My plugin manages the entities of a model and in order to work correctly needs some entities to be present and some others not to be.
This usually works, but there are cases in which users will save the model manually. I am reviewing the overall workflow, but I need a ‘patch’ at the moment.
I was thinking to use preSaveModel from the model observer to intercept when users save the model and notify them that there are some entities that should not be there. This gives the opportunity to remove them manually or back them up in another file.
Should they decide to do so the model would not be saved. This is where I am struggling. How do I stop the saving process that has already been initiated?
I don’t know enough about SketchUp’s Ruby API to comment on the technicalities of your design idea, but as a SketchUp user I offer the following side comment: a user should always be able to save their work. It is OK to present a caution about some aspect of saving that the user might not expect, but it is critical to me that a user be able to save their model at any time (assuming that SketchUp is essentially idle, of course).
@TDahl Thanks for your feedback. It is very helpful, especially because it comes from a user and that is what matters.
I might have to rethink the whole approach sooner that I wished to. I also realised that with my approach users would not even be able to ‘save as’ and that it is a no go.
You can store continuously the id of each entity that should be removed in a hash (or array) and in case the user save the model your plugin can read that hash and delete the entities after that.
… or you could just assign the “problem” entities to a tag and hide it.