<?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: get perimeter sum in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/get-perimeter-sum/m-p/12526633#M5728</link>
    <description>&lt;P&gt;Please read my reply CAREFULLY: you need to MOVE the line of code&amp;nbsp; for adding up perimeter OUT OF the "if..." block:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;                foreach (DBObject obj in objs)
                {
                    Curve c = obj as Curve;
                    if (c != null)
                    {
                        ObjectId curveId = cspace.AppendEntity(c);
                        tr.AddNewlyCreatedDBObject(c, true);
                        c.Layer = layerName;
                        ids.Add(curveId);

                        if (c.Area &amp;gt; area2)
                        {
                            idmain = curveId;
                            area2 = c.Area;
                        }
                        //ADDING UP the length of each curve
                        perimeter2 += c.GetDistanceAtParameter(c.StartParam) + c.GetDistanceAtParameter(c.EndParam);
                    }
                }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 29 Jan 2024 14:28:01 GMT</pubDate>
    <dc:creator>norman.yuan</dc:creator>
    <dc:date>2024-01-29T14:28:01Z</dc:date>
    <item>
      <title>get perimeter sum</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-perimeter-sum/m-p/12526449#M5725</link>
      <description>&lt;P&gt;Hello friends;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;In the code I have given below, the perimeter2 variable outputs the total incorrectly. Where can I go wrong?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks in advance to the helpful friend.&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;   PromptPointResult ppr = ed.GetPoint("\nKirişe Tıkla &amp;gt;");
            if (ppr.Status != PromptStatus.OK) return;

            DBObjectCollection objs = ed.TraceBoundary(ppr.Value, true);
            if (objs.Count == 0) return;
            ObjectIdCollection ids = new ObjectIdCollection();
            ObjectId idmain = ObjectId.Null;

            double area2 = 0.0;
            double perimeter2 = 0.0;

using (Transaction tr = doc.TransactionManager.StartTransaction())
            using (DocumentLock docLock = doc.LockDocument())
            {
                string layerName = "Gecici";
                string rgbTxt = "255,253,189";
                CreateLayer(layerName, rgbTxt);
                BlockTableRecord cspace = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);

                foreach (DBObject obj in objs)
                {
                    Curve c = obj as Curve;
                    if (c != null)
                    {
                        ObjectId curveId = cspace.AppendEntity(c);
                        tr.AddNewlyCreatedDBObject(c, true);
                        c.Layer = layerName;
                        ids.Add(curveId);

                        if (c.Area &amp;gt; area2)
                        {
                            idmain = curveId;
                            area2 = c.Area;
                            //perimeter2 += c.GetDistanceAtParameter(c.EndParam);
                            perimeter2 += c.GetDistanceAtParameter(c.StartParam) + c.GetDistanceAtParameter(c.EndParam);
                            

                        }
                    }
                }

                tr.Commit();
            }&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;</description>
      <pubDate>Mon, 29 Jan 2024 14:18:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-perimeter-sum/m-p/12526449#M5725</guid>
      <dc:creator>k005</dc:creator>
      <dc:date>2024-01-29T14:18:23Z</dc:date>
    </item>
    <item>
      <title>Re: get perimeter sum</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-perimeter-sum/m-p/12526487#M5726</link>
      <description>&lt;P&gt;You did not explain your goal clearly: what the "if (c.Area &amp;gt; area2) {...}" is for. My guess is that after looping the collection of Curves, you want to find the total perimeter length of ALL curve, and identify the curve with largest area. If that is your goal, you need to move&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="lia-code-sample line-numbers language-csharp" tabindex="0"&gt;&lt;CODE&gt;perimeter2 += c.GetDistanceAtParameter(c.StartParam) + c.GetDistanceAtParameter(c.EndParam);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;out of the "if..." block, so that each curve's perimeter is added to the total length.&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;</description>
      <pubDate>Mon, 29 Jan 2024 13:38:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-perimeter-sum/m-p/12526487#M5726</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2024-01-29T13:38:21Z</dc:date>
    </item>
    <item>
      <title>Re: get perimeter sum</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-perimeter-sum/m-p/12526593#M5727</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="curve.png" style="width: 325px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1319432iB515520C77BE4A9E/image-size/large?v=v2&amp;amp;px=999" role="button" title="curve.png" alt="curve.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;* I start the code with getpoint...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"if (c.Area &amp;gt; area2) {...}"&amp;nbsp; There may be an error in the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to get the total length of the curves. I have nothing to do with the field.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;However, the value entered into the perimeter2 variable is incorrect.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2024 14:19:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-perimeter-sum/m-p/12526593#M5727</guid>
      <dc:creator>k005</dc:creator>
      <dc:date>2024-01-29T14:19:37Z</dc:date>
    </item>
    <item>
      <title>Re: get perimeter sum</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-perimeter-sum/m-p/12526633#M5728</link>
      <description>&lt;P&gt;Please read my reply CAREFULLY: you need to MOVE the line of code&amp;nbsp; for adding up perimeter OUT OF the "if..." block:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;                foreach (DBObject obj in objs)
                {
                    Curve c = obj as Curve;
                    if (c != null)
                    {
                        ObjectId curveId = cspace.AppendEntity(c);
                        tr.AddNewlyCreatedDBObject(c, true);
                        c.Layer = layerName;
                        ids.Add(curveId);

                        if (c.Area &amp;gt; area2)
                        {
                            idmain = curveId;
                            area2 = c.Area;
                        }
                        //ADDING UP the length of each curve
                        perimeter2 += c.GetDistanceAtParameter(c.StartParam) + c.GetDistanceAtParameter(c.EndParam);
                    }
                }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2024 14:28:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-perimeter-sum/m-p/12526633#M5728</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2024-01-29T14:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: get perimeter sum</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-perimeter-sum/m-p/12526636#M5729</link>
      <description>&lt;P&gt;I am sorry. I realized later.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thank you. Dear &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/543921"&gt;@norman.yuan&lt;/a&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2024 14:29:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-perimeter-sum/m-p/12526636#M5729</guid>
      <dc:creator>k005</dc:creator>
      <dc:date>2024-01-29T14:29:53Z</dc:date>
    </item>
  </channel>
</rss>

