Save user data on a per file basis
-
Hi,
I'm working on a plugin that does a scaling operation on a model.When the model is scaled up, there's a screen note (text entity) on the screen like "Scaled up 10000 times".
Usually the user will scale down the model before saving. The screennote then disappears to indicate that the model has back its original size.
But when the user saves the scaled up file (including the screen-note of course), the only information about the scale-up action is in that screen-note.
How can I save that information in a more convenient way, and for several SU-files? -
Use something like
Sketchup.active_model.set_attribute('Liquid98','scale',@sf)
on scaling the model.
On opening a file run
sf=Sketchup.active_model.get_attribute('Liquid98','scale',nil)
If 'sf' is NOT nil then you have a scaled model... and you can then 'warn' the user ?
If the user resets the scale back to 1 you use
Sketchup.active_model.set_attribute('Liquid98','scale',nil)
so on rechecking later there is no warning is needed... -
Thanx TIG
OK I get the idea.. I'll experiment with that.
Its not really about a warning, the feedback is used as a reminder of the total scale-factor. So if the model is scaled up lets say 1000 times, the user has to multiply his input accordingly. When he/she saves the model and opens it later, the script can use
Sketchup.active_model.set_attribute('Liquid98','scale',@sf)
to scale down the model, like you suggested.Another question, can you use this
set_attributes
method as a substitute for a global variable ($varglobal
)? -
I just want to say that I am interested in the development of this idea. I wish you luck.
-
@liquid98 said:
Thanx TIG
OK I get the idea.. I'll experiment with that.
Its not really about a warning, the feedback is used as a reminder of the total scale-factor. So if the model is scaled up lets say 1000 times, the user has to multiply his input accordingly. When he/she saves the model and opens it later, the script can use
Sketchup.active_model.set_attribute('Liquid98','scale',@sf)
to scale down the model, like you suggested.Another question, can you use this
set_attributes
method as a substitute for a global variable ($varglobal
)?Currently you save the current [last-used] scale-factor globally into the Sketchup PC-Registry/MAC-Plist, this is then passed to a global variable [$] that used by all instances of Sketchup. As a user changes the scale-factor used the one available across SUp changes. Within each instance of SUp you are using a class variable [@0 to remember the last used setting too.
The last used setting AND the SKP's current 'status' are different things. You may well be better to set a model-attribute to remember the scale-factor for each SKP... then you can have a script that auto-runs at startup and checks the scale-factor for the opening SKP and if it's not '1.0' then somehow warn the user by displaying the screen-text or whatever. You will need to also make an App-observer to watch for a user opening a SKP from the menu/browser within SUp etc as that way of opening a SKP would not re-run the initial file - your App-observer would do that so when you open another SKP within SUp the same check on the current SKP's scale-factor is made - see my HolePunching tool code [near to the end] for examples of making an App-observer to ensure other observers run after such opening-events - in your case the execution of some simple sf checking code will be a lot easier to do... -
Thnx for the luck, mitcorb !
Advertisement