<?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: Recreating the &amp;quot;Shrink Wrap Linework&amp;quot; command in C# in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/recreating-the-quot-shrink-wrap-linework-quot-command-in-c/m-p/10622544#M15281</link>
    <description>I set CommandFlags.Session thinking that this allows the subsequent command thats written to be accessed throughout the entire AutoCAD Session instead of just the current document. However I just copied and pasted your code and it worked fine without CommandFlags.Session, so I really didn't understand what it actually does.&lt;BR /&gt;&lt;BR /&gt;I am very thankful for your hard work and thorough explanations, I extend my gratitude once again.</description>
    <pubDate>Tue, 14 Sep 2021 20:43:36 GMT</pubDate>
    <dc:creator>dalexanderSP3WJ</dc:creator>
    <dc:date>2021-09-14T20:43:36Z</dc:date>
    <item>
      <title>Recreating the "Shrink Wrap Linework" command in C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/recreating-the-quot-shrink-wrap-linework-quot-command-in-c/m-p/10608486#M15275</link>
      <description>&lt;P&gt;Greetings everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to programmatically create a "profile" or "Shrink Wrap Outline" around a collection of Curve objects (only Arcs, Lines, and Polylines). I have not seen any C-Sharp documentation or support on this topic, though I have found the command written in LISP, which is not really helpful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Im really only concerned with creating the outline around the curves objects, and don't care much about "islands" that exist inside of the outline.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are two links that describe exactly what I am trying to recreate in C# in more detail:&lt;/P&gt;&lt;P&gt;&lt;A href="https://knowledge.autodesk.com/support/autocad-architecture/learn-explore/caas/CloudHelp/cloudhelp/2018/ENU/AutoCAD-Architecture/files/GUID-568FD1DC-C794-49DB-8127-E98804947D25-htm.html" target="_blank"&gt;https://knowledge.autodesk.com/support/autocad-architecture/learn-explore/caas/CloudHelp/cloudhelp/2018/ENU/AutoCAD-Architecture/files/GUID-568FD1DC-C794-49DB-8127-E98804947D25-htm.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://files.carlsonsw.com/mirror/manuals/Carlson_2021/source/General/Draw/ShrinkWrap_Entities/ShrinkWrap_Entities.htm" target="_blank"&gt;http://files.carlsonsw.com/mirror/manuals/Carlson_2021/source/General/Draw/ShrinkWrap_Entities/ShrinkWrap_Entities.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A great thank you to anyone who can help!&lt;/P&gt;</description>
      <pubDate>Wed, 08 Sep 2021 15:32:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/recreating-the-quot-shrink-wrap-linework-quot-command-in-c/m-p/10608486#M15275</guid>
      <dc:creator>dalexanderSP3WJ</dc:creator>
      <dc:date>2021-09-08T15:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: Recreating the "Shrink Wrap Linework" command in C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/recreating-the-quot-shrink-wrap-linework-quot-command-in-c/m-p/10608517#M15276</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;You should get some inspiration from &lt;A href="https://forums.autodesk.com/t5/net/outline-closed-polylines-in-autocad-net/m-p/10584331/highlight/true#M70065" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;this reply&lt;/STRONG&gt;&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Sep 2021 15:45:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/recreating-the-quot-shrink-wrap-linework-quot-command-in-c/m-p/10608517#M15276</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2021-09-08T15:45:11Z</dc:date>
    </item>
    <item>
      <title>Re: Recreating the "Shrink Wrap Linework" command in C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/recreating-the-quot-shrink-wrap-linework-quot-command-in-c/m-p/10608528#M15277</link>
      <description>You have saved the day once again!! Thank you so much!</description>
      <pubDate>Wed, 08 Sep 2021 15:49:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/recreating-the-quot-shrink-wrap-linework-quot-command-in-c/m-p/10608528#M15277</guid>
      <dc:creator>dalexanderSP3WJ</dc:creator>
      <dc:date>2021-09-08T15:49:03Z</dc:date>
    </item>
    <item>
      <title>Re: Recreating the "Shrink Wrap Linework" command in C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/recreating-the-quot-shrink-wrap-linework-quot-command-in-c/m-p/10622128#M15278</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;In the post you referenced, your are returning an IEnumerable&amp;lt;Polyline&amp;gt; object, could you point me to some documentation that shows how to display the final "Shrinkwrap" Polyline in the editor?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Sep 2021 17:48:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/recreating-the-quot-shrink-wrap-linework-quot-command-in-c/m-p/10622128#M15278</guid>
      <dc:creator>dalexanderSP3WJ</dc:creator>
      <dc:date>2021-09-14T17:48:55Z</dc:date>
    </item>
    <item>
      <title>Re: Recreating the "Shrink Wrap Linework" command in C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/recreating-the-quot-shrink-wrap-linework-quot-command-in-c/m-p/10622241#M15279</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;Here is the command I am trying to write for more context&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;[CommandMethod("ShrinkWrap", CommandFlags.Session)]
