def self.select_by_layer(mod, layer_name)
ent = mod.active_entities # Error here
(The temporary entities are hidden and then the model is saved.)
The problem is that the active model does not seem to be available while quitting. It is probably closed before the observer is triggered. The Ruby console shows the error just before the window disappears.
It is not a major issue, but it is quite annoying to see these entities in the preview panel when the user opens SketchUp again.
I’m not an “observer” expert, but as I recall when I studied them, I didn’t really able catch the “onQuit” call. I guess it is happening when a modell is already saved and everything else is “done”.
When Sketchup quits (e.g. user select File>>Exit) , it will check if the model have changes, if yes it will show the save panel, but the “onQuit” call will hapen only after the save, so I do think the “onQuit” at least poorly documented or buggy… but I gueess - currently you cant use it to interrupt the quit and to make changes at the model.
As you also realised.
Anyway, to hid an entities without user interaction, in my opinion is a bad habit, you should inform the user about it… E.g. You should have a menu like: “Hide my temporally entities…”
Alternatively, perhaps, you can use the “onOpenModel” , “onActivateModel”… call next time the user open the model, and your extension is still installed… >> Popup: “Do you want to Hide my temporally entities…?”
I agree in principle, but this is a special case. These entities are generated on the fly only when a specific tab of the plugin is selected. They are used more like visual aids and they are not part of the model in the sense of objects, in my case buildings in a masterplan. They are also hidden when the user navigates to a different tab.
Yes, I had thought about this However, they would still be shown in the preview panel.