<?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: Outline closed Polylines in Autocad.net in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/outline-closed-polylines-in-autocad-net/m-p/11315841#M15426</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4560594"&gt;@anhtuan891997&lt;/a&gt;&amp;nbsp; a écrit&amp;nbsp;:&lt;BR /&gt;
&lt;P&gt;Hello! Can you show the entire code to create an outline like your image?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Here's an example:&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;

using System;
using System.Collections.Generic;
using System.Linq;

using AcAp = Autodesk.AutoCAD.ApplicationServices.Core.Application;

namespace UnionPlinesSample
{
    public class Commands
    {
        [CommandMethod("TEST")]
        public static void Test()
        {
            var doc = AcAp.DocumentManager.MdiActiveDocument;
            var db = doc.Database;
            var ed = doc.Editor;

            var filter = new SelectionFilter(new[] {
                new TypedValue(0, "LWPOLYLINE"),
                new TypedValue(-4, "&amp;amp;"),
                new TypedValue(70, 1) });
            var selection = ed.GetSelection(filter);
            if (selection.Status == PromptStatus.OK)
            {
                var options = new PromptKeywordOptions("\nErase source polylines [Yes/No]", "Yes No");
                var kWord = ed.GetKeywords(options);
                if (kWord.Status == PromptStatus.OK)
                {
                    using (var tr = db.TransactionManager.StartOpenCloseTransaction())
                    {
                        var source = selection.Value
                            .GetObjectIds()
                            .Select(id =&amp;gt; (Polyline)tr.GetObject(id, OpenMode.ForRead));
                        var curSpace = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
                        foreach (var pline in Union(source))
                        {
                            curSpace.AppendEntity(pline);
                            tr.AddNewlyCreatedDBObject(pline, true);
                        }
                        if (kWord.StringResult == "Yes")
                        {
                            foreach (var pline in source)
                            {
                                pline.UpgradeOpen();
                                pline.Erase();
                            }
                        }
                        tr.Commit();
                    }
                }
            }
        }

        struct Segment
        {
            public Point2d StartPt { get; set; }
            public Point2d EndPt { get; set; }
            public double Bulge { get; set; }
        }

