<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Draw Dimension feature using ArcObjects in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/draw-dimension-feature-using-arcobjects/m-p/1123265#M20412</link>
    <description>&lt;P&gt;Hello all&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; I have a task I need to create a tool to draw a dimension feature using ArcObjects C#, I did many search but I can not find any think about this.&lt;/P&gt;&lt;P&gt;I tried to draw the dimension by cerate 3 point and then store the feature , the dimension created successfully but the dimension created with a wrong angle so the length the line becomes wrong.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/28959iE8CBB29C08F733EF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; this image shows the difference between the dimension draw by my tool (the selected one in blue) and the right one.&lt;/P&gt;&lt;P&gt;and that is my code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; private IPoint pPoint1;
        private IPoint pPoint2;
        private IPoint pPoint3;
        private int i = 0;

 protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            try
            {
                i++;

                string layerName = GlobalVariables.DimensionLayer;
                IMxDocument mxDoc = ArcMap.Application.Document as IMxDocument;
                IMap m_pMap;
                m_pMap = ArcMap.Document.FocusMap;
                if (i == 1)
                {
                    pPoint1 = mxDoc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y);
                }
                else if (i == 2)
                {
                    pPoint2 = mxDoc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y);
                }
                else if (i == 3)
                {
                    i = 0;
                    pPoint3 = mxDoc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y);

                    #region Dimension
                    IFeatureLayer pePipeFeatureLayer = null;
                    ILayer pePipeLayer = null;
                    for (int j = 0; j &amp;lt; m_pMap.LayerCount; j++)
                    {
                        pePipeLayer = m_pMap.Layer[j];
                        if (pePipeLayer.Name.Contains(layerName))
                        {
                            pePipeFeatureLayer = (IFeatureLayer)pePipeLayer;
                        }
                    }
                    IFeatureClass pFClass;
                    pFClass = pePipeFeatureLayer.FeatureClass;
                    IDataset pePipeDataset = (IDataset)pePipeFeatureLayer;

                    #endregion


                    IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)((IDataset)(pePipeFeatureLayer.FeatureClass)).Workspace;
                    workspaceEdit.StartEditing(false);
                    workspaceEdit.StartEditOperation();

                    IFeature pFeature = pePipeFeatureLayer.FeatureClass.CreateFeature();
                    int dimLength = pFeature.Fields.FindField("DIMLENGTH");
                    int BEGINX = pFeature.Fields.FindField("BEGINX");
                    int BEGINY = pFeature.Fields.FindField("BEGINY");
                    int ENDX = pFeature.Fields.FindField("ENDX");
                    int ENDY = pFeature.Fields.FindField("ENDY");
                    int DIMX = pFeature.Fields.FindField("DIMX");
                    int DIMY = pFeature.Fields.FindField("DIMY");
                    int TEXTX = pFeature.Fields.FindField("TEXTX");
                    int TEXTY = pFeature.Fields.FindField("TEXTY");
                    int DIMTYPE = pFeature.Fields.FindField("DIMTYPE");
                    int EXTANGLE = pFeature.Fields.FindField("EXTANGLE");
                    int STYLEID = pFeature.Fields.FindField("STYLEID");
                    int USECUSTOMLENGTH = pFeature.Fields.FindField("USECUSTOMLENGTH");
                    int CUSTOMLENGTH = pFeature.Fields.FindField("CUSTOMLENGTH");
                    int DIMDISPLAY = pFeature.Fields.FindField("DIMDISPLAY");
                    int EXTDISPLAY = pFeature.Fields.FindField("EXTDISPLAY");
                    int MARKERDISPLAY = pFeature.Fields.FindField("MARKERDISPLAY");
                    int TEXTANGLE = pFeature.Fields.FindField("TEXTANGLE");
                    int SHAPE = pFeature.Fields.FindField("SHAPE");
                    int SHAPESTArea = pFeature.Fields.FindField("SHAPE.STArea()");
                    int SHAPESTLength = pFeature.Fields.FindField("SHAPE.STLength()");


                    // pFeature.Value[dimLength] = 36.169741;
                    pFeature.Value[BEGINX] = pPoint1.X;
                    pFeature.Value[BEGINY] = pPoint1.Y;
                    pFeature.Value[ENDX] = pPoint2.X;
                    pFeature.Value[ENDY] = pPoint2.Y;
                    pFeature.Value[DIMX] = pPoint3.X;
                    pFeature.Value[DIMY] = pPoint3.Y;
                    //pFeature.Value[TEXTX] = null;
                    //pFeature.Value[TEXTY] = null;
                    pFeature.Value[DIMTYPE] = 0;
                    pFeature.Value[EXTANGLE] = 1.570796;
                    pFeature.Value[STYLEID] = 0;
                    pFeature.Value[USECUSTOMLENGTH] = 0;
                    pFeature.Value[CUSTOMLENGTH] = 0;
                    //pFeature.Value[DIMDISPLAY] = null;
                    //pFeature.Value[EXTDISPLAY] = null;
                    //pFeature.Value[MARKERDISPLAY] = null;
                    pFeature.Value[TEXTANGLE] = 0;


                    pFeature.Store();

                    workspaceEdit.StopEditOperation();
                    workspaceEdit.StopEditing(true);
                    mxDoc.ActiveView.Refresh();

                    pPoint1 = null;
                    pPoint2 = null;
                    pPoint3 = null;

                    ArcMap.Application.CurrentTool.Refresh();
                }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Dec 2021 09:24:08 GMT</pubDate>
    <dc:creator>MohammedAlsadaany</dc:creator>
    <dc:date>2021-12-07T09:24:08Z</dc:date>
    <item>
      <title>Draw Dimension feature using ArcObjects</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/draw-dimension-feature-using-arcobjects/m-p/1123265#M20412</link>
      <description>&lt;P&gt;Hello all&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; I have a task I need to create a tool to draw a dimension feature using ArcObjects C#, I did many search but I can not find any think about this.&lt;/P&gt;&lt;P&gt;I tried to draw the dimension by cerate 3 point and then store the feature , the dimension created successfully but the dimension created with a wrong angle so the length the line becomes wrong.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/28959iE8CBB29C08F733EF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; this image shows the difference between the dimension draw by my tool (the selected one in blue) and the right one.&lt;/P&gt;&lt;P&gt;and that is my code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; private IPoint pPoint1;
        private IPoint pPoint2;
        private IPoint pPoint3;
        private int i = 0;

 protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            try
            {
                i++;

                string layerName = GlobalVariables.DimensionLayer;
                IMxDocument mxDoc = ArcMap.Application.Document as IMxDocument;
                IMap m_pMap;
                m_pMap = ArcMap.Document.FocusMap;
                if (i == 1)
                {
                    pPoint1 = mxDoc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y);
                }
                else if (i == 2)
                {
                    pPoint2 = mxDoc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y);
                }
                else if (i == 3)
                {
                    i = 0;
                    pPoint3 = mxDoc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y);

                    #region Dimension
                    IFeatureLayer pePipeFeatureLayer = null;
                    ILayer pePipeLayer = null;
                    for (int j = 0; j &amp;lt; m_pMap.LayerCount; j++)
                    {
                        pePipeLayer = m_pMap.Layer[j];
                        if (pePipeLayer.Name.Contains(layerName))
                        {
                            pePipeFeatureLayer = (IFeatureLayer)pePipeLayer;
                        }
                    }
                    IFeatureClass pFClass;
                    pFClass = pePipeFeatureLayer.FeatureClass;
                    IDataset pePipeDataset = (IDataset)pePipeFeatureLayer;

                    #endregion


                    IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)((IDataset)(pePipeFeatureLayer.FeatureClass)).Workspace;
                    workspaceEdit.StartEditing(false);
                    workspaceEdit.StartEditOperation();

                    IFeature pFeature = pePipeFeatureLayer.FeatureClass.CreateFeature();
                    int dimLength = pFeature.Fields.FindField("DIMLENGTH");
                    int BEGINX = pFeature.Fields.FindField("BEGINX");
                    int BEGINY = pFeature.Fields.FindField("BEGINY");
                    int ENDX = pFeature.Fields.FindField("ENDX");
                    int ENDY = pFeature.Fields.FindField("ENDY");
                    int DIMX = pFeature.Fields.FindField("DIMX");
                    int DIMY = pFeature.Fields.FindField("DIMY");
                    int TEXTX = pFeature.Fields.FindField("TEXTX");
                    int TEXTY = pFeature.Fields.FindField("TEXTY");
                    int DIMTYPE = pFeature.Fields.FindField("DIMTYPE");
                    int EXTANGLE = pFeature.Fields.FindField("EXTANGLE");
                    int STYLEID = pFeature.Fields.FindField("STYLEID");
                    int USECUSTOMLENGTH = pFeature.Fields.FindField("USECUSTOMLENGTH");
                    int CUSTOMLENGTH = pFeature.Fields.FindField("CUSTOMLENGTH");
                    int DIMDISPLAY = pFeature.Fields.FindField("DIMDISPLAY");
                    int EXTDISPLAY = pFeature.Fields.FindField("EXTDISPLAY");
                    int MARKERDISPLAY = pFeature.Fields.FindField("MARKERDISPLAY");
                    int TEXTANGLE = pFeature.Fields.FindField("TEXTANGLE");
                    int SHAPE = pFeature.Fields.FindField("SHAPE");
                    int SHAPESTArea = pFeature.Fields.FindField("SHAPE.STArea()");
                    int SHAPESTLength = pFeature.Fields.FindField("SHAPE.STLength()");


                    // pFeature.Value[dimLength] = 36.169741;
                    pFeature.Value[BEGINX] = pPoint1.X;
                    pFeature.Value[BEGINY] = pPoint1.Y;
                    pFeature.Value[ENDX] = pPoint2.X;
                    pFeature.Value[ENDY] = pPoint2.Y;
                    pFeature.Value[DIMX] = pPoint3.X;
                    pFeature.Value[DIMY] = pPoint3.Y;
                    //pFeature.Value[TEXTX] = null;
                    //pFeature.Value[TEXTY] = null;
                    pFeature.Value[DIMTYPE] = 0;
                    pFeature.Value[EXTANGLE] = 1.570796;
                    pFeature.Value[STYLEID] = 0;
                    pFeature.Value[USECUSTOMLENGTH] = 0;
                    pFeature.Value[CUSTOMLENGTH] = 0;
                    //pFeature.Value[DIMDISPLAY] = null;
                    //pFeature.Value[EXTDISPLAY] = null;
                    //pFeature.Value[MARKERDISPLAY] = null;
                    pFeature.Value[TEXTANGLE] = 0;


                    pFeature.Store();

                    workspaceEdit.StopEditOperation();
                    workspaceEdit.StopEditing(true);
                    mxDoc.ActiveView.Refresh();

                    pPoint1 = null;
                    pPoint2 = null;
                    pPoint3 = null;

                    ArcMap.Application.CurrentTool.Refresh();
                }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 09:24:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/draw-dimension-feature-using-arcobjects/m-p/1123265#M20412</guid>
      <dc:creator>MohammedAlsadaany</dc:creator>
      <dc:date>2021-12-07T09:24:08Z</dc:date>
    </item>
  </channel>
</rss>

