<?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 Re: Why my auto dimension code does not work? in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/why-my-auto-dimension-code-does-not-work/m-p/11370523#M11966</link>
    <description>when does not work I will record video and send you.</description>
    <pubDate>Sat, 20 Aug 2022 11:45:04 GMT</pubDate>
    <dc:creator>MarkJamesRogolino</dc:creator>
    <dc:date>2022-08-20T11:45:04Z</dc:date>
    <item>
      <title>Why my auto dimension code does not work?</title>
      <link>https://forums.autodesk.com/t5/net-forum/why-my-auto-dimension-code-does-not-work/m-p/11368137#M11959</link>
      <description>&lt;P&gt;Hello, everyone.&lt;/P&gt;&lt;P&gt;now I am making a autodimension plugin with c#.&lt;/P&gt;&lt;P&gt;my code is as followings.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;public static void Dimenssion()&lt;BR /&gt;{&lt;BR /&gt;var documentManager = Application.DocumentManager;&lt;BR /&gt;var currentDocument = documentManager.MdiActiveDocument;&lt;BR /&gt;var db = currentDocument.Database;&lt;BR /&gt;var ed = currentDocument.Editor;&lt;BR /&gt;using (var tr = db.TransactionManager.StartOpenCloseTransaction())&lt;BR /&gt;{&lt;BR /&gt;var blockTable = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);&lt;BR /&gt;foreach (ObjectId btrId in blockTable)&lt;BR /&gt;{&lt;BR /&gt;var btr = (BlockTableRecord)tr.GetObject(btrId, OpenMode.ForWrite);&lt;BR /&gt;var PlineCls = RXObject.GetClass(typeof(Polyline));&lt;BR /&gt;if (btr.IsLayout)&lt;BR /&gt;{&lt;BR /&gt;foreach (ObjectId id in btr)&lt;BR /&gt;{&lt;BR /&gt;if (id.ObjectClass == PlineCls)&lt;BR /&gt;{&lt;BR /&gt;var pline = (Polyline)tr.GetObject(id, OpenMode.ForRead);&lt;BR /&gt;string curlay = pline.Layer;&lt;BR /&gt;&lt;BR /&gt;int cnt = pline.NumberOfVertices;&lt;BR /&gt;for (int i = 0; i &amp;lt; cnt-1; i++)&lt;BR /&gt;{&lt;BR /&gt;Point3d startpt = pline.GetPoint3dAt(i);&lt;BR /&gt;Point3d endpt = pline.GetPoint3dAt(i + 1);&lt;BR /&gt;string str=System.DateTime.Now.ToString()+ curlay +":"+cnt.ToString() + " : " + startpt.X.ToString();&lt;BR /&gt;WriteLog(str);&lt;BR /&gt;&lt;BR /&gt;RotatedDimension acRotDim = new RotatedDimension();&lt;BR /&gt;acRotDim.SetDatabaseDefaults();&lt;BR /&gt;acRotDim.XLine1Point = startpt;&lt;BR /&gt;acRotDim.XLine2Point = endpt;&lt;BR /&gt;acRotDim.Rotation = 0.707;&lt;BR /&gt;acRotDim.Visible = true;&lt;BR /&gt;acRotDim.DimLinePoint = new Point3d(0, 7, 0);&lt;BR /&gt;acRotDim.DimensionStyle = db.Dimstyle;&lt;BR /&gt;acRotDim.Layer = curlay;&lt;BR /&gt;btr.AppendEntity(acRotDim);&lt;BR /&gt;tr.AddNewlyCreatedDBObject(acRotDim, true);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;tr.Commit();&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Please someone help me. Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2022 04:06:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/why-my-auto-dimension-code-does-not-work/m-p/11368137#M11959</guid>
      <dc:creator>MarkJamesRogolino</dc:creator>
      <dc:date>2022-08-19T04:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: Why my auto dimension code does not work?</title>
      <link>https://forums.autodesk.com/t5/net-forum/why-my-auto-dimension-code-does-not-work/m-p/11368207#M11960</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;To auto dimension randomly oriented polyline segments, you should not use rotated dimensions. Use aligned dimensions instead.&lt;/P&gt;
