<?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: Convert DBObjectCollection to polyline in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/convert-dbobjectcollection-to-polyline/m-p/11731203#M10109</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;correct, I knew there were cases where there may be multiples I just couldn't think of any examples last night. Thanks for the correction.&lt;/P&gt;</description>
    <pubDate>Sun, 05 Feb 2023 16:04:02 GMT</pubDate>
    <dc:creator>Jeff_M</dc:creator>
    <dc:date>2023-02-05T16:04:02Z</dc:date>
    <item>
      <title>Convert DBObjectCollection to polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/convert-dbobjectcollection-to-polyline/m-p/11730117#M10104</link>
      <description>&lt;P&gt;Hello Forums,&lt;/P&gt;&lt;P&gt;I'm trying to work with "GetOffsetCurves()"&amp;nbsp; in order to create a offset polyline(opened), but it return a DBObjectCollection. To convert this collections, I put a function :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;public Polyline ConvertDBObjectToPolyline(Document doc, DBObjectCollection dbcol, Plane _plane)
        {
            Polyline _Pline = new Polyline();
            Database db = doc.Database;

            Transaction tr =doc.TransactionManager.StartTransaction();
            using (tr)
            {
                BlockTable bt =(BlockTable)tr.GetObject(db.BlockTableId,OpenMode.ForWrite);
                BlockTableRecord btr =(BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);

                // For initial Curve take the first in the list
                Curve cv1 = dbcol[0] as Curve;

                _Pline.AddVertexAt(_Pline.NumberOfVertices, cv1.StartPoint.Convert2d(_plane), BulgeFromCurve(cv1, false), 0, 0);
                _Pline.AddVertexAt(_Pline.NumberOfVertices, cv1.EndPoint.Convert2d(_plane), 0, 0, 0);
                dbcol.Remove(cv1);

                Point3d nextPt = cv1.EndPoint;
                int prevCnt = dbcol.Count + 1;

                while (dbcol.Count &amp;gt; 0 &amp;amp;&amp;amp; dbcol.Count &amp;lt; prevCnt)
                {
                    prevCnt = dbcol.Count;
                    foreach (Curve cv in dbcol)
                    {
                        // If one end of the curve connects with the
                        // point we're looking for...
                        if (cv.StartPoint == nextPt || cv.EndPoint == nextPt)
                        {
                            // Calculate the bulge for the curve and
                            // set it on the previous vertex
                            double bulge = BulgeFromCurve(cv,false);
                            _Pline.SetBulgeAt(_Pline.NumberOfVertices - 1, bulge);

                            // Reverse the points, if needed
                            if (cv.StartPoint == nextPt)
                                nextPt = cv.EndPoint;
                            else
                                // cv.EndPoint == nextPt
                                nextPt = cv.StartPoint;

                            // Add out new vertex (bulge will be set next
                            // time through, as needed)
                            _Pline.AddVertexAt(_Pline.NumberOfVertices, nextPt.Convert2d(_plane), 0, 0, 0);

                            // Remove our curve from the list, which
                            // decrements the count, of course
                            dbcol.Remove(cv);

                            break;
                        }
                    }
                }

                tr.Commit();
            }

            return _Pline;
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After debugging, it's doesn't march in all segments!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Feb 2023 18:50:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/convert-dbobjectcollection-to-polyline/m-p/11730117#M10104</guid>
      <dc:creator>youssefGC</dc:creator>
      <dc:date>2023-02-04T18:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: Convert DBObjectCollection to polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/convert-dbobjectcollection-to-polyline/m-p/11730499#M10105</link>
      <description>&lt;P&gt;The DBObjectCollection from an offset polyline should only contain 1 object, a Polyline.&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;//crv is a Polyline object
var offset = crv.GetOffsetCurves(15.0);
var pline = (Polyline)offset[0];&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 05 Feb 2023 00:32:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/convert-dbobjectcollection-to-polyline/m-p/11730499#M10105</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2023-02-05T00:32:56Z</dc:date>
    </item>
    <item>
      <title>Re: Convert DBObjectCollection to polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/convert-dbobjectcollection-to-polyline/m-p/11730753#M10106</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;More accurately, the GetOffsetCurves method returns a DBObjectCollection because offesting a curve may generate more than one curve. If the the source curve is a polyline, the generated curves are also polylines&lt;/P&gt;
&lt;P&gt;&lt;div class="lia-vid-container video-embed-center"&gt;&lt;div id="lia-vid-6319826024112w808h332r761" class="lia-video-brightcove-player-container"&gt;&lt;video-js data-video-id="6319826024112" data-account="6057940548001" data-player="default" data-embed="default" class="vjs-fluid" controls="" data-application-id="" style="width: 100%; height: 100%;"&gt;&lt;/video-js&gt;&lt;/div&gt;&lt;script src="https://players.brightcove.net/6057940548001/default_default/index.min.js"&gt;&lt;/script&gt;&lt;script&gt;(function() {  var wrapper = document.getElementById('lia-vid-6319826024112w808h332r761');  var videoEl = wrapper ? wrapper.querySelector('video-js') : null;  if (videoEl) {     if (window.videojs) {       window.videojs(videoEl).ready(function() {         this.on('loadedmetadata', function() {           this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) {             bar.setAttribute('role', 'presentation');             bar.setAttribute('aria-hidden', 'true');           });         });       });     }  }})();&lt;/script&gt;&lt;a class="video-embed-link" href="https://forums.autodesk.com/t5/video/gallerypage/video-id/6319826024112"&gt;(view in My Videos)&lt;/a&gt;&lt;/div&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your ConvertDBObjectToPolyline method could be simply like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;        public void ConvertDBObjectToPolyline(Database db, DBObjectCollection dbCol)
        {
            using (var tr = db.TransactionManager.StartTransaction())
            {
                var modelSpace = (BlockTableRecord)tr.GetObject(
                    SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite);
                foreach(Curve curve in dbCol)
                {
                    modelSpace.AppendEntity(curve);
                    tr.AddNewlyCreatedDBObject(curve, true);
                }
                tr.Commit();
            }
        }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Feb 2023 09:24:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/convert-dbobjectcollection-to-polyline/m-p/11730753#M10106</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-02-05T09:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: Convert DBObjectCollection to polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/convert-dbobjectcollection-to-polyline/m-p/11730941#M10107</link>
      <description>That works, thanks a lot</description>
      <pubDate>Sun, 05 Feb 2023 10:47:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/convert-dbobjectcollection-to-polyline/m-p/11730941#M10107</guid>
      <dc:creator>youssefGC</dc:creator>
      <dc:date>2023-02-05T10:47:50Z</dc:date>
    </item>
    <item>
      <title>Re: Convert DBObjectCollection to polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/convert-dbobjectcollection-to-polyline/m-p/11730944#M10108</link>
      <description>Yes, but I want to retrieve it as a polyline</description>
      <pubDate>Sun, 05 Feb 2023 10:49:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/convert-dbobjectcollection-to-polyline/m-p/11730944#M10108</guid>
      <dc:creator>youssefGC</dc:creator>
      <dc:date>2023-02-05T10:49:17Z</dc:date>
    </item>
    <item>
      <title>Re: Convert DBObjectCollection to polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/convert-dbobjectcollection-to-polyline/m-p/11731203#M10109</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;correct, I knew there were cases where there may be multiples I just couldn't think of any examples last night. Thanks for the correction.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Feb 2023 16:04:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/convert-dbobjectcollection-to-polyline/m-p/11731203#M10109</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2023-02-05T16:04:02Z</dc:date>
    </item>
  </channel>
</rss>

