Modifying or extending SU native tools
-
Is there a way to extend/modify SU's native tools? like access the native tool's callbacks or methods. Or even inherit them to override or add to their behavior?
like
<span class="syntaxdefault"></span><span class="syntaxkeyword">class </span><span class="syntaxdefault">MySelectionTool </span><span class="syntaxkeyword">< </span><span class="syntaxdefault">SelectionTool<br /><br /> def initialize</span><span class="syntaxkeyword">()<br /> </span><span class="syntaxdefault">super</span><span class="syntaxkeyword">()<br /> </span><span class="syntaxdefault">end<br /> <br /> def draw</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">view</span><span class="syntaxkeyword">)<br /> </span><span class="syntaxcomment"># Do my own thing here..<br /> </span><span class="syntaxdefault">end<br /><br />end</span>
Any suggestions or insight would be appreciated.
Thanks
Arun -
Most times you must make a mimic of a native tool - see the linetool example script...
There is limited access to premade tools - e.g. running them.
However, the API does allow many aspects of the premade tools to be aped...PS: Please don't double post - as new member you must be patient... while you are processed and recognized as not being a spambot...
-
NO, sorry,.. at least not directly. The native tools are coded on the C++ side, and are not exposed as Ruby classes.
However.. the API does have observers, including a
Sketchup::ToolsObserver
(so you can do something when a native tool changes, ie, becomes active, or it's state changes;) and theSketchup::SelectionObserver
(so you can do something when the model's selection set changes, ie, is cleared, has items removed or added.)Many authors have both a tool and a series of observers that make up a plugin.
-
Sorry guys about the double post. After my first post, I wasn't sure if it went through. Now I understand.
I'm going to play around with the toolsobserver to see if it can help me and get back. Thanks for your help!
-
Most of the native tool ids are defined as global constants, that begin with "CMD_"
List them, at the Ruby Console:
Object.constants.grep(/CMD/).sort
The tool state integers vary from tool to tool, and some tools do not use them at all.
Advertisement