Need help with CmdButton / Killing your grandfather in the past paradox

In some of our definitions using Human UI, we ask the user for initial objects which are processed and then baked.
Since the processed objects are meant to replace the initial ones, the later should be deleted.
I tried to use the “Create Rhino Command Button” to do this, by feeding it a command that selects the initial objects and deletes them, but it doesn’t work : I need to deleted them manually.

The new objects are created though.

I understand this is a case of possible infernal loop, since : if the initial objects are deleted, there is no more input for the definition to process, and there would be no more objects to bake…

Yet, this problem comes up very often, and I’d like to know if there is a “Clean and reliable” way of dealing with it.

(Here an example of a definition that will create mortise and tenon features on steel plates)

Sarah Connor ?

I think this is what you’re after. RhinoCommon has a helpful “Replace” method that will swap out an object while preserving its properties, and that seems to do the trick here, with a little scheduled-solution magic.

Replace (21.4 KB)


It works like a charm.
Thank you so much Andrew.
This seems like it could be a very useful addition to Human tools…

1 Like

cool tool. can you fix it ?
he does not understand the line and turns the closed line into an object :frowning:

that script is only set up to work with Breps. this one should work with breps and curves. For additional types it will have to be similarly extended.
replace (5.2 KB)

1 Like

thanks but it doesn’t work at all. :upside_down_face:

sorry, it worked on mac, windows doesn’t support that c# syntax
replace (6.3 KB)

1 Like

many thanks ! works perfect! :grinning: