Editor.Command from palette
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey all,
My question is very similar to this question: https://forums.autodesk.com/t5/net/editor-command-from-palette/td-p/6376430
Q: Can I run a Editor.Command from a Palette, without using the construction of creating a CommandMethod and using SendStringToExecute()?
In our scenario, it's not possible to use the CommandMethod/SendStringToExecute construction, because it's not synchronously executed.
The problem we're trying to solve is the following:
Scenario
Via a palette we insert a component, this insert component will do all kinds of things in acad (via the acad API).
We surround this logic with an undo group, to create this undo group we use "Autodesk.AutoCAD.Internal.Utils.SetUndoMark( ... );".
Then at the end of everything, if the insert failed, we want to rollback all our changes.
To do this we just need to do "Undo 1", due to the undo group.
To do the "Undo 1" we use "SendStringToExecute" since there is no ACAD API to do the undo synchronously (as far as we know).
Problem
When you scroll in acad during the insert.
When the insert fails
Then ACaD will first handle the scroll
And then ACaD will handle the undo 1
Result -> Only the scroll is undone
Expected -> The complete insert changes (which are grouped) are undone
Why creating a new command won't work
We want to keep our application decoupled from ACAD, we don't want to write all our insert component logic in an ACAD command.
We merely use ACAD as a visualizer, all our application logic doesn't know it's executed in ACAD.
There is also another post about this scroll issue interacting with the SendString:
https://forums.autodesk.com/t5/net/problem-with-execute-sendstringtoexecute/td-p/5186201