Thanks Jim. Your intuition was right - a call from within a function worked. It's annoying that the API isn't a little clearer about this but I am a noob and there are many things that remain unclear to me.
🏢 PlaceMaker | 25% off for February including new Google Earth data imports!
Learn more
H
Latest posts made by hanks
-
RE: Observer Usage
-
Observer Usage
This may be a stupid question to some of you wizards, but can anyone tell me why this code does not work when pasted into a .rb file and dropped into the plugins directory?
straight out of the API...
# This is an example of an observer that watches tool interactions. class MyToolsObserver < Sketchup;;ToolsObserver def onActiveToolChanged(tools, tool_name, tool_id) UI.messagebox("onActiveToolChanged; " + tool_name.to_s) end end # Attach the observer. Sketchup.active_model.tools.add_observer(MyToolsObserver.new)
This is the resulting error...
@unknownuser said:
Error Loading File section_view.rb
undefined method `tools' for nil:NilClassThe script works perfectly however if I call the last part manually using the Ruby Console...
Sketchup.active_model.tools.add_observer(MyToolsObserver.new)
I suspect that my inability to understand this line of the class intro from the API is why I'm lost...
@unknownuser said:
To implement this observer, create a Ruby class of this type, override the desired methods, and add an instance of the observer to the Tools object.
WTF does override the desired methods mean!!??