public void ShrinkWrapLinework()
{
    Initializer.init(this);
    Document doc = Application.DocumentManager.MdiActiveDocument;
    Editor ed = doc.Editor;
    Database db = doc.Database;
    try 
    {
        PromptPointOptions ptOpts1 = new PromptPointOptions("\nSelect the first corner of Crossing Window: ");
        PromptPointResult ptRes1 = ed.GetPoint(ptOpts1);
        PromptPointOptions ptOpts2 = new PromptPointOptions("\nSelect the second corner of Crossing Window: ");
        PromptPointResult ptRes2 = ed.GetPoint(ptOpts2);
        if (ptRes1.Status == PromptStatus.OK &amp;amp;&amp;amp;
            ptRes2.Status == PromptStatus.OK)
        {
            Point3d p1 = ptRes1.Value;
            Point3d p2 = ptRes2.Value;

            PromptSelectionResult windowSelection = ed.SelectCrossingWindow(p1, p2);
            SelectionSet ss = windowSelection.Value;

            if (ss != null)
            {
                Tools.HandleTransaction(doc, (Transaction trans, BlockTableRecord btr) =&amp;gt;
                {
                    List&amp;lt;Polyline&amp;gt; plineList = new List&amp;lt;Polyline&amp;gt;();
                    foreach (SelectedObject selObj in ss)
                    {
                        DBObject foundObj = trans.GetObject(selObj.ObjectId, OpenMode.ForWrite) as DBObject;
                        if (foundObj.GetType() == typeof(Polyline))
                        {
                            using (Polyline pline = (Polyline)foundObj)
                            {
                                plineList.Add(pline);
                            }
                        }
                    }
                    
                    // ShrinkWrap the Polylines
                    IEnumerable&amp;lt;Polyline&amp;gt; plineCollection = plineList;
                    plineCollection = ObjectExtensions.ShrinkWrapPolylines(plineCollection);

                    foreach (Polyline pline in plineCollection)
                    {
                        pline.SetDatabaseDefaults();
                        pline.Thickness = 2;
                        pline.Color = Color.FromRgb(255, 0, 0);
                    }
                }, OpenMode.ForWrite);
            }
        }
    }
    catch (System.Exception ex)
    {
        Tools.Log("Shrinkwrap Error: \n" + ex.Message);
    }
}&lt;/LI-CODE&gt;&lt;P&gt;I am getting a an "Unhandled Memory" Exception when I try to re-set the plineCollection variable. I have also added the code you pointed me to in the original post in a separate class for brevity.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Sep 2021 18:23:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/recreating-the-quot-shrink-wrap-linework-quot-command-in-c/m-p/10622241#M15279</guid>
      <dc:creator>dalexanderSP3WJ</dc:creator>
      <dc:date>2021-09-14T18:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: Recreating the "Shrink Wrap Linework" command in C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/recreating-the-quot-shrink-wrap-linework-quot-command-in-c/m-p/10622520#M15280</link>
      <description>&lt;P&gt;The 'Union' method of the code in the referenced post returns an IEnumerable&amp;lt;Polyline&amp;gt;. The calling method is responsible to add these polylines to a Database or Dispose of them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;About the the command you are trying to write:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Why do you set the CommandFags.Session?&lt;/LI&gt;
