sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Modifying or extending SU native tools

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 3 Posters 1.1k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A Offline
      ArunYoganandan
      last edited by

      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&nbsp;</span><span class="syntaxdefault">MySelectionTool&nbsp;</span><span class="syntaxkeyword"><&nbsp;</span><span class="syntaxdefault">SelectionTool<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;def&nbsp;initialize</span><span class="syntaxkeyword">()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">super</span><span class="syntaxkeyword">()<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">end<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;def&nbsp;draw</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">view</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxcomment">#&nbsp;Do&nbsp;my&nbsp;own&nbsp;thing&nbsp;here..<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">end<br /><br />end</span>
      

      Any suggestions or insight would be appreciated.

      Thanks
      Arun

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        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...

        TIG

        1 Reply Last reply Reply Quote 0
        • Dan RathbunD Offline
          Dan Rathbun
          last edited by

          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 the Sketchup::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.

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • A Offline
            ArunYoganandan
            last edited by

            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!

            1 Reply Last reply Reply Quote 0
            • Dan RathbunD Offline
              Dan Rathbun
              last edited by

              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.

              I'm not here much anymore.

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              Buy SketchPlus
              Buy SUbD
              Buy WrapR
              Buy eBook
              Buy Modelur
              Buy Vertex Tools
              Buy SketchCuisine
              Buy FormFonts

              Advertisement