<?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 : Join using Command in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/join-using-command/m-p/5968082#M37617</link>
    <description>Thanks for pointing out to that code, I am already using parts of your library.&lt;BR /&gt;However in another discussion (i think Kean took part in that) the use of the ed.Command functions where recommended, and thus thought lets try to implement a JOIN function using ed.Command.&lt;BR /&gt;&lt;BR /&gt;Again thanks for you're considerations.&lt;BR /&gt;</description>
    <pubDate>Wed, 30 Dec 2015 11:14:58 GMT</pubDate>
    <dc:creator>SENL1362</dc:creator>
    <dc:date>2015-12-30T11:14:58Z</dc:date>
    <item>
      <title>Join using Command</title>
      <link>https://forums.autodesk.com/t5/net-forum/join-using-command/m-p/5967967#M37613</link>
      <description>&lt;P&gt;I am kind of stuck getting the JOIN command accepting my selected entities. The error messages are:&lt;/P&gt;&lt;PRE&gt;Value does not fall within the expected range&lt;/PRE&gt;&lt;P&gt;From within AutoCAD the selected entities could be JOINed of course.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So what's wrong with the code:&lt;/P&gt;&lt;P&gt;1. Is it the way objects are added to the ed.Command(...);&lt;/P&gt;&lt;P&gt;2. Or has it something to do with the JOIN command itself&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any help.&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;These are the trials so far.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;       //Goal: Create Polyline from calculated objects using JOIN command
        [CommandMethod("TJC", CommandFlags.UsePickSet | CommandFlags.Modal)]
        public static  async void TestJoinCommand()
        {
            Document doc = null;
            Database db = null;
            Editor ed = null;

            try
            {
                doc = AcadApp.DocumentManager.MdiActiveDocument;
                if (doc == null)
                    throw new System.Exception("No MdiActiveDocument");
                db = doc.Database;
                ed = doc.Editor;

                //ed.Command("_.JOIN", ed.SelectImplied()); //Error: Value does not fall within the expected range
                //ed.Command("_.JOIN", objIds[0], objIds.Skip(1)); //Error: Value does not fall within the expected range

                //PromptSelectionResult selectionRes1 = ed.SelectImplied();
                //ObjectId[] objIds = selectionRes1.Value.GetObjectIds();
                //ed.Command("_.JOIN", objIds[0], objIds[0], objIds[1], objIds[2], "");
                //ed.SetImpliedSelection(new ObjectId[0]);
                //ed.Command("_.JOIN", objIds); //Error: Value does not fall within the expected range
                
                


                //ed.SetImpliedSelection(selectionRes1.Value);
                //PromptSelectionResult selectionRes2 = ed.SelectImplied();
                //ed.Command(new object[] { "_.JOIN", selectionRes2 }); //Invalid range
                //ed.Command("_.JOIN", selectionRes1.Value);  //Bad Selection Set

                //await ed.CommandAsync("_.JOIN");
                //using (Transaction tr = db.TransactionManager.StartTransaction())
                //{
                //    foreach (ObjectId objId in objIds)
                //    {
                //        Entity ent = (Entity)tr.GetObject(objId, OpenMode.ForRead);
                //        await ed.CommandAsync(ent.ObjectId);
                //    }
                //    await ed.CommandAsync("");
                //    tr.Commit();
                //}

                //Test1: Send PickSet. Failed
                if (ed.SelectImplied().Value != null)
                    ed.Command("_.JOIN");

                //Test2: Send PickSet, and close selection. Failed
                if (ed.SelectImplied().Value != null)
                    ed.Command(new object[]{"_.JOIN", ""});
                    ed.Command("_.JOIN","");

                //Test3: Add objects one at the time. Failed
                SelectionSetDelayMarshalled ssMarshal = (SelectionSetDelayMarshalled)ed.SelectImplied().Value;
                var selObjIds = ssMarshal.GetObjectIds();
                ed.SetImpliedSelection(new ObjectId[0]);
                SelectionSet selSet = (SelectionSet)ssMarshal;
                using (DocumentLock docLck = doc.LockDocument())
                {
                     await ed.CommandAsync("_.JOIN");
                     await ed.CommandAsync(selObjIds[0]);
                     for (int i = 1; i &amp;lt; selObjIds.Length; i++)
                         await ed.CommandAsync(selObjIds[i]);
                     await ed.CommandAsync("");
                }
            }
            catch (System.Exception ex)
            {
                if (ed != null)
                    ed.WriteMessage("\n Error in TestJoinCommand: {0}", ex.Message);
            }
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Dec 2015 07:50:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/join-using-command/m-p/5967967#M37613</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2015-12-30T07:50:57Z</dc:date>
    </item>
    <item>
      <title>Re : Join using Command</title>
      <link>https://forums.autodesk.com/t5/net-forum/join-using-command/m-p/5967998#M37614</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like the "JOIN" command called by Editor.Command() doesn't work exactly the same as the one called from within AutoCAD.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe you'd be more lucky with the "PEDIT" command.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;        [CommandMethod("TJC", CommandFlags.Modal | CommandFlags.UsePickSet)]
        public static void TestJoinCommand()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            PromptSelectionResult psr = ed.GetSelection();
            if (psr.Status != PromptStatus.OK)
                return;
            object peditAccept = Application.GetSystemVariable("PEDITACCEPT");
            Application.SetSystemVariable("PEDITACCEPT", 1);
            try
            {
                ed.Command("_.PEDIT", "_Multiple", psr.Value, "", "_Join", 0.0, "");
            }
            catch (Exception ex)
            {
                ed.WriteMessage("\nError: n{0}", ex.Message);
            }
            finally
            {
                Application.SetSystemVariable("PEDITACCEPT", peditAccept);
            }
        }&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Dec 2015 08:45:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/join-using-command/m-p/5967998#M37614</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2015-12-30T08:45:47Z</dc:date>
    </item>
    <item>
      <title>Re : Join using Command</title>
      <link>https://forums.autodesk.com/t5/net-forum/join-using-command/m-p/5968014#M37615</link>
      <description>Hi Gilles,&lt;BR /&gt;Thanks for confirming my issues. I hoped the JOIN command could replace the somewhat complicated c# implementation to build polylines from entities.&lt;BR /&gt;Also thanks for sending the PEDIT alternative.&lt;BR /&gt;</description>
      <pubDate>Wed, 30 Dec 2015 09:14:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/join-using-command/m-p/5968014#M37615</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2015-12-30T09:14:02Z</dc:date>
    </item>
    <item>
      <title>Re : Join using Command</title>
      <link>https://forums.autodesk.com/t5/net-forum/join-using-command/m-p/5968079#M37616</link>
      <description>&lt;P&gt;You're welcome.&lt;/P&gt;
