sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Detecting Ctrl-[Move || Rotate]

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 2 Posters 248 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.
    • P Offline
      Pierreden
      last edited by

      Yo! Im trying to detect new entities added using the move or rotate tool while pressing Ctrl.

      Using the Meta Observer i can see that the ToolObserver, SelectionObserver and some Transaction Callbacks are triggered, but I just cant figure out how to detect the new geometry 😳 (for some reason the EntitiesObserver doesn't trigger when Ctrl-move or rotate πŸ˜’ )

      Can someone point me in the right direction?

      Peace out
      Pierre

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

        Before the Move or Rotate tool is used, the selection set will contain the "old" entities.

        When the user completes the CTRL Move or CTRL Rotate, the selection set will contain the "new" entities.

        Because the selection set changes, the onSelectionBulkChange callback in your Sketchup::SelectionObserver subclass instance should fire.

        Within your custom SelectionObserver's onSelectionBulkChange callback, you can check what the active tool id is:

        tool_id = Sketchup.active_model.tools.active_tool_id
        if tool_id == 21048
          # The Move tool was used.
        elsif tool_id == 21129
          # The Rotate tool was used.
        else
          # Some other tool was used.
        end
        

        BUT if the user did not use CTRL, then the selection set will still contain the original entities (but their transform may have changed.) In this case the onSelectionBulkChange callback may not fire (so this could be how you can detect the difference between a normal Move and a CTRL+Move, as well as a normal Rotate and a CTRL+Rotate.)

        I'm not here much anymore.

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

          Exception... after testing:

          If the user does NOT preselect items using the SelectionTool, but instead selects ONE item using the MoveTool or RotateTool, then when the process is complete (regardless whether they use the tool in normal mode or CTRL copy mode,) the selection set will be empty, ie:
          Sketchup.active_model.selection.count

          0

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • P Offline
            Pierreden
            last edited by

            Awesome, thats exactly what i needed!

            Have a great sunday!

            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