Change the model view to Wireframe with Ruby API

Hello everyone, before inserting into the model of SkUp, a component created with the Ruby… I would like to change the view in wireframe with code Ruby API, is possible ?
Thank you
Joseph.

Yes … use the RenderingOptions object.

I think the key you need to access is "RenderMode" and the value is 0 for Wireframe mode.

opts = Sketchup.active_model.rendering_options
@old_mode = opts["RenderMode"]
opts["RenderMode"]= 0

Example methods (for a plugin module) …

def save_render_mode
  @old_mode = Sketchup.active_model.rendering_options["RenderMode"]
end

def restore_render_mode
  Sketchup.active_model.rendering_options["RenderMode"]= @old_mode if @old_mode
end

def set_render_mode_wireframe
  save_render_mode()
  Sketchup.active_model.rendering_options["RenderMode"]= 0
end
2 Likes

Hello, thank you for your help, now I’m going to study the code…
I tried to write the word “Wireframe” in the search field
Ruby API’s online documentation, I didn’t get any results,
so I asked for help in the forum…
Thank you again

Joseph.

Wireframe

Wireframe_1

Wireframe_2

The API search only searches for classes or methods or files. It’s more of a quick navigation than a typical search. You can google “SketchUp API” + phrase to find that phrase in the API documentation.

OK…
:stuck_out_tongue_winking_eye: :stuck_out_tongue_winking_eye:
:+1: :+1:

Mr. DanRathbun, please, one more thing…
but where can I find the access keys to change “RenderMode”…
Wireframe value type = 0

Thank you

Joseph.

"RenderMode" is a key of the RenderingOptions (hash-like) object.
(All the keys are listed in the Overview section of the RenderingOptions class documentation.)

I think you may mean … ‘What are the valid values for the "RenderMode" key"?’

The values for enumerations (keys that have ordinal values) are not documented in the API documentation (yet.) These ordinal values are sometimes called “magic numbers”.

A documentation issue was opened over a year ago … ie:


Do not set "RenderMode" to 4 !! (Crashes versions of SketchUp 2017…2019.1, fixed in v2019.2.)

"RenderMode" values
0 = Wireframe
1 = Hidden Line
2 = Shaded
3 = Shaded ?
4 = Do not use! obsolete (Crashes SketchUp versions 2017.0…2019.1)
5 = Monochrome
6+ Do not use! (Crashes SketchUp versions 2017.0…2019.1)

"Texture" values
true = Show textures in shaded render modes
false = No textures in shaded render modes

"DrawBackEdges" values
true = Show (hidden) Back Edges in most render modes
false = Do not show (hidden) Back Edges in any render mode
(Hidden Back Edges have no effect for Xray or Wireframe render modes.)

"ModelTransparency" (Xray) values
true = Xray transparent faces in most render modes (except Wireframe mode.)
false = Normal opaque faces in render modes (except Wireframe mode.)

1 Like

Thank you again

Joseph.

:+1: :+1:

1 Like