I get the following code, after running, we can see that the time is changing with the timeline, but how should this change of time be used?For example, how do I take the hour h of a changing time in a module, which is still changing outside the module, and the formula h=h-8 is also changing along the timeline
class MyShadowInfoObserver < Sketchup::ShadowInfoObserver
def onShadowInfoChanged(shadow_info, type)
# puts "onShadowInfoChanged: #{type}"
Sketchup.active_model.active_view.invalidate
end
end
class ShadowTool
def initialize()
# Attach the observer.
Sketchup.active_model.select_tool(self)
end
def activate
# puts 'activate'
@observer =MyShadowInfoObserver.new
Sketchup.active_model.shadow_info.add_observer(@observer)
Sketchup.active_model.active_view.invalidate
end
def deactivate(view)
# puts 'deactivate'
Sketchup.active_model.shadow_info.remove_observer(@observer)
view.invalidate
end
def draw(view)
model = Sketchup.active_model
shadowinfo = model.shadow_info
@text = shadowinfo["ShadowTime"].to_s
view.draw_text([30, 30], @text, {size: 18, color: [80, 80, 80]})
end
end # tool
end
SW::ShadowTool.new
nil