Implementing Custom Parent Command Repeat with Space/Enter and Single Undo for Entire Custom Parent Command
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm developing an AutoCAD plugin using .NET API that needs to implement two specific behaviors:
Command Repetition: I have a custom parent command which uses AutoCAD's built-in command to create polyline internally, then adds related entities (text) and data. When my custom parent command completes and the user presses Space or Enter (standard AutoCAD behavior for repeating commands), I want my entire custom parent command to repeat, not just the last operation.
Single Undo for entire Custom Parent Command: My custom parent command uses AutoCAD built-in commands internally and performs operations across multiple transactions with user interactions between them. As of now, the user has to press Ctrl+Z multiple times to undo all operation in custom parent command. I need all operations to be undo in a single undo step.
My command workflow:
- Create polyline using AutoCAD's built-in command (SendStringToExecute)
- Create text entity in the Command Ended callback (to display polyline name) in one transaction
- Creating mapping between polyline and text entities in another transaction
When the user presses Space/Enter, the entire sequence in my custom parent command should repeat.
When the user executes Undo, all operations in my custom parent command should be undone in a single step(Text and Polyline should be deleted).