<?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: How to copy lines and arcs and transform them into a closed polyline in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-copy-lines-and-arcs-and-transform-them-into-a-closed/m-p/11915912#M9074</link>
    <description>&lt;P&gt;Hi, thanks for the reply.&lt;/P&gt;&lt;P&gt;I tried using the Entity.JoinEntities method but it partially works.&lt;/P&gt;&lt;P&gt;I tried this:&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;        Dim doc As Document = Application.DocumentManager.MdiActiveDocument
        Dim db As Database = doc.Database

        Using tr As Transaction = db.TransactionManager.StartTransaction()
            Dim bt As BlockTable = tr.GetObject(db.BlockTableId, OpenMode.ForRead)
            Dim btr As BlockTableRecord = tr.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite)

            Dim Poly As Polyline = New Polyline
            btr.AppendEntity(Poly)
            tr.AddNewlyCreatedDBObject(Poly, True)

            Dim line1 As Line = New Line(New Point3d(0, 0, 0), New Point3d(100, 0, 0))
            btr.AppendEntity(line1)
            tr.AddNewlyCreatedDBObject(line1, True)

            Dim line2 As Line = New Line(New Point3d(0, 0, 0), New Point3d(0, 100, 0))
            btr.AppendEntity(line2)
            tr.AddNewlyCreatedDBObject(line2, True)

            Dim arc1 As Arc = New Arc(New Point3d(0, 0, 0), 100, 0, Math.PI / 2)
            btr.AppendEntity(arc1)
            tr.AddNewlyCreatedDBObject(arc1, True)

            Poly.JoinEntities(New Entity() {line1, line2, arc1})

            tr.Commit()
        End Using&lt;/LI-CODE&gt;&lt;P&gt;This code creates a polyline composed of line2 and arc1 but without line1.&lt;/P&gt;&lt;P&gt;If I change the line of code "Poly.JoinEntities(New Entity() {line1, line2, arc1})" with "Poly.JoinEntities(New Entity() {line1, arc1, line2})" the polyline is composed of line1 and arc1 but without line2.&lt;/P&gt;&lt;P&gt;Where do you think I'm wrong?&lt;/P&gt;&lt;P&gt;Thanks a lot, bye.&lt;/P&gt;</description>
    <pubDate>Sun, 23 Apr 2023 13:17:52 GMT</pubDate>
    <dc:creator>mecoman6GF27</dc:creator>
    <dc:date>2023-04-23T13:17:52Z</dc:date>
    <item>
      <title>How to copy lines and arcs and transform them into a closed polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-copy-lines-and-arcs-and-transform-them-into-a-closed/m-p/11914871#M9072</link>
      <description>&lt;P&gt;Hi everyone.&lt;BR /&gt;As per the title of the post I have to make a copy of lines and arcs and transform them into a closed polyline. I have no problem copying lines and arcs but I don't know how to join them into a closed polyline.&lt;/P&gt;&lt;P&gt;This is what I wrote.&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;        Dim doc As Document = Application.DocumentManager.MdiActiveDocument
        Dim db As Database = doc.Database
        Dim ed As Editor = doc.Editor

        Dim Filter_List1 As TypedValue() = New TypedValue(1) {}
        Filter_List1(0) = New TypedValue(0, "LINE")
        Filter_List1(1) = New TypedValue(8, "Line_Layer")

        Dim Sel_Filter1 As SelectionFilter = New SelectionFilter(Filter_List1)
        Dim Ris_Sel_Filter1 As PromptSelectionResult = ed.SelectAll(Sel_Filter1)

        If Ris_Sel_Filter1.Status &amp;lt;&amp;gt; PromptStatus.OK Then
            MsgBox("Error!!!")
            Return
        End If

        Dim Object_ID As ObjectId() = Ris_Sel_Filtri1.Value.GetObjectIds()

        Dim Obj_Entity_Entity As Entity
        Dim Obj_Entity_Line As Line
        Dim Obj_Entity_Line_Copy As Line

        Using tr1 As Transaction = db.TransactionManager.StartTransaction
            Dim Block_Tab1 As BlockTable = tr1.GetObject(db.BlockTableId, OpenMode.ForRead)
            Dim Block_Tab_Rec1 As BlockTableRecord = tr1.GetObject(Block_Tab1(BlockTableRecord.ModelSpace), OpenMode.ForWrite)

            For i As Integer = 0 To Object_ID.Length - 1
                Obj_Entity_Entity = Object_ID(i).GetObject(OpenMode.ForRead)
                Obj_Entity_Linee = TryCast(Obj_Entity_Entity, Line)

                Obj_Entity_Linee_Copy = Obj_Entity_Linee.Clone()
                Obj_Entity_Linee_Copy.Layer = "Line_Layer_Copy"
                Obj_Entity_Linee_Copy.SetDatabaseDefaults()
                Block_Tab_Rec1.AppendEntity(Obj_Entity_Linee_Copy)

                tr1.AddNewlyCreatedDBObject(Obj_Entity_Linee_Copy, True)
            Next

            tr1.Commit()
        End Using&lt;/LI-CODE&gt;&lt;P&gt;Can anyone give me some advice on how to do this?&lt;BR /&gt;Thanks a lot, bye.&lt;/P&gt;</description>
      <pubDate>Sat, 22 Apr 2023 15:02:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-copy-lines-and-arcs-and-transform-them-into-a-closed/m-p/11914871#M9072</guid>
      <dc:creator>mecoman6GF27</dc:creator>
      <dc:date>2023-04-22T15:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy lines and arcs and transform them into a closed polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-copy-lines-and-arcs-and-transform-them-into-a-closed/m-p/11914905#M9073</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;You could use the Entity.JoinEntities method but to get it work, you have to convert the line or arc the method applies to into a Polyline.&lt;/P&gt;
