Undo inside command "undoes" previous one

Hi all,
I have a problem firing _Undo inside my custom commands. Basically, if I use a GetObject or a GetPoint (and potentially any Get, I tried these two) and do not set GetObject.AcceptUndo(true), if I run my command and press Ctrl+Z (or type _Undo in the command line) the previous command Undo is executed. The previous command doesn’t have any custom undo registered, but it creates a curve, so undoing inside the second command the object created gets deleted.

The strange thing is, if I use _Curve or _InterpCrv commands to create the curve, firing Undo does delete it during a GetObject, but if I pick the object and then fire Undo during a subsequent Get inside the same command, the curve doesn’t get deleted, which instead happens if I beforehand used my custom command to create it.

Does anyone has any clue about what’s happening here?

Thank you,

Hi @m.camillo, do you have an example code?

Hi Darryl,
I investigated some more on the problem and I found out the problem is related to the fact that all my commands are decorated with [CommandStyle(Style.ScriptRunner)]. I created an isolated command with the two getters and it didn’t had any problem until I added that style. Also, the new command has no different behaviours dependant on which was the previous command (which creates the curve object): this will be always get undone, even if I pick the object

So now my problem is that I need to use that style, as I sometimes use some built-in Rhino commands not accessible via RhinoCommon API. Any idea how to avoid this problem?

Thank you

Hi @m.camillo,

What command(s) are you scripting?

– Dale

Hi Dale,
we use SelDupAll, RebuildCrvNonUniform, CurveBoolean and maybe some others, together with some custom commands we created

Anyone has a solution? As a workaround I added AcceptUndo(true) to every command that need the Style.ScriptRunner, but this is not optimal as these will have an useless option on the command line that can confuse the users.

Hi @m.camillo,

About the only suggestion I can make is to not script Rhino command, but rather implement their functionality yourself. This way, your command don’t need the script runner attributes.

– Dale