Message 1 of 4
Calling AutoCAD Undo commands from C#.NET

Not applicable
03-31-2015
09:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to write two methods which call AutoCAD's UNDO command and pass in different parameters. The first method calls UNDO and passes M which means mark the position of the drawing. The second method calls UNDO and passes B which means undo all the way back to the marked position (or the end if there isnt one). So far they are pretty simple
/// <summary> /// Method to mark the current position of the AutoCAD program /// </summary> public static void MarkPosition() { doc.SendStringToExecute("._UNDO M", true, false, true); } /// <summary> /// Method to step AutoCAD back int steps /// </summary> public static void BigUndo() { doc.SendStringToExecute("._UNDO B", true, false, true); }
These look like they should work but for some reason they don't. When I call MarkPosition() and then BigUndo() I get an error saying Start of Group encountered; enter Undo End to go back further. To test my syntax. I changed MarkPosition to
public static void MarkPosition() { doc.SendStringToExecute("circle 2,2,0 4 ", true, false, true); }
which successfully draws a circle. That means my syntax is right but something weird is going on with Undo.