&lt;P&gt;If you want to implement your own method, you can use or get some inspiration from the &lt;A href="http://www.theswamp.org/index.php?topic=31865.msg373672#msg373672" target="_blank"&gt;GeometryExtension library&lt;/A&gt;, mainly the PolylineSegment and PolylineSegmentcollection classes (the second one have an overloaded Join() method).&lt;/P&gt;
&lt;P&gt;A using example &lt;A href="http://www.theswamp.org/index.php?topic=31865.msg446965#msg446965" target="_blank"&gt;here&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Dec 2015 11:09:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/join-using-command/m-p/5968079#M37616</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2015-12-30T11:09:11Z</dc:date>
    </item>
    <item>
      <title>Re : Join using Command</title>
      <link>https://forums.autodesk.com/t5/net-forum/join-using-command/m-p/5968082#M37617</link>
      <description>Thanks for pointing out to that code, I am already using parts of your library.&lt;BR /&gt;However in another discussion (i think Kean took part in that) the use of the ed.Command functions where recommended, and thus thought lets try to implement a JOIN function using ed.Command.&lt;BR /&gt;&lt;BR /&gt;Again thanks for you're considerations.&lt;BR /&gt;</description>
      <pubDate>Wed, 30 Dec 2015 11:14:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/join-using-command/m-p/5968082#M37617</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2015-12-30T11:14:58Z</dc:date>
    </item>
  </channel>
</rss>

