This document is archived and information here might be outdated.  Recommended version.


esriSketchConstraint Constants (ArcObjects .NET 10.6 SDK)
ArcObjects Help for .NET developers > ArcObjects namespaces > Editor > ESRI.ArcGIS.Editor > Constants > E > esriSketchConstraint Constants (ArcObjects .NET 10.6 SDK)
ArcObjects Library Reference (Editor)  

esriSketchConstraint Constants

Constraints that can be applied to the sketch tool.

Constant Value Description
esriConstraintNone 0 No constraint.
esriConstraintAngle 1 Angle.
esriConstraintDistance 2 Distance.

Product Availability

Available with ArcGIS Desktop.

Remarks

Use the esriSketchConstraint enumeration along with additional properties on the ISketchTool interface to control how constraints are applied to the Sketch Tool. For example, to apply an angle constraint to the Sketch Tool, first set ISketchTool::Constraint to esriConstraintAngle and then set an angle value (measured in radians) in the ISketchTool::AngleConstraint property.

[C#]

This sample shows how to set the distance constraint on the sketch tool. This code was applied to a custom sketch tool, which declared the editor variable as a field class and set the value of m_editor before this code is called. The IApplication was also set as a field class and set to hook in the ICommand::OnCreate procedure.

 

private void SetDistanceConstraint()
   {
      ISketchTool sketchTool;
      double dist;
      IMxApplication mxApp;

      mxApp=app as IMxApplication;
      m_editor=mxApp.FindExtension("esriEditor.Editor")
      sketchTool=app.CurrentTool.Command as ISketchTool;
      INumberDialog distDialog=new NumberDialogClass();
      if (distDialog.DoModal("Distance", 0, 2, m_editor.Display.hWnd))
      {
        dist=distDialog.Value;
        sketchTool.DistanceConstraint=dist;
        sketchTool.Constraint=esriSketchConstraint.esriConstraintDistance;
      }
    }

[Visual Basic .NET]

This sample sets the Distance constraint on a sketch tool that is implemented using BaseTool, the IApplication that is defined as app as a module variable was assigned the value of hook in the OnCreate method.

  Private Sub SetDistanceConstraint()
    Dim editor as IEditor
    Dim sketchTool As ISketchTool
    Dim dist As Double
    Dim responce As String
    Dim mxDocApp As IMxApplication

    mxDocApp=app
    editor=mxDocApp.FindExtension("esriEditor.Editor")
    sketchTool=app.CurrentTool.Command
    responce=InputBox("Enter the constraint distance", "Distance", 0)
    dist=Double.Parse(responce)
    sketchTool.AngleConstraint=dist
    sketchTool.Constraint=esriSketchConstraint.esriConstraintDistance

  End Sub