&lt;P&gt;Another way should be using the PolylineSegmentCollection.Join method from the &lt;A href="https://github.com/gileCAD/GeometryExtensions/blob/master/GeometryExtensions/PolylineSegmentCollection.cs" target="_blank" rel="noopener"&gt;PolylineSegmentCollection class&lt;/A&gt; after having converted the line and Arcs into &lt;A href="https://github.com/gileCAD/GeometryExtensions/blob/master/GeometryExtensions/PolylineSegment.cs" target="_blank" rel="noopener"&gt;PolylineSegment&lt;/A&gt; instances. These classes are part of the &lt;A href="https://github.com/gileCAD/GeometryExtensions" target="_blank" rel="noopener"&gt;GeometryExtensions library&lt;/A&gt; (this library is written in C# but it can be referenced as is in a VB project).&lt;/P&gt;</description>
      <pubDate>Sat, 22 Apr 2023 15:54:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-copy-lines-and-arcs-and-transform-them-into-a-closed/m-p/11914905#M9073</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-04-22T15:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy lines and arcs and transform them into a closed polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-copy-lines-and-arcs-and-transform-them-into-a-closed/m-p/11915912#M9074</link>
      <description>&lt;P&gt;Hi, thanks for the reply.&lt;/P&gt;&lt;P&gt;I tried using the Entity.JoinEntities method but it partially works.&lt;/P&gt;&lt;P&gt;I tried this:&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;        Dim doc As Document = Application.DocumentManager.MdiActiveDocument
        Dim db As Database = doc.Database

        Using tr As Transaction = db.TransactionManager.StartTransaction()
            Dim bt As BlockTable = tr.GetObject(db.BlockTableId, OpenMode.ForRead)
            Dim btr As BlockTableRecord = tr.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite)

            Dim Poly As Polyline = New Polyline
            btr.AppendEntity(Poly)
            tr.AddNewlyCreatedDBObject(Poly, True)

            Dim line1 As Line = New Line(New Point3d(0, 0, 0), New Point3d(100, 0, 0))
            btr.AppendEntity(line1)
            tr.AddNewlyCreatedDBObject(line1, True)

            Dim line2 As Line = New Line(New Point3d(0, 0, 0), New Point3d(0, 100, 0))
            btr.AppendEntity(line2)
            tr.AddNewlyCreatedDBObject(line2, True)

            Dim arc1 As Arc = New Arc(New Point3d(0, 0, 0), 100, 0, Math.PI / 2)
            btr.AppendEntity(arc1)
            tr.AddNewlyCreatedDBObject(arc1, True)

            Poly.JoinEntities(New Entity() {line1, line2, arc1})

            tr.Commit()
        End Using&lt;/LI-CODE&gt;&lt;P&gt;This code creates a polyline composed of line2 and arc1 but without line1.&lt;/P&gt;&lt;P&gt;If I change the line of code "Poly.JoinEntities(New Entity() {line1, line2, arc1})" with "Poly.JoinEntities(New Entity() {line1, arc1, line2})" the polyline is composed of line1 and arc1 but without line2.&lt;/P&gt;&lt;P&gt;Where do you think I'm wrong?&lt;/P&gt;&lt;P&gt;Thanks a lot, bye.&lt;/P&gt;</description>
      <pubDate>Sun, 23 Apr 2023 13:17:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-copy-lines-and-arcs-and-transform-them-into-a-closed/m-p/11915912#M9074</guid>
      <dc:creator>mecoman6GF27</dc:creator>
      <dc:date>2023-04-23T13:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy lines and arcs and transform them into a closed polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-copy-lines-and-arcs-and-transform-them-into-a-closed/m-p/11915984#M9075</link>
      <description>&lt;P&gt;As I said upper, you have to convert one of the lines or arcs into a polyline and call the JoinEntities on this polyline.&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;        [CommandMethod("TEST")]
        public static void Test()
        {
            var db = HostApplicationServices.WorkingDatabase;
            using (var tr = db.TransactionManager.StartTransaction())
            using (var line = new Line(Point3d.Origin, new Point3d(100.0, 0.0, 0.0)))
            using (var arc = new Arc(Point3d.Origin, 100.0, 0.0, Math.PI * 0.5))
            using (var pline = new Polyline())
            {
                pline.AddVertexAt(0, Point2d.Origin, 0.0, 0.0, 0.0);
                pline.AddVertexAt(1, new Point2d(0.0, 100.0), 0.0, 0.0, 0.0);
                pline.JoinEntities(new Entity[2] { line, arc });
                var modelSpace = (BlockTableRecord)tr.GetObject(
                    SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite);
                modelSpace.AppendEntity(pline);
                tr.AddNewlyCreatedDBObject(pline, true);
                tr.Commit();
            }
        }&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 23 Apr 2023 14:35:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-copy-lines-and-arcs-and-transform-them-into-a-closed/m-p/11915984#M9075</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-04-23T14:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy lines and arcs and transform them into a closed polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-copy-lines-and-arcs-and-transform-them-into-a-closed/m-p/11918171#M9076</link>
      <description>&lt;P&gt;Hi Gil, thank you very much.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 15:51:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-copy-lines-and-arcs-and-transform-them-into-a-closed/m-p/11918171#M9076</guid>
      <dc:creator>mecoman6GF27</dc:creator>
      <dc:date>2023-04-24T15:51:20Z</dc:date>
    </item>
  </channel>
</rss>