&lt;P&gt;You should separate the different tasks of the whole process into simpler methods.&lt;/P&gt;
&lt;P&gt;This way you can separately test each step and adapt it to suit your needs.&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;        private static AlignedDimension AddAlignedDimension(Point3d pt1, Point3d pt2, BlockTableRecord btr, Transaction tr)
        {
            var db = btr.Database;
            var linePt = pt1 + (pt2 - pt1).GetPerpendicularVector().GetNormal() * db.Dimtxt * 2.0;
            var dim = new AlignedDimension(pt1, pt2, linePt, "", db.Dimstyle);
            btr.AppendEntity(dim);
            tr.AddNewlyCreatedDBObject(dim, true);
            return dim;
        }

        private static void PolylineAutoDimension(Polyline pline, BlockTableRecord btr, Transaction tr)
        {
            int i;
            for (i = 0; i &amp;lt; pline.NumberOfVertices - 1; i++)
            {
                var dim = AddAlignedDimension(pline.GetPoint3dAt(i), pline.GetPoint3dAt(i + 1), btr, tr);
                dim.Layer = pline.Layer;
            }
            if (pline.Closed)
            {
                var dim = AddAlignedDimension(pline.GetPoint3dAt(i), pline.GetPoint3dAt(0), btr, tr);
                dim.Layer = pline.Layer;
            }
        }&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;PS: use the "Insert/Edit code sample" button (&amp;lt;/&amp;gt;) when you post code samples.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2022 06:06:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/why-my-auto-dimension-code-does-not-work/m-p/11368207#M11960</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2022-08-19T06:06:22Z</dc:date>
    </item>
    <item>
      <title>Re: Why my auto dimension code does not work?</title>
      <link>https://forums.autodesk.com/t5/net-forum/why-my-auto-dimension-code-does-not-work/m-p/11370215#M11961</link>
      <description>&lt;P&gt;Thank you very much. Your help has always been correct.&lt;/P&gt;&lt;P&gt;My Next issue is Hatch problem. Could you help me?&lt;/P&gt;</description>
      <pubDate>Sat, 20 Aug 2022 04:08:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/why-my-auto-dimension-code-does-not-work/m-p/11370215#M11961</guid>
      <dc:creator>MarkJamesRogolino</dc:creator>
      <dc:date>2022-08-20T04:08:53Z</dc:date>
    </item>
    <item>
      <title>Re: Why my auto dimension code does not work?</title>
      <link>https://forums.autodesk.com/t5/net-forum/why-my-auto-dimension-code-does-not-work/m-p/11370228#M11962</link>
      <description>&lt;A href="https://forums.autodesk.com/t5/net/how-to-hatch-polygon-polyline-using-c/td-p/11364455" target="_blank"&gt;https://forums.autodesk.com/t5/net/how-to-hatch-polygon-polyline-using-c/td-p/11364455&lt;/A&gt;&lt;BR /&gt;?</description>
      <pubDate>Sat, 20 Aug 2022 04:24:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/why-my-auto-dimension-code-does-not-work/m-p/11370228#M11962</guid>
      <dc:creator>MarkJamesRogolino</dc:creator>
      <dc:date>2022-08-20T04:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: Why my auto dimension code does not work?</title>
      <link>https://forums.autodesk.com/t5/net-forum/why-my-auto-dimension-code-does-not-work/m-p/11370464#M11963</link>
      <description>&lt;P&gt;Thanks. Your code sometimes works well but sometimes does not work.&lt;/P&gt;&lt;P&gt;strange phenomena.&lt;span class="lia-unicode-emoji" title=":face_with_rolling_eyes:"&gt;🙄&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Aug 2022 10:31:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/why-my-auto-dimension-code-does-not-work/m-p/11370464#M11963</guid>
      <dc:creator>MarkJamesRogolino</dc:creator>
      <dc:date>2022-08-20T10:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: Why my auto dimension code does not work?</title>
      <link>https://forums.autodesk.com/t5/net-forum/why-my-auto-dimension-code-does-not-work/m-p/11370477#M11964</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12396114"&gt;@MarkJamesRogolino&lt;/a&gt;&amp;nbsp; a écrit&amp;nbsp;:&lt;BR /&gt;
