sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Handling advanced selection in a tool

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 2 Posters 1.0k Views 2 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.
    • I Offline
      ittayd
      last edited by

      I'm writing a tool in which I want a first step, then a step to allow the user to pick several entities and then more steps to manipulate them.

      The problem is how do I allow the user to select the entities? I tried handling entity and window selection with PickHandler, then added modifier keys handling for add/remove/toggle, now I'm about to handle open & close of groups... It just seems too cumbersome.

      Is there a way to utilize sketchup's own selection tool? So the user starts my tool, selects entities using the usual way and then gets back to my tool for the next steps. I can try reorganizing the tool so it expects a selection when it starts, but I want to see if I can do things the way I want.

      1 Reply Last reply Reply Quote 0
      • I Offline
        ittayd
        last edited by

        Just found Sketchup.send_action. Will try to explore it.

        1 Reply Last reply Reply Quote 0
        • I Offline
          ittayd
          last edited by

          So send_action is async, so the code that calls it returns immediately

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

            @ittayd said:

            Is there a way to utilize sketchup's own selection tool?

            The only way is to attach a SelectionObserver, activate SketchUp's native SelectTool Sketchup.active_model.select_tool(nil), collect the object references, detach the observer, and activate your tool.

            But trying to leverage native tools via code has been problematic in the past. So, this is why they finally added (SU2016) the two window pick methods to the PickHelper class.

            ThomThom wrote a tutorial and created a graphic helper chart for using this class.

            Link Preview Image
            PickHelper — A Visual Guide

            I’ve put together a visual guide to the PickHelper class in SketchUp’s Ruby API. When I first tried to use the PickHelper class I was confused over what the different methods did, and f…

            favicon

            Procrastinators Revolt! (www.thomthom.net)


            Other than that, you best learn by reading the example extension by the SketchUp Team (EW) or others like ThomThom's plugins.

            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