Code Red > .NET

how to get update selection after run sendcommand pedit

(1/1)

daboho:
i have line ,arc and send command to change to polyline
how to make get value is polyline after send command pedit,in my code still read first selection (line)
i want to make result selection is after pedit how to update this

--- Code: --- [CommandMethod("IMP",CommandFlags.UsePickSet|CommandFlags.Modal)]
        public void SELECM()
        {
            var ss = ed.GetSelection();
            if (ss.Status != PromptStatus.OK) return;
            ObjectId[] myID = ss.Value.GetObjectIds().ToArray();
            ed.SetImpliedSelection(myID);
            string cmd = "._pedit\n_m\n_p\n\n_Y\n_Join\n\n\n";
            doc.SendStringToExecute(cmd, true, false, false);
            ed.Regen();
            var ss1 = ed.SelectImplied();
            if (ss1.Status != PromptStatus.OK) return;
           
            using (var tr = db.TransactionManager.StartTransaction())
            {
                foreach (SelectedObject s in ss1.Value)
                {
                    var ob = tr.GetObject(s.ObjectId, OpenMode.ForRead) as DBObject;
                   //[b]this result object is still line[/b]
                    //[b]how to make update selection result selection is object after has to pedit where is object polyline after send command pedit[/b]
                    ed.WriteMessage("\nobject type " + ob.GetType().Name.ToString());
                }
                tr.Commit();
            }
     
        }
--- End code ---

gile:
Hi,

SendStringToExecute works asynchronously (i.e. the string command is executed at the end of the code).
You can use Editor.Command() which works synchronously and accept typed arguments such as numbers, ObjectId or SelectSet (the same way as the command LISP function).

--- Code - C#: ---        [CommandMethod("IMP", CommandFlags.UsePickSet | CommandFlags.Modal)]        public static void SELECM()        {            var doc = Application.DocumentManager.MdiActiveDocument;            var db = doc.Database;            var ed = doc.Editor;            var ss = ed.GetSelection();            if (ss.Status != PromptStatus.OK) return;            ed.Command("_.pedit", "_m", ss.Value, "", "_y", "_join", "", "");            var ss1 = ed.SelectLast();            if (ss1.Status != PromptStatus.OK) return;             using (var tr = db.TransactionManager.StartTransaction())            {                foreach (ObjectId id in ss1.Value.GetObjectIds())                {                    ed.WriteMessage("\nObject type: " + id.ObjectClass.DxfName);                }                tr.Commit();            }        }

daboho:
thank gile i was test but only one object is selected not all
ed.WriteMessage("\ncount object : " + ss1.Value.Count.ToString()); result only 1
in first selection is 3 line

gile:
The 3 lines do not exist anymore, the command PEDIT created a new polyline and deleted the 3 lines.

daboho:
My mean var ss1=ed.SelecLast()
Only select single last one object
In ss1.count only one of object (only can save single last object or can not save multiple object)

Navigation

[0] Message Index

Go to full version