Hallo,
i have an problem with interaction between SendStringToExecute and SetImpliedSelection.
In following example work the SetImpliedSelection fine without the SendStringToExecute,
but with the SendStringToExecute do SetImpliedSelection nothing.
Why??
Code:
[CommandMethod("-SELTEST", CommandFlags.Transparent | CommandFlags.UsePickSet | CommandFlags.Redraw | CommandFlags.Modal)] public void SELTEST() { Autodesk.AutoCAD.EditorInput.Editor acEditor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager. MdiActiveDocument.Editor; Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection acObjectIdCollection; if (acEditor.SelectImplied().Value != null) { Autodesk.AutoCAD.EditorInput.PromptSelectionResult acPromptSelectionResult = acEditor.SelectImplied(); if (acPromptSelectionResult.Status == Autodesk.AutoCAD.EditorInput.PromptStatus.OK) acObjectIdCollection = new Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection(acPromptSelectionResult.Value.GetObjectIds()); else acObjectIdCollection = new Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection(); // 2 Elements remove from selection for Check acObjectIdCollection.RemoveAt(0); acObjectIdCollection.RemoveAt(0); // ToArray Autodesk.AutoCAD.DatabaseServices.ObjectId[] oIDArray = new Autodesk.AutoCAD.DatabaseServices.ObjectId[acObjectIdCollection.Count]; acObjectIdCollection.CopyTo(oIDArray,0); // SendCommand (without this sendcommand work the SetImpliedSelection fine) Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.SendStringToExecute("_zoom _a ", false, false, false); //Set SelectionSet acEditor.SetImpliedSelection(oIDArray); // don't work } }
regards Mario
Solved! Go to Solution.
Actually, the SetImpliedSelection Is working just fine. SendStringToExecute is Asynchronous, so your zoom command runs after the SetImpliedSelection, and clears the selection.
Instead of using SendStringToExecute("_ZOOM _A "); you can use ZoomExtents (or ZoomAll):
public static void ZoomExtents() { object acad = Application.AcadApplication; acad.GetType().InvokeMember("ZoomExtents", BindingFlags.InvokeMethod, null, acad, null); }
public static void ZoomAll() { object acad = Application.AcadApplication; acad.GetType().InvokeMember("ZoomAll", BindingFlags.InvokeMethod, null, acad, null); }
which can be done synchronously with your's code.
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Thanks Alexander. I was going to suggest using a graphics system manager to manipulate the view, but it would require that he calculate the extents, which would obviously add a lot of code. I didn't think about invoking a COM call.
Hallo,
for your notes, but the problem is not the "zoom" command. The example code is only a quick and dirty example.
In the Application i select the entities or use the pre-selection and take a user input for "new Elevation"
after this i calulate a new ucs and set the editor.currentucs (or smiliar, just i have no autocad).
Now i calling the "_plan " command to view planar to ucs, '(load "...")' the flatten.lsp with SendCommand.
Then i would like to set the "SetImpliedSelection" with the Objectidcollection from begin of the app and
lastly i calling the "flatten" command. (the origin flatten.lsp i have modify to complete silent)
On debug is set the editor.ImpliedSelection okay but on flatten comes to nothing.
I think ist a effect of the asynchronous for SendStringToExecute.
There is a synchronous variant of SendStringToExecute?
@Alexander:
On next Monday i test the : acad.GetType().InvokeMember for my Application.
until then a nice weekend.
regards Mario
@Anonymous wrote:
There is a synchronous variant of SendStringToExecute?
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Hi,
You can wrap the P/Invoked acedCmd in an helper 'Command' method. See here:
http://www.theswamp.org/index.php?topic=31886.msg460020#msg460020
Then use it as the LISP command function:
Command("_.circle", Point3d.Origin, 10.0);
Command("_.move", selSet, Point3d.Origin, new Point3d(10.0, 20.0, 0.0));
Hello Alexander and _gile
the examples of "send synchronously commands" works fine.
But now i have one problem by send command '(load "C:/test.lsp")'.
AutoCAD response "LISP command not available"!?
How can i load the lsp-file?
When i load the lisp-file on appload automatically then don't find AutoCAD
the lispfunction, response "unknown command". But when i input the same
command in the AutoCAD-Commandline then works the command !?
regards Mario
(load...) is not a command. The acedCmd() method only accepts commands and the input they request..
To execute LISP you could use acedEvaluateLisp() or acedInvoke() via P/Invoke.
... i give up ...
Now i have test all variants of send lisp-Command. No variant works for (load "abc.lsp").
And no synchron commandcalling-variant can call a lisp-exported command.
My Solution:
I load the lisp-file over "Appload" and call the lisp-exported function as lasted in my app over "SendStringToExecute".
This works.
i have found in TheSwamp
When .net function set the "CommandFlags.Session" then works the
..
((Autodesk.AutoCAD.Interop.AcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication).ActiveDocument.SendCommand(commandstring);
..
Synchronously. And does what i want.
regards ... over and out ...
Mario
Can't find what you're looking for? Ask the community or share your knowledge.