&lt;LI&gt;After each prompt for user input, you should check the PromptResult.Status value and stop the execution if it's different from PromptStatus.OK.&lt;/LI&gt;
&lt;LI&gt;You should use a SelectionFilter to ensure all entities in the selection set are closed polylines.&lt;/LI&gt;
&lt;LI&gt;You do not need to convert the List&amp;lt;Polyline&amp;gt; into an IEnumerable&amp;lt;Polyline&amp;gt; because List&amp;lt;T&amp;gt; implements IEnumerable&amp;lt;T&amp;gt;.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try something like this:&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;[CommandMethod("ShrinkWrap")]
public static void ShrinkWrapLinework()
{
    var doc = Application.DocumentManager.MdiActiveDocument;
    var db = doc.Database;
    var ed = doc.Editor;

    var pointResult = ed.GetPoint("\nSelect the first corner of Crossing Window: ");
    if (pointResult.Status != PromptStatus.OK)
        return;
    var pt1 = pointResult.Value;

    pointResult = ed.GetCorner("\nSelect the second corner of Crossing Window: ", pt1);
    if (pointResult.Status != PromptStatus.OK)
        return;
    var pt2 = pointResult.Value;

    var filter = new SelectionFilter(new[]
        {
            new TypedValue(0, "LWPOLYLINE"),
            new TypedValue(-4, "&amp;amp;"),
            new TypedValue(70, 1)
        });
    var selection = ed.SelectCrossingWindow(pt1, pt2, filter);
    if (selection.Status != PromptStatus.OK)
        return;

    using (var tr = db.TransactionManager.StartOpenCloseTransaction())
    {
        var source = new List&amp;lt;Polyline&amp;gt;();
        foreach (ObjectId id in selection.Value.GetObjectIds())
        {
            source.Add((Polyline)tr.GetObject(id, OpenMode.ForRead));
        }
        var curSpace = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);

        // Add the ShrinkWrap Polylines to the current space
        foreach (var pline in ObjectExtensions.ShrinkWrapPolylines(source))
        {
            pline.Thickness = 2;
            pline.ColorIndex = 1;
            curSpace.AppendEntity(pline);
            tr.AddNewlyCreatedDBObject(pline, 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>Tue, 14 Sep 2021 20:29:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/recreating-the-quot-shrink-wrap-linework-quot-command-in-c/m-p/10622520#M15280</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2021-09-14T20:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: Recreating the "Shrink Wrap Linework" command in C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/recreating-the-quot-shrink-wrap-linework-quot-command-in-c/m-p/10622544#M15281</link>
      <description>I set CommandFlags.Session thinking that this allows the subsequent command thats written to be accessed throughout the entire AutoCAD Session instead of just the current document. However I just copied and pasted your code and it worked fine without CommandFlags.Session, so I really didn't understand what it actually does.&lt;BR /&gt;&lt;BR /&gt;I am very thankful for your hard work and thorough explanations, I extend my gratitude once again.</description>
      <pubDate>Tue, 14 Sep 2021 20:43:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/recreating-the-quot-shrink-wrap-linework-quot-command-in-c/m-p/10622544#M15281</guid>
      <dc:creator>dalexanderSP3WJ</dc:creator>
      <dc:date>2021-09-14T20:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: Recreating the "Shrink Wrap Linework" command in C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/recreating-the-quot-shrink-wrap-linework-quot-command-in-c/m-p/10623692#M15282</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/10701123"&gt;@dalexanderSP3WJ&lt;/a&gt;&amp;nbsp; a écrit&amp;nbsp;:&lt;BR /&gt;I set CommandFlags.Session thinking that this allows the subsequent command thats written to be accessed throughout the entire AutoCAD Session instead of just the current document.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The CommandFlags.Session is used to run the command in Application context instead of Document context (as modeless UI).&lt;/P&gt;
&lt;P&gt;It is required when the command switches between different Documents (e.g. open an existing document or add a new one to the active document collection).&lt;/P&gt;
&lt;P&gt;When a command is decored with this flag, you need to Lock the document before editing its Database.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 09:44:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/recreating-the-quot-shrink-wrap-linework-quot-command-in-c/m-p/10623692#M15282</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2021-09-15T09:44:27Z</dc:date>
    </item>
    <item>
      <title>Re: Recreating the "Shrink Wrap Linework" command in C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/recreating-the-quot-shrink-wrap-linework-quot-command-in-c/m-p/10624217#M15283</link>
      <description>Thank you for the clarification, I appreciate it.</description>
      <pubDate>Wed, 15 Sep 2021 13:22:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/recreating-the-quot-shrink-wrap-linework-quot-command-in-c/m-p/10624217#M15283</guid>
      <dc:creator>dalexanderSP3WJ</dc:creator>
      <dc:date>2021-09-15T13:22:02Z</dc:date>
    </item>
    <item>
      <title>Re: Recreating the "Shrink Wrap Linework" command in C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/recreating-the-quot-shrink-wrap-linework-quot-command-in-c/m-p/12566266#M15284</link>
      <description>&lt;P&gt;Hi Gile,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The ObjectExtensions.ShrinkWarpPolylines doesn't exist in the current content. Can you help me solve this error?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Feb 2024 10:19:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/recreating-the-quot-shrink-wrap-linework-quot-command-in-c/m-p/12566266#M15284</guid>
      <dc:creator>m.bakkerC8KLN</dc:creator>
      <dc:date>2024-02-17T10:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: Recreating the "Shrink Wrap Linework" command in C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/recreating-the-quot-shrink-wrap-linework-quot-command-in-c/m-p/12566339#M15285</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/9328024"&gt;@m.bakkerC8KLN&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Gile,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The ObjectExtensions.ShrinkWarpPolylines doesn't exist in the current content. Can you help me solve this error?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You should ask &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/10701123"&gt;@dalexanderSP3WJ&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;This came from his code, not mine.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Feb 2024 11:42:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/recreating-the-quot-shrink-wrap-linework-quot-command-in-c/m-p/12566339#M15285</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2024-02-17T11:42:18Z</dc:date>
    </item>
  </channel>
</rss>