&lt;P&gt;Your code sometimes works well but sometimes does not work.&lt;span class="lia-unicode-emoji" title=":face_with_rolling_eyes:"&gt;🙄&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What do tou mean with "does not work"? Nobody can help you if you do not provide more explanations and/or an example.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Aug 2022 10:53:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/why-my-auto-dimension-code-does-not-work/m-p/11370477#M11964</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2022-08-20T10:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: Why my auto dimension code does not work?</title>
      <link>https://forums.autodesk.com/t5/net-forum/why-my-auto-dimension-code-does-not-work/m-p/11370520#M11965</link>
      <description>&lt;P&gt;This is my code.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; public static void Dimenssion()
        {
            var documentManager = Application.DocumentManager;
            var currentDocument = documentManager.MdiActiveDocument;
            var db = currentDocument.Database;
            var ed = currentDocument.Editor;
            using (var tr = db.TransactionManager.StartOpenCloseTransaction())
            {
                var blockTable = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
                foreach (ObjectId btrId in blockTable)
                {
                    var btr = (BlockTableRecord)tr.GetObject(btrId, OpenMode.ForWrite);
                    var PlineCls = RXObject.GetClass(typeof(Polyline));
                    if (btr.IsLayout)
                    {
                        foreach (ObjectId id in btr)
                        {
                            if (id.ObjectClass == PlineCls)
                            {
                                var pline = (Polyline)tr.GetObject(id, OpenMode.ForRead);
                                string curlay = pline.Layer;
                                if (IsReqDim(curlay)==true)
                                {
                                    int cnt = pline.NumberOfVertices;
                                    for (int i = 0; i &amp;lt; cnt-1; i++)
                                    {
                                        Point3d startpt = pline.GetPoint3dAt(i);
                                        Point3d endpt = pline.GetPoint3dAt(i + 1);
                                        string str="Dimension&amp;lt;&amp;gt;"+System.DateTime.Now.ToString()+ ": "+curlay +":"+cnt.ToString() + " : " + startpt.X.ToString();
                                        WriteLog(str);
                                                                                var dim = AddAlignedDimension(pline.GetPoint3dAt(i), pline.GetPoint3dAt(i + 1), btr, tr);
                                        dim.Layer = pline.Layer;                                        
                                        
                                    }
                                }
                            }
                        }
                    }
                }
                //ed.UpdateScreen();
                tr.Commit();
            }
        }
