Questions on Styles and Rendering options
-
I am a little bit lost with this, at least on 2 points
- What is the
model.styles.active_style
?
Is it a way to save the current style information to replay it later?
What is the difference withstyles.selected_style
?
For sure, if the following statement create an immediate bug plat. Don't know if this is a bug or a misunderstanding of the difference
style_active = styles.active_style styles.selected_style = style.active
- The model or page rendering options des not include ALL information on styles.
At least I found that is a scene is formatted with the style "Brush Stroke Wide", the
model.rendering_options
orpage.rendering_options
does not contain all information necessary to replay the same rendering as the style from the Ruby API.The API documentation is very elusive, in general, and in particular on styles and rendering options.
Thanks for your thoughts
Fredo
- What is the
-
@fredo6 said:
For sure, if the following statement create an immediate bug plat. Don't know if this is a bug or a misunderstanding of the difference
> style_active = styles.active_style > styles.selected_style = style.active >
Anything causing a crash is to be considered a bug.
For the record, the complete snippet to reproduce the crash with all variables defined and without typo is:
styles = Sketchup.active_model.styles style_active = styles.active_style styles.selected_style = style_active
Fredo, I'll look at this on Monday. I was just skimming the forum right now.
-
thomthom,
Thanks for raising the point within Trimble.
But do you know what is the difference between
active_style
andselected_style
?Fredo
-
I have played around with styles, rendering options and shadow option in a couple of plugins
but I could never work that one out...
styles = Sketchup.active_model.styles p styles.selected_style == styles.active_style # => false p styles.selected_style.name == styles.active_style.name # => true
and
p [styles.selected_style, styles.active_style] # => [#<Sketchup;;Style;0x007ff13ba9a590>, #<Sketchup;;Style;0x007ff13975fb20>] p [styles.selected_style.name, styles.active_style.name] # => ["[Default Style]", "[Default Style]"]
I'll see if I can find my revert style code...
-
finally found the bit I was after...
I grab the active style and collect the missing values...styles = Sketchup.active_model.styles @count = styles.count sty = styles.active_style @revert = 0 @i = 0 styles.map{|s| @i = @i+1 @revert = @i-1 if s.name == sty.name } # collect items not covered by Style options... sun4 = Sketchup.active_model.shadow_info["UseSunForAllShading"] shad = Sketchup.active_model.shadow_info["DisplayShadows"] dark = Sketchup.active_model.shadow_info["Dark"] light = Sketchup.active_model.shadow_info["Light"] faces = Sketchup.active_model.shadow_info["DisplayOnGroundPlane"] ground = Sketchup.active_model.shadow_info["DisplayOnAllFaces"]
then at the end of my async loop that changes styles and makes an image I use
styles.selected_style = styles[@revert] Sketchup.active_model.shadow_info["UseSunForAllShading"] = sun4 Sketchup.active_model.shadow_info["DisplayShadows"] = shad Sketchup.active_model.shadow_info["Dark"] = dark Sketchup.active_model.shadow_info["Light"] = light Sketchup.active_model.shadow_info["DisplayOnGroundPlane"] = ground Sketchup.active_model.shadow_info["DisplayOnAllFaces"] = faces
to put it back as it was...
-
@dan
what's not working?model = Sketchup.active_model pages = model.pages page = pages[0] rendering_settings = page.rendering_options.to_a
returns the full enchilada...
and shadow info appears to work on page as well...shadow_settings = page.shadow_info.to_a
can you post a failing snippet I can test on my mac?
john
-
@driven
Thanks for your samples. It would seem that the Active Style is a structure to hold the current options set interactively (and normally in rendering_options and Shadow_info), whereas the Selected Style only corresponds to styles stored in the model and coming from files. But as the API to styles is very poor, there is little chance that anything useful can be done.@Dan
Page.rendering_options
seems to work OK in SU15, even if it does not map all the parameters of styles.Fredo
-
I am going from memory. This was several versions back, may have been while Google still owned SketchUp.
What I was trying to do was SET rendering options/styles that were unique to each page.
I was told (if I remember correctly) is that since Styles were invented, you have to use style files.
I responded that (generalizing) this was cumbersome if I only wished to change a few options on each page.
@fredo6 said:
page.rendering_options
seems to work OK in SU15...It did for me, also in that older version. But setting things (different than the model settings,) and having them remembered seems to be the issue.
Notice how in the Scene Manager, there is no checkbox for "rendering options"
Setting the
page.use_rendering_options=true
has no effect.
For the shadow_info, there an additional flag that must be set true, to make the changes remembered.
page.use_shadow_info= true page.update
-
I asked someone on the SketchUp development team last year (I think, could have been before,) about the
page.rendering_options
not working.They said it was replaced with styles when styles were invented. And that the API docs were erroneous with respect to setting rendering options on pages. (It should say that they do not work when attempting to make settings on pages.)
To which I responded that made no sense, as nothing much of the
Style
class had been exposed. Why would take away API functionality? And the response was something vague, about future plans that never happened. -
Sorry Fredo for the late reply. I just looked up the source for this. Though it looks like you deduced this yourself, here's confirming it:
selected_style refer to the style selected in the Style browser. However, the user might have modified that style after selecting it. So it's properties doesn't reflect what's being used in the viewport.
active_style refer to the "working" style.
The API interface is a reflection off the underlying system. But it's certainly awkward. Better documentation and examples are needed. And I guess there is a need for some new API methods.
-
thomthom,
thsanks very much.
So active_style is finally not useful, as we cannot do anything with it.
Fredio
-
api definitely needs some development here, you cannot even do a style.erase command. (just purge)
i looked inside a *.style file (aka zip), hoping to find some hints. some obscure numbers which surely must be pointing to the settings like face colours etc, but too cryptic.
not to mention watermarks.
Advertisement