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.
Enter a Command on the Command Line Enter the command using one of the following options: In the Command prompt text box, type the full command name and press Enter or Spacebar.
Ctrl+Shift+C. Copy to clipboard with base point. Ctrl+Shift+V. Paste data as block.
Solution: Use the shortcut CTRL+9 (CMD+3 in AutoCAD for Mac) to toggle on the command line.
When you use SendCommand you always need a space at the end, that will make sure the command runs.
Also, on AutoCAD 2015 (and newer) you can user Editor.Command or Editor.CommandAsync, which is much better.
http://adndevblog.typepad.com/autocad/2014/04/migration-after-fiber-is-removed-in-autocad-2015.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With