Non-model geometry
-
Hello
During implementation of plugin I faced with requirement to show some geometry to user which should not appear in saved files and preferably be absent in "undo" stack.
It's a helper entity - basically bounding box which shows to user bounds of area for model fitting.
Does anyone know ways to do such things in Sketchup?
P.S.
We already considered approach of creating a tool, but it's important to allow user to edit model with other tools while the plugin is active. -
Think you're out of luck. There is no event that trigger before you save. And the arguments of
model.start_operation
which is meant to let operations be transparent - is bugged. -
As your PS - with a 'tool' you can 'draw' openGL geometry temporarily but this only displays while the tool is active.
To make a 'bounds-box' why not make a lightly transparent grouped box with hidden edges etc that sits in the required location [locked?] and stays there while you do other things/tools.
The 'bounds-box' could be a 'unique' thing in that when you activate a new one it'd make sure that any earlier one was erased - simple attribute given to the grouped box lets it be recognized as one ready for erasure...
You then have a tool/toolbar-icon[s] to show 'bounds', hide/clear 'bounds' etc for some particular location [not sure how you want to specify this?]...
You could also have an observer that removed any left over 'bounds' when the model closed, or removed any found when the model starts, so there is never a 'bounds' you don't expect, and never more that one of them at a time ?
Making the box will be undo-able BUT you could store the bounds' info in a model attribute and set a flag that says one should be displayed... then when it is erased in an undo error an observer watching for groups say spots that the desired one is gone and automatically recreates it UNLESS you run a 'bounds' clear tool to remove it and reset the flag etc ??? -
I noticed that the API documentation for view.draw_(lines,points,etc...) mentions that it is usually implemented inside the draw method.
Is there any other way you can implement them?
-
No.
-
Thanks for answers.
We ended up with approach similar to one of described by TIG: we have a separate layer with known and recognizable name and store all our geometry there. Any operation gets required data (actually it's only box size) from that layer and thus the problem with losing references to our stuff is solved.
Of course problem with appearance of our geometry in saved modelΡ is still relevant, but it seems we can and will have to live with that (because after reopening the plugin catches existing geometry)...
Advertisement