Implementing a tool is as simple as creating a class an implementing the methods.
Look at the linetool.rb in examples
class LineTool
def initialize
...
end
def activate
...
end
etc...
def onLButtonDown(flags, x, y, view)
...
end
...
end
As for why the observer method is returning odd values... no idea, I'll have to try it.
EDIT: I implemented a test observer and it works fine.
class MyTestObserver < Sketchup;;ToolsObserver
def onActiveToolChanged(tools, name, toolid)
puts tools.to_s + " " + name.to_s + " " + toolid.to_s
end
def onToolStateChanged(tools, name, toolid, xxx)
puts tools.to_s + " " + name.to_s + " " + toolid.to_s + " " + xxx.to_s
end
end
It ouput "#Sketchup::Tools:0x5c1b690 CircleTool 21096" to the ruby console.
You'll notice there is a fourth parameter for onToolStateChanged. The API is wrong; it doesn't list that parameter but without it there will be an error.