Hi there. I have and exporter plugin and I would like to know the value of “Color by Layer” in the Layers tray before exporting. I’m using this code, but the value is always returned as true even when it is unchecked. Am I looking in the wrong place? Thanks.
Can you verify the return value of the calls to SURenderingOptionsGetValue() and SUTypedValueGetBool()?
I’m going to guess that SURenderingOptionsGetValue() is returning SU_ERROR_INVALID_OUTPUT as you are not creating the SUTypedValueRef with SUTypedValueCreate(&valueref);
Furthermore, since you aren’t verifying that SURenderingOptionsGetValue() is succeeding with an SU_ERROR_NONE result, I’m guessing that SUTypedValueGetBool() is returning SU_ERROR_INVALID_INPUT as valueref is invalid. This would mean that value is never set, so you’re getting whatever happens to be in value at the time.
Don’t forget to call SUTypedValueRelease(&valueref) when you’re done with your SUTypedValueRef!
Hi, You’re absolutely correct and I should certainly check the SUResult more often. However now I noticed that the value only reflects an unmodified style. It is correct if SUStylesGetActiveStyleChanged is false. If you change it at runtime, SUStylesGetActiveStyleChanged is true, the UI display is updated, but the value of DisplayColorByLayer remains unchanged. I haven’t been able to find the ColorByLayer option for the Style in the API. Any Ideas? I can still mark as solved because you did correct my code.
There are only two properties exposed to the Ruby API, name and description.
Looking at the C API, the exposure is very premature. Some (but not all) of the Edge settings, the BackgroundColor, name, description, path, guid and the Watermark flag. There is a lot still unexposed!
As explained to me by Chris Fullmer, the Scene Page Rendering Options (hash / dictionary / property list - whatever you call it?) predated the invention of SketchUp Styles.
So when styles were implemented, the RenderingOptions for individual scene pages were “switched off” (so to speak.) If on the Ruby-side I try setting a particular scene page’s "DisplayColorByLayer" property to true it has the new true value, but does not apply to the view, nor does it apply to the scene page’s style.
(Ie, it is now a “silent fail” to prevent the raising of exceptions / errors in old plugins still “in the wild”.)
(In reality, on Windows at least, the SketchUp application model viewport is a singleton class Sketchup::View that all the scene pages share, and when changed from one page to another, this view is transitioned from the former’s camera and certain style settings, to the latter’s camera and certain style settings.)
So really the RenderingOptions are sort of “global” and apply to the current view object, regardless of what scene page is current.
Now, when I set the model’sRenderingOptions["DisplayColorByLayer"] property to true, it has the new true value, and does apply to the view, and does apply to the current scene page’s style. That scene page’s icon shows that it needs to be updated to keep this style change.
If I switch to my “Thumbnail” scene page, and back again, this property has reverted back to false. If I update the style before switching pages, then my “Work” scene page will still have "DisplayColorByLayer" set true.
ADD: Also, there is a boolean flag for each scene page whether to “use_rendering_options”.
Regardless of this setting for the individual scene page object, setting this page’s RenderingOptions["DisplayColorByLayer"] property still has no effect. (The “silent fail”.)
I also see that updating a current style has not yet been exposed (but this makes sense as the C API is not yet “runtime certified”. Making changes to the loaded model will corrupt the undo stack and eventually crash the SketchUp process.)