@joshb said:
Thanks thomthom! That is exactly what I needed to know!
Right now users are just going through the SketchUp GUI File, Import to do their work. I'm going to look at the observers, perhaps DefinitionsObserver.onComponentAdded to see if I can do my merging there.
Thanks again!
Josh
Beware! UI import is not the only thing that might import a model. If you react to an observer event you can crash SketchUp. You may also interfere with some other operation.
Setting attributes is something that can be undone. And starting an operation in the middle of another one will interfer and break the first one. So if you react to an observer event and modify anything - you might break the undo-stack, you might break an operation of another plugin or native function - or you might even crash SketchUp.
My recommendation for observers is to only read data. If you need to react with model changes, cache it for a later time when you know it's safe to modify your model. For instance, you detect a model import, you cache what definition that was and wait with the merge until your plugin need to access any of your data.
Another thing: be very careful what your observers do. Make them do as little as possible. Events can trigger in the thousands in some scenarios and then it doesn't take much to bog down a model.
Refer to this list of observer issues which I've been trying to chart: http://www.thomthom.net/software/sketchup/observers/