Style validation
-
this is all i could find, on retrieving a style name that seems to work from the console.
styles = Sketchup.active_model.styles style = styles.selected_style UI.messagebox ('The selected style is; ' + style.name)
but i can't get it to work with a validation proc - something along these 'lines'...
cmd.set_validation_proc { styles = Sketchup.active_model.styles style = styles.selected_style if style.name = mystyle.style MF_CHECKED else MF_UNCHECKED end }
-
-
@cadfather said:
this is all i could find, on retrieving a style name that seems to work from the console.]
Sketchup.active_model.styles.methods
will show you there are a lot more that work...
but, what are you trying to achieve?
john -
yes TIG i think that is it - i'm going to try it. (fail)
mystyle.style is just the name of the file i'm calling (from a toolbar).
John, then i wanted to have an icon which activated if that particular style was active (selected).
-
Still as clear as mud
What is 'mystyle' ?
What is its 'style' ?If you are not clear, try to type
mystyle.class
and it'll tell you... -
i've got a toolbar, clicking an icon it loads and applies a style from a folder (mystyle.style, for want of a better name). this part is working fine.
what i was trying to do is for the icon to highlight anytime that style is active.
(from the api the 'active' procedure didn't work but the 'selected' did)
hope this makes some sense..
-
So "
mystyle.style
" is actually a string representing a.style
file physically on the PC.
Lets say you have reference to the file as@style_file = ".../somefolder/mystyle.style"
If you have named it logically then its Style is named 'mystyle
'.
So@style_name = File.basename(@style_file, ".*")
gives you the string'mystyle'
[or the basename of whatever the file that is queried that way].NOW you can compare the name of the current style and the name of the style_file thus:
cmd.set_validation_proc { ### let's assume @style_file is set elsewhere, as perhaps; @style_file = ".../somefolder/mystyle.style" ### get its name... @style_name = File.basename(@style_file, ".*") ### compare current style name and basename if Sketchup.active_model.styles.selected_style.name == @style_name MF_CHECKED else MF_UNCHECKED end }
To pass
@
variables you need the validation to take place inside themodule...end
where that@
variable is set... -
ok TIG, thanks for that, i shall have a go with this.
i thought i wasn't too far with my first example!
Thanks!
Advertisement