[Question] Switch of model and Interactive Plugins on Mac
-
Here is a question I should have asked long before, as I don't have a Mac.
On Mac, you can several SKP documents opened concurrently, each in a separate window.
Now, when you run an interactive script (based on Sketchup::Tool class), what does happen when you switch from one model window to another one?
Say the script is RoundCorner. I assume it displays a button palette in the viewport of the window where it is launched.
If you switch to another model window, what happens
- is the button palette also displayed in this model window?
- if not, can you launch RoundCorner again in this model window?
That may be a basic interrogation, but without a Mac to check, I realize that I don't know the answer.
Thanks to all
Fredo
-
On Mac, there is a bug (which I reported and filed some time ago) in the handling of things created using the various view#draw_xxx methods within a Tool. The items from the currently active_model's view are drawn to all views. As soon as you select a different model/view, it's selected Tool activates and its draw affects all the views. So, ultimately it is only a cosmetic bug because the only Tool active is the one for the active_model, but it is visually quite annoying.
-
New for SketchUp 2015 is a callback in the AppObserver:
onActivateModel
It only applies to Mac.Commands, MenuItems and Toolbars, should always act upon the active model. Or more specifically, check the active model states when deciding what to return for their validation proc, status bar text and tooltips. (Use commands for both menus and toolbars, and it becomes easier.)
Tools should always act upon the active model, and it is best if each model gets it's own tool instances, so there will not be any cross-contamination of data. More importantly, when a model is switched, the tool in the "from" model might be deactivated, or might not. It may be left in the same state, but don't count on it. Expect it to be suspended, so implement
suspend()
andresume()
callbacks in your Tool class.Each model has it's own toolstack collection, therefore each model has it's own active tool object. These objects may not be instances of the same tool class, and even if they are, they might not be at the same step state. (One may have not done anything, another may have chosen the 1st point, still another the 2nd point, etc.)
-
click to run gif, if it doesn't...
john -
Thanks to all for feedback.
So there is a bug somewhere, because in all my scripts, all viewport drawing (i.e. view draw) are done with the <view> parameter of the Tool#draw method. And anyway, it should only draw to one viewport, not to several.
Dan: thanks for feedback as well. If each model has its own tool stack, then we can program on Mac as if we were on Windows, that is not bothering about change of model.
Fredo
-
As John's animation shows, it isn't a matter of each model not having its own Tool activated, it is an issue with SketchUp duplicating certain view.draw_xxx contents on all existing views. This is a bug we reported some time ago.
Advertisement