        public static IEnumerable&amp;lt;Polyline&amp;gt; Union(IEnumerable&amp;lt;Polyline&amp;gt; plines)
        {
            foreach (var group in plines.GroupBy(pl =&amp;gt; new { pl.Elevation, pl.Normal }))
            {
                if (group.Count() == 1)
                {
                    yield return group.First();
                }
                else
                {
                    var plane = new Plane(Point3d.Origin, group.Key.Normal);
                    var segs = new List&amp;lt;Segment&amp;gt;();
                    using (var dbObjects = new DBObjectCollection())
                    {
                        foreach (var pline in group)
                        {
                            pline.Explode(dbObjects);
                        }
                        using (DBObjectCollection regions = Region.CreateFromCurves(dbObjects))
                        {
                            var region = (Region)regions[0];
                            for (int i = 1; i &amp;lt; regions.Count; i++)
                            {
                                region.BooleanOperation(BooleanOperationType.BoolUnite, (Region)regions[i]);
                                regions[i].Dispose();
                            }
                            foreach (DBObject o in dbObjects) o.Dispose();
                            dbObjects.Clear();
                            region.Explode(dbObjects);
                            region.Dispose();
                            for (int i = 0; i &amp;lt; dbObjects.Count; i++)
                            {
                                if (dbObjects[i] is Region)
                                {
                                    ((Region)dbObjects[i]).Explode(dbObjects);
                                    continue;
                                }
                                var curve = (Curve)dbObjects[i];
                                Point3d start = curve.StartPoint;
                                Point3d end = curve.EndPoint;
                                double bulge = 0.0;
                                if (curve is Arc)
                                {
                                    Arc arc = (Arc)curve;
                                    double angle = arc.Center.GetVectorTo(start).GetAngleTo(arc.Center.GetVectorTo(end), arc.Normal);
                                    bulge = Math.Tan(angle / 4.0);
                                }
                                segs.Add(new Segment { StartPt = start.Convert2d(plane), EndPt = end.Convert2d(plane), Bulge = bulge });
                            }
                            foreach (DBObject obj in dbObjects) obj.Dispose();
                            while (segs.Count &amp;gt; 0)
                            {
                                using (Polyline pline = new Polyline())
                                {
                                    pline.AddVertexAt(0, segs[0].StartPt, segs[0].Bulge, 0.0, 0.0);
                                    Point2d pt = segs[0].EndPt;
                                    segs.RemoveAt(0);
                                    int vtx = 1;
                                    while (true)
                                    {
                                        int i = segs.FindIndex(delegate (Segment s)
                                        {
                                            return s.StartPt.IsEqualTo(pt) || s.EndPt.IsEqualTo(pt);
                                        });
                                        if (i &amp;lt; 0) break;
                                        Segment seg = segs[i];
                                        if (seg.EndPt.IsEqualTo(pt))
                                            seg = new Segment { StartPt = seg.EndPt, EndPt = seg.StartPt, Bulge = -seg.Bulge };
                                        pline.AddVertexAt(vtx, seg.StartPt, seg.Bulge, 0.0, 0.0);
                                        pt = seg.EndPt;
                                        segs.RemoveAt(i);
                                        vtx++;
                                    }
                                    pline.Closed = true;
                                    pline.Normal = group.Key.Normal;
                                    pline.Elevation = group.Key.Elevation;
                                    yield return pline;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
&lt;/LI-CODE&gt;</description>
    <pubDate>Sat, 23 Jul 2022 15:16:29 GMT</pubDate>
    <dc:creator>_gile</dc:creator>
    <dc:date>2022-07-23T15:16:29Z</dc:date>
    <item>
      <title>Outline closed Polylines in Autocad.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/outline-closed-polylines-in-autocad-net/m-p/10583761#M15422</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;please hel me with a problem.Is there a way to make a outline in C# or VB.net for some closed polyline .Something like in this picture :&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Snap 2021-08-30 at 09.25.45.png" style="width: 569px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/958774iA265DBCD21EA01CB/image-size/large?v=v2&amp;amp;px=999" role="button" title="Snap 2021-08-30 at 09.25.45.png" alt="Snap 2021-08-30 at 09.25.45.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your support and your help.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 06:27:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/outline-closed-polylines-in-autocad-net/m-p/10583761#M15422</guid>
      <dc:creator>imagination_s</dc:creator>
      <dc:date>2021-08-30T06:27:10Z</dc:date>
    </item>
    <item>
      <title>Re: Outline closed Polylines in Autocad.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/outline-closed-polylines-in-autocad-net/m-p/10584331#M15423</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;You can use the following method and struct (which is a generalization of &lt;A href="http://www.theswamp.org/index.php?topic=37976.msg429899#msg429899" target="_blank" rel="noopener"&gt;this one&lt;/A&gt;).&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;struct Segment
{
    public Point2d StartPt { get; set; }
    public Point2d EndPt { get; set; }
    public double Bulge { get; set; }
}

public static IEnumerable&amp;lt;Polyline&amp;gt; Union(IEnumerable&amp;lt;Polyline&amp;gt; plines)
{
    foreach (var group in plines.GroupBy(pl =&amp;gt; new { pl.Elevation, pl.Normal }))
    {
        if (group.Count() == 1)
        {
            yield return group.First();
        }
        else
        {
            var plane = new Plane(Point3d.Origin, group.Key.Normal);
            var segs = new List&amp;lt;Segment&amp;gt;();
            using (var dbObjects = new DBObjectCollection())
            {
                foreach (var pline in group)
                {
                    pline.Explode(dbObjects);
                }
                using (DBObjectCollection regions = Region.CreateFromCurves(dbObjects))
                {
                    var region = (Region)regions[0];
                    for (int i = 1; i &amp;lt; regions.Count; i++)
                    {
                        region.BooleanOperation(BooleanOperationType.BoolUnite, (Region)regions[i]);
                        regions[i].Dispose();
                    }
                    foreach (DBObject o in dbObjects) o.Dispose();
                    dbObjects.Clear();
                    region.Explode(dbObjects);
                    region.Dispose();
                    for (int i = 0; i &amp;lt; dbObjects.Count; i++)
                    {
                        if (dbObjects[i] is Region)
                        {
                            ((Region)dbObjects[i]).Explode(dbObjects);
                            continue;
                        }
                        var curve = (Curve)dbObjects[i];
                        Point3d start = curve.StartPoint;
                        Point3d end = curve.EndPoint;
                        double bulge = 0.0;
                        if (curve is Arc)
                        {
                            Arc arc = (Arc)curve;
                            double angle = arc.Center.GetVectorTo(start).GetAngleTo(arc.Center.GetVectorTo(end), arc.Normal);
                            bulge = Math.Tan(angle / 4.0);
                        }
                        segs.Add(new Segment { StartPt = start.Convert2d(plane), EndPt = end.Convert2d(plane), Bulge = bulge });
                    }
                    foreach (DBObject obj in dbObjects) obj.Dispose();
                    while (segs.Count &amp;gt; 0)
                    {
                        using (Polyline pline = new Polyline())
                        {
                            pline.AddVertexAt(0, segs[0].StartPt, segs[0].Bulge, 0.0, 0.0);
                            Point2d pt = segs[0].EndPt;
                            segs.RemoveAt(0);
                            int vtx = 1;
                            while (true)
                            {
                                int i = segs.FindIndex(delegate (Segment s)
                                {
                                    return s.StartPt.IsEqualTo(pt) || s.EndPt.IsEqualTo(pt);
                                });
                                if (i &amp;lt; 0) break;
                                Segment seg = segs[i];
                                if (seg.EndPt.IsEqualTo(pt))
                                    seg = new Segment { StartPt = seg.EndPt, EndPt = seg.StartPt, Bulge = -seg.Bulge };
                                pline.AddVertexAt(vtx, seg.StartPt, seg.Bulge, 0.0, 0.0);
                                pt = seg.EndPt;
                                segs.RemoveAt(i);
                                vtx++;
                            }
                            pline.Closed = true;
                            pline.Normal = group.Key.Normal;
                            pline.Elevation = group.Key.Elevation;
                            yield return pline;
                        }
                    }
                }
            }
        }
    }
}&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 30 Aug 2021 11:13:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/outline-closed-polylines-in-autocad-net/m-p/10584331#M15423</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2021-08-30T11:13:11Z</dc:date>
    </item>
    <item>
      <title>Re: Outline closed Polylines in Autocad.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/outline-closed-polylines-in-autocad-net/m-p/10586874#M15424</link>
      <description>&lt;P&gt;Thankyou so much Sir for your help.Your code work so greate.Here is a picture of some polylines .After apply the code it creates a single polyline .Have&amp;nbsp; a nice day &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Snap 2021-08-31 at 11.59.57.png" style="width: 342px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/959269i88E340284BA2EA14/image-size/large?v=v2&amp;amp;px=999" role="button" title="Snap 2021-08-31 at 11.59.57.png" alt="Snap 2021-08-31 at 11.59.57.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Aug 2021 09:04:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/outline-closed-polylines-in-autocad-net/m-p/10586874#M15424</guid>
      <dc:creator>imagination_s</dc:creator>
      <dc:date>2021-08-31T09:04:02Z</dc:date>
    </item>
    <item>
      <title>Re: Outline closed Polylines in Autocad.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/outline-closed-polylines-in-autocad-net/m-p/11314616#M15425</link>
      <description>&lt;P&gt;Hello! Can you show the entire code to create an outline like your image?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2022 17:35:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/outline-closed-polylines-in-autocad-net/m-p/11314616#M15425</guid>
      <dc:creator>anhtuan891997</dc:creator>
      <dc:date>2022-07-22T17:35:47Z</dc:date>
    </item>
    <item>
      <title>Re: Outline closed Polylines in Autocad.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/outline-closed-polylines-in-autocad-net/m-p/11315841#M15426</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4560594"&gt;@anhtuan891997&lt;/a&gt;&amp;nbsp; a écrit&amp;nbsp;:&lt;BR /&gt;
&lt;P&gt;Hello! Can you show the entire code to create an outline like your image?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Here's an example:&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;

using System;
using System.Collections.Generic;
using System.Linq;

using AcAp = Autodesk.AutoCAD.ApplicationServices.Core.Application;

namespace UnionPlinesSample
{
    public class Commands
    {
        [CommandMethod("TEST")]
        public static void Test()
        {
            var doc = AcAp.DocumentManager.MdiActiveDocument;
            var db = doc.Database;
            var ed = doc.Editor;

            var filter = new SelectionFilter(new[] {
                new TypedValue(0, "LWPOLYLINE"),
                new TypedValue(-4, "&amp;amp;"),
                new TypedValue(70, 1) });
            var selection = ed.GetSelection(filter);
            if (selection.Status == PromptStatus.OK)
            {
                var options = new PromptKeywordOptions("\nErase source polylines [Yes/No]", "Yes No");
                var kWord = ed.GetKeywords(options);
                if (kWord.Status == PromptStatus.OK)
                {
                    using (var tr = db.TransactionManager.StartOpenCloseTransaction())
                    {
                        var source = selection.Value
                            .GetObjectIds()
                            .Select(id =&amp;gt; (Polyline)tr.GetObject(id, OpenMode.ForRead));
                        var curSpace = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
                        foreach (var pline in Union(source))
                        {
                            curSpace.AppendEntity(pline);
                            tr.AddNewlyCreatedDBObject(pline, true);
                        }
                        if (kWord.StringResult == "Yes")
                        {
                            foreach (var pline in source)
                            {
                                pline.UpgradeOpen();
                                pline.Erase();
                            }
                        }
                        tr.Commit();
                    }
                }
            }
        }

        struct Segment
        {
            public Point2d StartPt { get; set; }
            public Point2d EndPt { get; set; }
            public double Bulge { get; set; }
        }

        public static IEnumerable&amp;lt;Polyline&amp;gt; Union(IEnumerable&amp;lt;Polyline&amp;gt; plines)
        {
            foreach (var group in plines.GroupBy(pl =&amp;gt; new { pl.Elevation, pl.Normal }))
            {
                if (group.Count() == 1)
                {
                    yield return group.First();
                }
                else
                {
                    var plane = new Plane(Point3d.Origin, group.Key.Normal);
                    var segs = new List&amp;lt;Segment&amp;gt;();
                    using (var dbObjects = new DBObjectCollection())
                    {
                        foreach (var pline in group)
                        {
                            pline.Explode(dbObjects);
                        }
                        using (DBObjectCollection regions = Region.CreateFromCurves(dbObjects))
                        {
                            var region = (Region)regions[0];
                            for (int i = 1; i &amp;lt; regions.Count; i++)
                            {
                                region.BooleanOperation(BooleanOperationType.BoolUnite, (Region)regions[i]);
                                regions[i].Dispose();
                            }
                            foreach (DBObject o in dbObjects) o.Dispose();
                            dbObjects.Clear();
                            region.Explode(dbObjects);
                            region.Dispose();
                            for (int i = 0; i &amp;lt; dbObjects.Count; i++)
                            {
                                if (dbObjects[i] is Region)
                                {
                                    ((Region)dbObjects[i]).Explode(dbObjects);
                                    continue;
                                }
                                var curve = (Curve)dbObjects[i];
                                Point3d start = curve.StartPoint;
                                Point3d end = curve.EndPoint;
                                double bulge = 0.0;
                                if (curve is Arc)
                                {
                                    Arc arc = (Arc)curve;
                                    double angle = arc.Center.GetVectorTo(start).GetAngleTo(arc.Center.GetVectorTo(end), arc.Normal);
                                    bulge = Math.Tan(angle / 4.0);
                                }
                                segs.Add(new Segment { StartPt = start.Convert2d(plane), EndPt = end.Convert2d(plane), Bulge = bulge });
                            }
                            foreach (DBObject obj in dbObjects) obj.Dispose();
                            while (segs.Count &amp;gt; 0)
                            {
                                using (Polyline pline = new Polyline())
                                {
                                    pline.AddVertexAt(0, segs[0].StartPt, segs[0].Bulge, 0.0, 0.0);
                                    Point2d pt = segs[0].EndPt;
                                    segs.RemoveAt(0);
                                    int vtx = 1;
                                    while (true)
                                    {
                                        int i = segs.FindIndex(delegate (Segment s)
                                        {
                                            return s.StartPt.IsEqualTo(pt) || s.EndPt.IsEqualTo(pt);
                                        });
                                        if (i &amp;lt; 0) break;
                                        Segment seg = segs[i];
                                        if (seg.EndPt.IsEqualTo(pt))
                                            seg = new Segment { StartPt = seg.EndPt, EndPt = seg.StartPt, Bulge = -seg.Bulge };
                                        pline.AddVertexAt(vtx, seg.StartPt, seg.Bulge, 0.0, 0.0);
                                        pt = seg.EndPt;
                                        segs.RemoveAt(i);
                                        vtx++;
                                    }
                                    pline.Closed = true;
                                    pline.Normal = group.Key.Normal;
                                    pline.Elevation = group.Key.Elevation;
                                    yield return pline;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 23 Jul 2022 15:16:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/outline-closed-polylines-in-autocad-net/m-p/11315841#M15426</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2022-07-23T15:16:29Z</dc:date>
    </item>
    <item>
      <title>Re: Outline closed Polylines in Autocad.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/outline-closed-polylines-in-autocad-net/m-p/11325634#M15427</link>
      <description>&lt;P&gt;Hello _gile here my function of making outline of a polyline&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;public void make_buffer(Polyline3d poly, double buffer, string detination_layer)&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;try&lt;BR /&gt;{&lt;BR /&gt;Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;&lt;BR /&gt;Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; //citire dwg curent&lt;BR /&gt;Database acCurDB = acDoc.Database;&lt;BR /&gt;using (DocumentLock acDocloc = acDoc.LockDocument())&lt;BR /&gt;{&lt;BR /&gt;using (var tr = acCurDB.TransactionManager.StartTransaction())&lt;BR /&gt;{&lt;BR /&gt;BlockTable acBlkTbl;&lt;BR /&gt;acBlkTbl = (BlockTable)tr.GetObject(acCurDB.BlockTableId, OpenMode.ForRead);&lt;BR /&gt;DwgReader reader = new DwgReader();&lt;BR /&gt;DwgWriter writer = new DwgWriter();&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;IGeometry geometry = reader.ReadGeometry(poly);&lt;BR /&gt;if(!geometry.IsEmpty || geometry!=null)&lt;BR /&gt;{&lt;BR /&gt;//Tangent_Lines_distance(1, p3d,5);&lt;BR /&gt;// IGeometry buf = geometry.Buffer(dblOptionsResult.Value);&lt;/P&gt;&lt;P&gt;IGeometry buf = geometry.Buffer(buffer);//buffer&lt;/P&gt;&lt;P&gt;MPolygon outEnt = null;&lt;/P&gt;&lt;P&gt;if (!buf.IsEmpty)&lt;BR /&gt;{&lt;BR /&gt;if (buf.GeometryType == "Polygon")&lt;BR /&gt;{&lt;BR /&gt;outEnt = writer.WriteMPolygon(buf as Polygon);&lt;BR /&gt;}&lt;BR /&gt;else if (buf.GeometryType == "MultiPolygon")&lt;BR /&gt;{&lt;BR /&gt;outEnt = writer.WriteMPolygon(buf as MultiPolygon);&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;if (outEnt != null)&lt;BR /&gt;{&lt;BR /&gt;BlockTableRecord btr = (BlockTableRecord)tr.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite);&lt;BR /&gt;outEnt.ColorIndex = 1;&lt;BR /&gt;outEnt.Layer = detination_layer;&lt;/P&gt;&lt;P&gt;DBObjectCollection acDBObjColl = new DBObjectCollection();&lt;/P&gt;&lt;P&gt;//for(int i=0;i&amp;lt; outEnt.NumMPolygonLoops;i++)&lt;BR /&gt;// {&lt;BR /&gt;// MPolygonLoop mloop = outEnt.GetMPolygonLoopAt(i);&lt;BR /&gt;// outEnt.RemoveMPolygonLoopAt&lt;BR /&gt;// IntegerCollection col= outEnt.IsPointInsideMPolygon(new Point3d(), 0);&lt;BR /&gt;// }&lt;/P&gt;&lt;P&gt;btr.AppendEntity(outEnt);&lt;BR /&gt;tr.AddNewlyCreatedDBObject(outEnt, true);&lt;/P&gt;&lt;P&gt;outEnt.Explode(acDBObjColl);&lt;BR /&gt;outEnt.Erase();&lt;BR /&gt;foreach (Entity acEnt in acDBObjColl)&lt;BR /&gt;{&lt;BR /&gt;// ' Add the new object to the block table record and the transaction&lt;BR /&gt;acEnt.Layer = detination_layer;&lt;BR /&gt;acEnt.ColorIndex = 1;&lt;BR /&gt;btr.AppendEntity(acEnt);&lt;BR /&gt;tr.AddNewlyCreatedDBObject(acEnt, true);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;tr.Commit();&lt;BR /&gt;tr.Dispose();&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;catch (System.Exception ex)&lt;BR /&gt;{&lt;BR /&gt;// MessageBox.Show(ex.ToString());&lt;BR /&gt;// poly.Highlight();&lt;BR /&gt;return;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//here the function for manage the outlines&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;public void OutPlines()&lt;BR /&gt;{&lt;BR /&gt;Document _doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; //citire dwg curent&lt;BR /&gt;Database db = _doc.Database;&lt;/P&gt;&lt;P&gt;using (DocumentLock acDocloc = _doc.LockDocument())&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;// Polyline result_buffer = MinimumEnclosingBoundary(false);&lt;BR /&gt;//Point3d center = GetCentroid(result_buffer);&lt;BR /&gt;//string strPt = center.X.ToString() + "," + center.Y.ToString();&lt;/P&gt;&lt;P&gt;Editor ed = _doc.Editor;&lt;BR /&gt;var acTypVal = new TypedValue[2];&lt;BR /&gt;acTypVal.SetValue(new TypedValue((int)DxfCode.Start, "LWPOLYLINE"), 0);&lt;BR /&gt;acTypVal.SetValue(new TypedValue((int)DxfCode.LayerName, "Buffer"), 1);&lt;BR /&gt;SelectionFilter filter = new SelectionFilter(acTypVal);&lt;BR /&gt;PromptSelectionResult psr = ed.SelectAll(filter);&lt;BR /&gt;if (psr.Status != PromptStatus.OK)&lt;BR /&gt;return;&lt;BR /&gt;//else&lt;BR /&gt;// {&lt;BR /&gt;// MessageBox.Show("nothing found on layer Buffer");&lt;BR /&gt;// }&lt;/P&gt;&lt;P&gt;bool erase = true;&lt;BR /&gt;try&lt;BR /&gt;{&lt;BR /&gt;ObjectIdCollection ids = new ObjectIdCollection(psr.Value.GetObjectIds());&lt;BR /&gt;ListEcho.Items.Add("Outlines is creating .Please wait.....");&lt;BR /&gt;int n = MergePlines(ids, erase);&lt;BR /&gt;ListEcho.Items.Add("here where made" + n + " polylines(i) ");&lt;BR /&gt;// ed.WriteMessage("\n{0} there where made (i){1} polylines", n, n &amp;gt; 1 ? "s" : "");&lt;BR /&gt;MessageBox.Show("done");&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;catch (Autodesk.AutoCAD.Runtime.Exception ex)&lt;BR /&gt;{&lt;BR /&gt;ed.WriteMessage("\n{0}: {1}\n{2}", ex.Message, ex.StackTrace);&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//here is the buton function to execut all that&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Polyline3d source = null;&lt;BR /&gt;try&lt;BR /&gt;{&lt;BR /&gt;this.Hide();&lt;BR /&gt;var doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt;var db = doc.Database;&lt;BR /&gt;var ed = doc.Editor;&lt;BR /&gt;double distance = Convert.ToDouble(textBox_distance.Text);&lt;BR /&gt;using (DocumentLock acDocloc = doc.LockDocument())&lt;BR /&gt;{&lt;BR /&gt;using (var tr = db.TransactionManager.StartTransaction())&lt;BR /&gt;{&lt;BR /&gt;var acTypValAx = new TypedValue[2];&lt;BR /&gt;acTypValAx.SetValue(new TypedValue((int)DxfCode.Start, "Polyline"), 0);&lt;BR /&gt;acTypValAx.SetValue(new TypedValue((int)DxfCode.LayerName, ComboAx.SelectedItem.ToString()), 1);&lt;/P&gt;&lt;P&gt;var acSelFtrCarosabil = new SelectionFilter(acTypValAx);&lt;BR /&gt;PromptSelectionResult resultAx = ed.GetSelection(acSelFtrCarosabil);&lt;BR /&gt;&lt;BR /&gt;if (resultAx.Status == PromptStatus.OK)&lt;BR /&gt;{&lt;BR /&gt;SelectionSet acSSet = resultAx.Value;&lt;BR /&gt;ObjectId[] idarray = acSSet.GetObjectIds();&lt;/P&gt;&lt;P&gt;foreach (ObjectId objid in idarray)&lt;BR /&gt;{&lt;BR /&gt;source = (Polyline3d)tr.GetObject(objid, OpenMode.ForRead);&lt;BR /&gt;//Extents3d ext = pl3d.GeometricExtents;&lt;BR /&gt;//Zoom_me(ed, ext.MinPoint, ext.MaxPoint);&lt;BR /&gt;AcadApplication app = (AcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;&lt;BR /&gt;app.ZoomExtents();&lt;BR /&gt;Tangent_Lines_distance(1, source, distance);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;this.Show();&lt;BR /&gt;//ia toate polylininile din bufferul de distana si punele in lista&lt;BR /&gt;List&amp;lt;Polyline3d&amp;gt; get_poly3d = get_polylines();&lt;BR /&gt;// ListEcho.Items.Add(get_poly3d.Count.ToString());&lt;BR /&gt;//calculeaza distanta minima de la fiecare polylinie la ax&lt;BR /&gt;&lt;BR /&gt;foreach (Polyline3d dest in get_poly3d)&lt;BR /&gt;{&lt;BR /&gt;// GetMinimumDistance_boundinBox(source, dest);&lt;BR /&gt;// Polyline bounding= MinimumEnclosingBoundary(dest);&lt;BR /&gt;if (dest.Layer.ToUpper() == "mylayer")&lt;BR /&gt;{&lt;BR /&gt;Curve pl1 = pl1 = (Curve)tr.GetObject(source.ObjectId, OpenMode.ForRead);&lt;BR /&gt;Curve pl2 = (Curve)tr.GetObject(dest.ObjectId, OpenMode.ForRead);&lt;BR /&gt;double distance_to_carosabil = pl1.GetGeCurve().GetDistanceTo(pl2.GetGeCurve());&lt;BR /&gt;// ed.WriteMessage(distance_to_carosabil+ "\n");&lt;BR /&gt;make_buffer(dest, Math.Round(distance_to_carosabil *2), "Buffer");&lt;BR /&gt;break;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;foreach (Polyline3d dest in get_poly3d)&lt;BR /&gt;{&lt;BR /&gt;// GetMinimumDistance_boundinBox(source, dest);&lt;BR /&gt;// Polyline bounding= MinimumEnclosingBoundary(dest);&lt;BR /&gt;Curve pl1 = pl1 = (Curve)tr.GetObject(source.ObjectId, OpenMode.ForRead);&lt;BR /&gt;Curve pl2 = (Curve)tr.GetObject(dest.ObjectId, OpenMode.ForRead);&lt;BR /&gt;//Curve pl2 = (Curve)tr.GetObject(bounding.ObjectId, OpenMode.ForRead);&lt;BR /&gt;Extents3d ext_source = pl1.GeometricExtents;&lt;BR /&gt;Extents3d ext_dest = pl2.GeometricExtents;&lt;BR /&gt;//double d = ext_source.MaxPoint.DistanceTo(ext_dest.MaxPoint);&lt;BR /&gt;//ListEcho.Items.Add(d.ToString());&lt;BR /&gt;// ed.WriteMessage(difference.ToString() + "\r");&lt;BR /&gt;//get distance to boundinbox&lt;BR /&gt;double distance_buf = pl1.GetGeCurve().GetDistanceTo(pl2.GetGeCurve());&lt;BR /&gt;if (dest.Layer.ToUpper() == "mylayer")&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;// ListEcho.Items.Add(distance_buf.ToString());&lt;BR /&gt;// ed.WriteMessage(distance_buf + "\n");&lt;BR /&gt;//result_buffer.UpgradeOpen();&lt;BR /&gt;//result_buffer.Erase();&lt;BR /&gt;//if (distance_buf &amp;lt; 1)&lt;BR /&gt;//{&lt;BR /&gt;// dest.Highlight();&lt;BR /&gt;//}&lt;BR /&gt;if (distance_buf &amp;gt;1)&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;// ed.WriteMessage(distance_buf + "\n");&lt;BR /&gt;make_buffer(dest, Math.Round(distance_buf+2.5), "Buffer");&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;ListEcho.Items.Add("Am procesat " + get_poly3d.Count.ToString() + " polilinii");&lt;BR /&gt;&lt;BR /&gt;tr.Commit();&lt;BR /&gt;tr.Dispose();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;&lt;BR /&gt;// MessageBox.Show("Done");&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;catch(System.Exception ex)&lt;BR /&gt;{&lt;BR /&gt;MessageBox.Show(ex.ToString());&lt;BR /&gt;}&lt;BR /&gt;OutPlines();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the program make reference to exlude a specific layer&amp;nbsp; so that it amke the outline of an area&amp;nbsp;&lt;/P&gt;&lt;P&gt;hpe this helps&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2022 11:21:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/outline-closed-polylines-in-autocad-net/m-p/11325634#M15427</guid>
      <dc:creator>imagination_s</dc:creator>
      <dc:date>2022-07-28T11:21:24Z</dc:date>
    </item>
    <item>
      <title>Re: Outline closed Polylines in Autocad.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/outline-closed-polylines-in-autocad-net/m-p/11325639#M15428</link>
      <description>&lt;P&gt;Hello&amp;nbsp; here my function of making outline of a polyline&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;public void make_buffer(Polyline3d poly, double buffer, string detination_layer)&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;try&lt;BR /&gt;{&lt;BR /&gt;Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;&lt;BR /&gt;Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; //citire dwg curent&lt;BR /&gt;Database acCurDB = acDoc.Database;&lt;BR /&gt;using (DocumentLock acDocloc = acDoc.LockDocument())&lt;BR /&gt;{&lt;BR /&gt;using (var tr = acCurDB.TransactionManager.StartTransaction())&lt;BR /&gt;{&lt;BR /&gt;BlockTable acBlkTbl;&lt;BR /&gt;acBlkTbl = (BlockTable)tr.GetObject(acCurDB.BlockTableId, OpenMode.ForRead);&lt;BR /&gt;DwgReader reader = new DwgReader();&lt;BR /&gt;DwgWriter writer = new DwgWriter();&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;IGeometry geometry = reader.ReadGeometry(poly);&lt;BR /&gt;if(!geometry.IsEmpty || geometry!=null)&lt;BR /&gt;{&lt;BR /&gt;//Tangent_Lines_distance(1, p3d,5);&lt;BR /&gt;// IGeometry buf = geometry.Buffer(dblOptionsResult.Value);&lt;/P&gt;&lt;P&gt;IGeometry buf = geometry.Buffer(buffer);//buffer&lt;/P&gt;&lt;P&gt;MPolygon outEnt = null;&lt;/P&gt;&lt;P&gt;if (!buf.IsEmpty)&lt;BR /&gt;{&lt;BR /&gt;if (buf.GeometryType == "Polygon")&lt;BR /&gt;{&lt;BR /&gt;outEnt = writer.WriteMPolygon(buf as Polygon);&lt;BR /&gt;}&lt;BR /&gt;else if (buf.GeometryType == "MultiPolygon")&lt;BR /&gt;{&lt;BR /&gt;outEnt = writer.WriteMPolygon(buf as MultiPolygon);&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;if (outEnt != null)&lt;BR /&gt;{&lt;BR /&gt;BlockTableRecord btr = (BlockTableRecord)tr.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite);&lt;BR /&gt;outEnt.ColorIndex = 1;&lt;BR /&gt;outEnt.Layer = detination_layer;&lt;/P&gt;&lt;P&gt;DBObjectCollection acDBObjColl = new DBObjectCollection();&lt;/P&gt;&lt;P&gt;//for(int i=0;i&amp;lt; outEnt.NumMPolygonLoops;i++)&lt;BR /&gt;// {&lt;BR /&gt;// MPolygonLoop mloop = outEnt.GetMPolygonLoopAt(i);&lt;BR /&gt;// outEnt.RemoveMPolygonLoopAt&lt;BR /&gt;// IntegerCollection col= outEnt.IsPointInsideMPolygon(new Point3d(), 0);&lt;BR /&gt;// }&lt;/P&gt;&lt;P&gt;btr.AppendEntity(outEnt);&lt;BR /&gt;tr.AddNewlyCreatedDBObject(outEnt, true);&lt;/P&gt;&lt;P&gt;outEnt.Explode(acDBObjColl);&lt;BR /&gt;outEnt.Erase();&lt;BR /&gt;foreach (Entity acEnt in acDBObjColl)&lt;BR /&gt;{&lt;BR /&gt;// ' Add the new object to the block table record and the transaction&lt;BR /&gt;acEnt.Layer = detination_layer;&lt;BR /&gt;acEnt.ColorIndex = 1;&lt;BR /&gt;btr.AppendEntity(acEnt);&lt;BR /&gt;tr.AddNewlyCreatedDBObject(acEnt, true);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;tr.Commit();&lt;BR /&gt;tr.Dispose();&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;catch (System.Exception ex)&lt;BR /&gt;{&lt;BR /&gt;// MessageBox.Show(ex.ToString());&lt;BR /&gt;// poly.Highlight();&lt;BR /&gt;return;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//here the function for manage the outlines&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;public void OutPlines()&lt;BR /&gt;{&lt;BR /&gt;Document _doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; //citire dwg curent&lt;BR /&gt;Database db = _doc.Database;&lt;/P&gt;&lt;P&gt;using (DocumentLock acDocloc = _doc.LockDocument())&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;// Polyline result_buffer = MinimumEnclosingBoundary(false);&lt;BR /&gt;//Point3d center = GetCentroid(result_buffer);&lt;BR /&gt;//string strPt = center.X.ToString() + "," + center.Y.ToString();&lt;/P&gt;&lt;P&gt;Editor ed = _doc.Editor;&lt;BR /&gt;var acTypVal = new TypedValue[2];&lt;BR /&gt;acTypVal.SetValue(new TypedValue((int)DxfCode.Start, "LWPOLYLINE"), 0);&lt;BR /&gt;acTypVal.SetValue(new TypedValue((int)DxfCode.LayerName, "Buffer"), 1);&lt;BR /&gt;SelectionFilter filter = new SelectionFilter(acTypVal);&lt;BR /&gt;PromptSelectionResult psr = ed.SelectAll(filter);&lt;BR /&gt;if (psr.Status != PromptStatus.OK)&lt;BR /&gt;return;&lt;BR /&gt;//else&lt;BR /&gt;// {&lt;BR /&gt;// MessageBox.Show("nothing found on layer Buffer");&lt;BR /&gt;// }&lt;/P&gt;&lt;P&gt;bool erase = true;&lt;BR /&gt;try&lt;BR /&gt;{&lt;BR /&gt;ObjectIdCollection ids = new ObjectIdCollection(psr.Value.GetObjectIds());&lt;BR /&gt;ListEcho.Items.Add("Outlines is creating .Please wait.....");&lt;BR /&gt;int n = MergePlines(ids, erase);&lt;BR /&gt;ListEcho.Items.Add("here where made" + n + " polylines(i) ");&lt;BR /&gt;// ed.WriteMessage("\n{0} there where made (i){1} polylines", n, n &amp;gt; 1 ? "s" : "");&lt;BR /&gt;MessageBox.Show("done");&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;catch (Autodesk.AutoCAD.Runtime.Exception ex)&lt;BR /&gt;{&lt;BR /&gt;ed.WriteMessage("\n{0}: {1}\n{2}", ex.Message, ex.StackTrace);&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//here is the buton function to execut all that&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Polyline3d source = null;&lt;BR /&gt;try&lt;BR /&gt;{&lt;BR /&gt;this.Hide();&lt;BR /&gt;var doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt;var db = doc.Database;&lt;BR /&gt;var ed = doc.Editor;&lt;BR /&gt;double distance = Convert.ToDouble(textBox_distance.Text);&lt;BR /&gt;using (DocumentLock acDocloc = doc.LockDocument())&lt;BR /&gt;{&lt;BR /&gt;using (var tr = db.TransactionManager.StartTransaction())&lt;BR /&gt;{&lt;BR /&gt;var acTypValAx = new TypedValue[2];&lt;BR /&gt;acTypValAx.SetValue(new TypedValue((int)DxfCode.Start, "Polyline"), 0);&lt;BR /&gt;acTypValAx.SetValue(new TypedValue((int)DxfCode.LayerName, ComboAx.SelectedItem.ToString()), 1);&lt;/P&gt;&lt;P&gt;var acSelFtrCarosabil = new SelectionFilter(acTypValAx);&lt;BR /&gt;PromptSelectionResult resultAx = ed.GetSelection(acSelFtrCarosabil);&lt;BR /&gt;&lt;BR /&gt;if (resultAx.Status == PromptStatus.OK)&lt;BR /&gt;{&lt;BR /&gt;SelectionSet acSSet = resultAx.Value;&lt;BR /&gt;ObjectId[] idarray = acSSet.GetObjectIds();&lt;/P&gt;&lt;P&gt;foreach (ObjectId objid in idarray)&lt;BR /&gt;{&lt;BR /&gt;source = (Polyline3d)tr.GetObject(objid, OpenMode.ForRead);&lt;BR /&gt;//Extents3d ext = pl3d.GeometricExtents;&lt;BR /&gt;//Zoom_me(ed, ext.MinPoint, ext.MaxPoint);&lt;BR /&gt;AcadApplication app = (AcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;&lt;BR /&gt;app.ZoomExtents();&lt;BR /&gt;Tangent_Lines_distance(1, source, distance);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;this.Show();&lt;BR /&gt;//ia toate polylininile din bufferul de distana si punele in lista&lt;BR /&gt;List&amp;lt;Polyline3d&amp;gt; get_poly3d = get_polylines();&lt;BR /&gt;// ListEcho.Items.Add(get_poly3d.Count.ToString());&lt;BR /&gt;//calculeaza distanta minima de la fiecare polylinie la ax&lt;BR /&gt;&lt;BR /&gt;foreach (Polyline3d dest in get_poly3d)&lt;BR /&gt;{&lt;BR /&gt;// GetMinimumDistance_boundinBox(source, dest);&lt;BR /&gt;// Polyline bounding= MinimumEnclosingBoundary(dest);&lt;BR /&gt;if (dest.Layer.ToUpper() == "mylayer")&lt;BR /&gt;{&lt;BR /&gt;Curve pl1 = pl1 = (Curve)tr.GetObject(source.ObjectId, OpenMode.ForRead);&lt;BR /&gt;Curve pl2 = (Curve)tr.GetObject(dest.ObjectId, OpenMode.ForRead);&lt;BR /&gt;double distance_to_carosabil = pl1.GetGeCurve().GetDistanceTo(pl2.GetGeCurve());&lt;BR /&gt;// ed.WriteMessage(distance_to_carosabil+ "\n");&lt;BR /&gt;make_buffer(dest, Math.Round(distance_to_carosabil *2), "Buffer");&lt;BR /&gt;break;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;foreach (Polyline3d dest in get_poly3d)&lt;BR /&gt;{&lt;BR /&gt;// GetMinimumDistance_boundinBox(source, dest);&lt;BR /&gt;// Polyline bounding= MinimumEnclosingBoundary(dest);&lt;BR /&gt;Curve pl1 = pl1 = (Curve)tr.GetObject(source.ObjectId, OpenMode.ForRead);&lt;BR /&gt;Curve pl2 = (Curve)tr.GetObject(dest.ObjectId, OpenMode.ForRead);&lt;BR /&gt;//Curve pl2 = (Curve)tr.GetObject(bounding.ObjectId, OpenMode.ForRead);&lt;BR /&gt;Extents3d ext_source = pl1.GeometricExtents;&lt;BR /&gt;Extents3d ext_dest = pl2.GeometricExtents;&lt;BR /&gt;//double d = ext_source.MaxPoint.DistanceTo(ext_dest.MaxPoint);&lt;BR /&gt;//ListEcho.Items.Add(d.ToString());&lt;BR /&gt;// ed.WriteMessage(difference.ToString() + "\r");&lt;BR /&gt;//get distance to boundinbox&lt;BR /&gt;double distance_buf = pl1.GetGeCurve().GetDistanceTo(pl2.GetGeCurve());&lt;BR /&gt;if (dest.Layer.ToUpper() == "mylayer")&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;// ListEcho.Items.Add(distance_buf.ToString());&lt;BR /&gt;// ed.WriteMessage(distance_buf + "\n");&lt;BR /&gt;//result_buffer.UpgradeOpen();&lt;BR /&gt;//result_buffer.Erase();&lt;BR /&gt;//if (distance_buf &amp;lt; 1)&lt;BR /&gt;//{&lt;BR /&gt;// dest.Highlight();&lt;BR /&gt;//}&lt;BR /&gt;if (distance_buf &amp;gt;1)&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;// ed.WriteMessage(distance_buf + "\n");&lt;BR /&gt;make_buffer(dest, Math.Round(distance_buf+2.5), "Buffer");&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;ListEcho.Items.Add("Am procesat " + get_poly3d.Count.ToString() + " polilinii");&lt;BR /&gt;&lt;BR /&gt;tr.Commit();&lt;BR /&gt;tr.Dispose();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;&lt;BR /&gt;// MessageBox.Show("Done");&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;catch(System.Exception ex)&lt;BR /&gt;{&lt;BR /&gt;MessageBox.Show(ex.ToString());&lt;BR /&gt;}&lt;BR /&gt;OutPlines();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the program make reference to exlude a specific layer&amp;nbsp; so that it amke the outline of an area&amp;nbsp;&lt;/P&gt;&lt;P&gt;hpe this helps&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2022 11:22:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/outline-closed-polylines-in-autocad-net/m-p/11325639#M15428</guid>
      <dc:creator>imagination_s</dc:creator>
      <dc:date>2022-07-28T11:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: Outline closed Polylines in Autocad.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/outline-closed-polylines-in-autocad-net/m-p/11327645#M15429</link>
      <description>&lt;P&gt;Can you please use the code formatting feature !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;public void make_buffer(Polyline3d poly, double buffer, string detination_layer)

{  // . . .  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="_kdub_0-1659076727432.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1097915iFA9638FDFEDB2CDB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="_kdub_0-1659076727432.png" alt="_kdub_0-1659076727432.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Click the button.&lt;/P&gt;&lt;P&gt;A dialog opens .&lt;/P&gt;&lt;P&gt;Add the code ( paste ) into the dialog.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&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>Fri, 29 Jul 2022 06:43:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/outline-closed-polylines-in-autocad-net/m-p/11327645#M15429</guid>
      <dc:creator>kerry_w_brown</dc:creator>
      <dc:date>2022-07-29T06:43:19Z</dc:date>
    </item>
  </channel>
</rss>

