Working with: onRenderingOptionsChanged (rendering_options, type)

Hi,
I’m working with the Observers and I’m not able to find a correspondence table between the type parameter returned from the onRenderingOptionsChanged and the Sketchup::RenderingOptions.

For example, when I click on a Scene in my model,
image
I get a type == 0 (zero), how can I understand to what corresponds this value?

Tnks

  • type (Integer) —

A number indicating which option was changed represented by one of the constants defined in Sketchup::RenderingOptions.

I thought this but it doesn’t looks so. Maybe is a my mistake but when I try to access the Sketchup::RenderingOptions with a numeric key, I receive an error and if a I try to print the list of all Sketchup::RenderingOptions, the first one (at index 0) is BackgroundColor that is not what really is changing.
For example when I change the rendering_options[‘DisplayColorByLayer’], I get type = 16 from the Observer but in the list of Sketchup::RenderingOptions I have:

Where I’m wrong?

I’m just trying to understand, too.
If you’re curious about a change, I assume you know exactly which one it is. So you need to compare the returned “type” value with the corresponding constant. If the comparasion returning true, then you will know that corresponding option is changed. Then you can change or get the ( eg. rendering_option[key] = value )accordingly.

I don’t know exactly which constant means what, but it can be determined somehow…

For example if you put this to console:
Sketchup::RenderingOptions::ROPAssign
0
Sketchup::RenderingOptions::ROPDrawHidden
28

… but I’m stuck here now. :blush:

Yes, that’s the answear !
Sketchup::RenderingOptions::ROPSetDisplayColorByLayer returns 16 and this is what I aspect for!

Thank you!

1 Like

I made some test and I have this:

As you can see, I’m not able to match all items

1 Like

The rendering option names and the names in the style edit interface differ. (The names for the GUI changed over time, but the API remained the same.)

For example … Silhouettes = Profiles

Your constant names are incorrect.

opts = Hash[
  Sketchup::RenderingOptions.constants.sort.map {|c|
    [ Sketchup::RenderingOptions.class_eval(c.to_s), c ]
  }
]
require "pp"
pp opts
{
 0=>:ROPAssign,
 28=>:ROPDrawHidden,
 29=>:ROPDrawHiddenGeometry,
 30=>:ROPDrawHiddenObjects,
 31=>:ROPEditComponent,
 27=>:ROPSectionDisplayTurnedOff,
 12=>:ROPSetBackgroundColor,
 15=>:ROPSetConstructionColor,
 33=>:ROPSetDepthQueEdges,
 35=>:ROPSetDepthQueWidth,
 16=>:ROPSetDisplayColorByLayer,
 58=>:ROPSetDisplayDims,
 20=>:ROPSetDisplayFog,
 11=>:ROPSetDisplayInstanceAxes,
 39=>:ROPSetDisplaySketchAxes,
 57=>:ROPSetDisplayText,
 60=>:ROPSetDisplayWatermarks,
 62=>:ROPSetDrawBackEdges,
 54=>:ROPSetDrawGround,
 53=>:ROPSetDrawHorizon,
 55=>:ROPSetDrawUnderground,
 5=>:ROPSetEdgeColorMode,
 4=>:ROPSetEdgeDisplayMode,
 41=>:ROPSetEdgeType,
 8=>:ROPSetExtendEdges,
 18=>:ROPSetExtendLines,
 40=>:ROPSetFaceColor,
 9999=>:ROPSetFaceColorMode,
 23=>:ROPSetFogColor,
 24=>:ROPSetFogDist,
 25=>:ROPSetFogHint,
 59=>:ROPSetFogUseBkColor,
 13=>:ROPSetForegroundColor,
 52=>:ROPSetGroundColor,
 56=>:ROPSetGroundTransparency,
 50=>:ROPSetHideConstructionGeometry,
 14=>:ROPSetHighlightColor,
 6=>:ROPSetJitterEdges,
 34=>:ROPSetLineEndEdges,
 36=>:ROPSetLineEndWidth,
 19=>:ROPSetLineExtension,
 7=>:ROPSetLineStyleEdges,
 38=>:ROPSetLockedColor,
 43=>:ROPSetMaterialTransparency,
 42=>:ROPSetModelTransparency,
 64=>:ROPSetPhotomatchBackgroundOpacity,
 63=>:ROPSetPhotomatchDrawBackground,
 65=>:ROPSetPhotomatchDrawOverlay,
 66=>:ROPSetPhotomatchOverlayOpacity,
 9=>:ROPSetProfileEdges,
 10=>:ROPSetProfileWidth,
 37=>:ROPSetProfilesOnlyEdges,
 1=>:ROPSetRenderMode,
 44=>:ROPSetSectionActiveColor,
 49=>:ROPSetSectionCutFilled,
 48=>:ROPSetSectionCutWidth,
 46=>:ROPSetSectionDefaultCutColor,
 47=>:ROPSetSectionDefaultFillColor,
 26=>:ROPSetSectionDisplayMode,
 45=>:ROPSetSectionInactiveColor,
 51=>:ROPSetSkyColor,
 3=>:ROPSetTexture,
 2=>:ROPSetTransparencyObsolete,
 61=>:ROPSetXRayOpacity,
 32=>:ROPTransparencySortMethod
}

thanks Dan!