When I try to get the value of rendering_options[‘RenderMode’] to use in the draw(view) method, the result is wrong and the draw(view) method is called 3 times every time the view is redrawn.
Below is the code to test:
class Tool
def activate
@model = Sketchup.active_model
@rendering_options = @model.rendering_options
@rendering_options['DrawBackEdges'] = true unless @rendering_options['DrawBackEdges']
# view.refresh (view.invalidate) to call draw(view) method
@model.active_view.refresh
end
def draw(view)
puts "Tool.draw(view)"
puts "@rendering_options['RenderMode']: #{@rendering_options['RenderMode']}"
end
end
Sketchup.active_model.select_tool Tool.new