This may be an argueable behaviour but for me it would perfectly make sense to have the sim_customizationscriptcall_cleanup called before saving a scene or a model.
By this, changes from the scripts could be remove again (if wanted/implemented in the cleanup section) before saving and so saving just keeps changes to the script itself or changes done outside of the script (i.e. manually).
Maybe to make it a bit clearer: my use-case of a customization script is to have it attached to a dummy object and automatically reload a robot model from somewhere else in the filesystem to the dummy position within the scene as I want to keep the model file separate from the scene file. If someone wants to keep the changes from a customization script, he/she just doesn't implement the removal of these objects in the cleanup section.
What are your thoughts on this???
Regards
Steffen
Call sim_customizationscriptcall_cleanup before saving
-
- Posts: 3
- Joined: 03 Mar 2015, 16:45
- Contact:
Re: Call sim_customizationscriptcall_cleanup before saving
Hello Steffen,
this makes perfectly sense and is a good idea to implement this as a option that can be enabled/disabled on a customization script level, e.g. with:
Of course this should consider only customization scripts concerned by the save operation, i.e. all in case of scene save, and only the customization scripts of the model, in case of model save.
Not sure if this can make it into the next release, but we'll try.
Cheers
this makes perfectly sense and is a good idea to implement this as a option that can be enabled/disabled on a customization script level, e.g. with:
Code: Select all
simSetScriptAttribute(sim_handle_self,sim_customizationscriptattribute_cleanupbeforesave,true)
Not sure if this can make it into the next release, but we'll try.
Cheers
-
- Posts: 3
- Joined: 03 Mar 2015, 16:45
- Contact:
Re: Call sim_customizationscriptcall_cleanup before saving
Thanks for the fast reply and the agreement. The suggested solution would be perfectly fine for me.
Regards
Steffen
Regards
Steffen
Re: Call sim_customizationscriptcall_cleanup before saving
Looking more in details at this, I noticed that there might be a small problem: the undo/redo functionality works by saving the scene to memory at each change, comparing with previous memory save, and effectively saving only the differences of the two.
So this means we would also have to call the clean-up section of customization scripts each time the scene content has changed... which is potentially a lot and will slow down things, depending on what you do in the clean-up or initialization sections. So I'll implement the solution previously mentioned, in addition you will have the property sim_customizationscriptattribute_cleanupbeforeundosave that can be set separately.
The better solution would be to combine 2 methods:
Cheers
So this means we would also have to call the clean-up section of customization scripts each time the scene content has changed... which is potentially a lot and will slow down things, depending on what you do in the clean-up or initialization sections. So I'll implement the solution previously mentioned, in addition you will have the property sim_customizationscriptattribute_cleanupbeforeundosave that can be set separately.
The better solution would be to combine 2 methods:
- Use a dummy as placeholder for the object to load. Attached to it, a customization script.
- in the init phase of the customization script, check if the dummy has children. If yes, remove them
- still in the init phase, load the desired model and make the dummy its parent (i.e. attach the model to the parent), set the correct model position/orientation.
- still in the init phase call simSetScriptAttribute(sim_handle_self,sim_customizationscriptattribute_cleanupbeforesave,true)
- in the clean-up phase, remove the children of the dummy
Cheers
-
- Posts: 3
- Joined: 03 Mar 2015, 16:45
- Contact:
Re: Call sim_customizationscriptcall_cleanup before saving
It seems to work now for scenes (so scene objects are deleted before saving) but not for saving model bases with "Saving model as...". Here the submodels (i.e. Sensors) are not removed before saving.
Re: Call sim_customizationscriptcall_cleanup before saving
Ooops, you are right,
thanks for pointing that out.
Cheers
thanks for pointing that out.
Cheers