private static AlignedDimension AddAlignedDimension(Point3d pt1, Point3d pt2, BlockTableRecord btr, Transaction tr)
        {
            var db = btr.Database;
            var linePt = pt1 + (pt2 - pt1).GetPerpendicularVector().GetNormal() * db.Dimtxt * 2.0;
            var dim = new AlignedDimension(pt1, pt2, linePt, "", db.Dimstyle);
            btr.AppendEntity(dim);
            tr.AddNewlyCreatedDBObject(dim, true);
            return dim;
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here IsreqDim() function returns if should display dimension or not.&amp;nbsp;&lt;/P&gt;&lt;P&gt;and Writelog() function write text of polyline positions.&lt;/P&gt;&lt;P&gt;This code sometimes works and does not work on the same drawing.&lt;/P&gt;&lt;P&gt;Hope your help.&lt;/P&gt;&lt;P&gt;if you need more info please tell me. Thanks.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Aug 2022 11:40:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/why-my-auto-dimension-code-does-not-work/m-p/11370520#M11965</guid>
      <dc:creator>MarkJamesRogolino</dc:creator>
      <dc:date>2022-08-20T11:40:55Z</dc:date>
    </item>
    <item>
      <title>Re: Why my auto dimension code does not work?</title>
      <link>https://forums.autodesk.com/t5/net-forum/why-my-auto-dimension-code-does-not-work/m-p/11370523#M11966</link>
      <description>when does not work I will record video and send you.</description>
      <pubDate>Sat, 20 Aug 2022 11:45:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/why-my-auto-dimension-code-does-not-work/m-p/11370523#M11966</guid>
      <dc:creator>MarkJamesRogolino</dc:creator>
      <dc:date>2022-08-20T11:45:04Z</dc:date>
    </item>
    <item>
      <title>Re: Why my auto dimension code does not work?</title>
      <link>https://forums.autodesk.com/t5/net-forum/why-my-auto-dimension-code-does-not-work/m-p/11370540#M11967</link>
      <description>&lt;P&gt;working video and not working video.&lt;/P&gt;&lt;P&gt;I think it works after my another plugin loads.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Aug 2022 12:02:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/why-my-auto-dimension-code-does-not-work/m-p/11370540#M11967</guid>
      <dc:creator>MarkJamesRogolino</dc:creator>
      <dc:date>2022-08-20T12:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: Why my auto dimension code does not work?</title>
      <link>https://forums.autodesk.com/t5/net-forum/why-my-auto-dimension-code-does-not-work/m-p/11370547#M11968</link>
      <description>&lt;P&gt;The videos do not help at all.&lt;/P&gt;
&lt;P&gt;I do not see anything wrong in the code you show, maybe the issue is due to something in IsreqDim() or Writelog(). Did you try to comment them one by one and test?&lt;/P&gt;</description>
      <pubDate>Sat, 20 Aug 2022 12:09:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/why-my-auto-dimension-code-does-not-work/m-p/11370547#M11968</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2022-08-20T12:09:29Z</dc:date>
    </item>
    <item>
      <title>Re: Why my auto dimension code does not work?</title>
      <link>https://forums.autodesk.com/t5/net-forum/why-my-auto-dimension-code-does-not-work/m-p/11370553#M11969</link>
      <description>&lt;P&gt;Hi, Gile. my another problem is hatch issue.&lt;/P&gt;&lt;P&gt;This is my code.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;[CommandMethod("htch")]
        public static void Hatch()
        {
            var documentManager = Application.DocumentManager;
            var currentDocument = documentManager.MdiActiveDocument;
            var db = currentDocument.Database;
            var ed = currentDocument.Editor;
            using (var tr = db.TransactionManager.StartOpenCloseTransaction())
            {
                var blockTable = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
                foreach (ObjectId btrId in blockTable)
                {
                    var btr = (BlockTableRecord)tr.GetObject(btrId, OpenMode.ForWrite);
                    var PlineCls = RXObject.GetClass(typeof(Polyline));
                    if (btr.IsLayout)
                    {
                        
                        foreach (ObjectId id in btr)
                        {
                            if (id.ObjectClass == PlineCls)
                            {
                                var pline = (Polyline)tr.GetObject(id, OpenMode.ForRead);
                                string curlay = pline.Layer;                                
                                if (IsreqHatch(curlay) == true)
                                {
                                    string str = "Hatch&amp;lt;&amp;gt;"+System.DateTime.Now.ToString()+ ": "+ curlay + ":" + id.ToString();
                                    WriteLog(str);                                    
                                    ObjectIdCollection ObjIds = new ObjectIdCollection();
                                    ObjIds.Add(id);
                                    MessageBox.Show(id.ToString());
                                    Hatch oHatch = new Hatch();
                                    Vector3d normal = new Vector3d(0.0, 0.0, 1.0);
                                    oHatch.Normal = normal;
                                    oHatch.Elevation = 0.0;
                                    oHatch.PatternScale = 2.0;
                                    oHatch.SetHatchPattern(HatchPatternType.PreDefined, "ZIGZAG");
                                    oHatch.HatchStyle = HatchStyle.Ignore;
                                    btr.AppendEntity(oHatch);
                                    tr.AddNewlyCreatedDBObject(oHatch, true);
                                    oHatch.Associative = true;
                                    oHatch.AppendLoop((int)HatchLoopTypes.Default, ObjIds);
                                    oHatch.EvaluateHatch(true);                                    
                                }
                            }
                        }                        
                    }
                }
                tr.Commit();
            }
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;but errors. Could you help me?&amp;nbsp; I&amp;nbsp;eagerly hope. Thanks.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Aug 2022 12:12:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/why-my-auto-dimension-code-does-not-work/m-p/11370553#M11969</guid>
      <dc:creator>MarkJamesRogolino</dc:creator>
      <dc:date>2022-08-20T12:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: Why my auto dimension code does not work?</title>
      <link>https://forums.autodesk.com/t5/net-forum/why-my-auto-dimension-code-does-not-work/m-p/11370568#M11970</link>
      <description>&lt;P&gt;Please don't add more confusion.&lt;/P&gt;
&lt;P&gt;I replied you in the &lt;A href="https://forums.autodesk.com/t5/net/my-polyline-hatch-code-has-terrible-error-and-does-not-work/td-p/11370318/jump-to/first-unread-message" target="_blank" rel="noopener"&gt;other post&lt;/A&gt; you started for this issue.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Aug 2022 12:22:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/why-my-auto-dimension-code-does-not-work/m-p/11370568#M11970</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2022-08-20T12:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: Why my auto dimension code does not work?</title>
      <link>https://forums.autodesk.com/t5/net-forum/why-my-auto-dimension-code-does-not-work/m-p/11370574#M11971</link>
      <description>&lt;P&gt;oh, sorry. I missed your reply. Thnx.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Aug 2022 12:25:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/why-my-auto-dimension-code-does-not-work/m-p/11370574#M11971</guid>
      <dc:creator>MarkJamesRogolino</dc:creator>
      <dc:date>2022-08-20T12:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: Why my auto dimension code does not work?</title>
      <link>https://forums.autodesk.com/t5/net-forum/why-my-auto-dimension-code-does-not-work/m-p/11380469#M11972</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="goldhorsemillion_0-1661488244240.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1107932i3528E34BC72AA888/image-size/medium?v=v2&amp;amp;px=400" role="button" title="goldhorsemillion_0-1661488244240.png" alt="goldhorsemillion_0-1661488244240.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;How to resize dimension arrow and font?&lt;/P&gt;&lt;P&gt;dimension arrow and font size is too large.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 12:36:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/why-my-auto-dimension-code-does-not-work/m-p/11380469#M11972</guid>
      <dc:creator>MarkJamesRogolino</dc:creator>
      <dc:date>2022-08-25T12:36:06Z</dc:date>
    </item>
  </channel>
</rss>

