Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am kind of stuck getting the JOIN command accepting my selected entities. The error messages are:
Value does not fall within the expected range
From within AutoCAD the selected entities could be JOINed of course.
So what's wrong with the code:
1. Is it the way objects are added to the ed.Command(...);
2. Or has it something to do with the JOIN command itself
Thanks for any help.
These are the trials so far.
//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 < 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); } }
Solved! Go to Solution.