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

How to do a crossing box select by ruby?

Scheduled Pinned Locked Moved Developers' Forum
6 Posts 4 Posters 244 Views 4 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.
  • B Offline
    bigcatln
    last edited by 22 Nov 2011, 14:16

    I want to make a script that do crossing box select just like what select tool in Sketchup do ,but I can't find a good method to do it.
    I did it by PickHelper firstly,but it only can pick from a point,while now I need pick from a retangle ,how can I do that?
    any idea?

    thanx in advance

    1 Reply Last reply Reply Quote 0
    • J Offline
      Jim
      last edited by 24 Nov 2011, 11:27

      You would use the Tool class.

      The onMouseMove() method is passed the x, y screen coordinates of the mouse which you can use View #draw2d method to draw the temporary box on screen.

      Hi

      1 Reply Last reply Reply Quote 0
      • T Offline
        TIG Moderator
        last edited by 24 Nov 2011, 11:31

        Thereafter your troubles will only increase... then you need to find everything inside that 'box' [or perhaps intersecting the box] depending on whether or not the picking is left-right or right-left - just like the Select tool... Why not get the user to 'preselect' the required objects and then run your code on that selection ?

        TIG

        1 Reply Last reply Reply Quote 0
        • J Offline
          Jim
          last edited by 24 Nov 2011, 11:36

          Hmmm, I seem to be missing something.

          How do you use the 2d screen coordinates to draw the rubber-band box? It looks like the View#draw2d method takes Point3d objects rather then screen coordinates. Are the docs wrong?

          Edit - The docs aren't wrong, I just didn't read them through. 😳
          @unknownuser said:

          The second parameter is an Array of Point3d objects (or several individual Point3d objects). These Point3d objects are in screen space, not 3D space. The X value corresponds to the number of pixels from the left edge of the drawing area. The Y value corresponds to the number of pixels down from the top of the drawing area. The Z value is not used.

          So you can use an Array: [x, y] for the 2nd parameter, which should work.

          Hi

          1 Reply Last reply Reply Quote 0
          • B Offline
            bigcatln
            last edited by 24 Nov 2011, 12:55

            @tig said:

            Thereafter your troubles will only increase... then you need to find everything inside that 'box' [or perhaps intersecting the box] depending on whether or not the picking is left-right or right-left - just like the Select tool... Why not get the user to 'preselect' the required objects and then run your code on that selection ?

            In fact I did preselect object!
            I am making a trim tool which use a number of groups trimmed by another number of groups
            So I need select a number of groups first then select my tool ,and then select another number of groups, put return key to do the trim at last.
            that need select groups while my tool is still active. and I want the select operation just like what the select tool do.

            1 Reply Last reply Reply Quote 0
            • T Offline
              thomthom
              last edited by 24 Nov 2011, 13:01

              You could perhaps do a simplified version and map the boundingbox of the groups to a cached array, then use Geom.point_in_polygon_2D to see if any of the points are within the selectionbox of your custom tool. It will miss the cases where a selectionbox crosses the group's boundingbox but the corner points are outside, but if you start to do intersection on all that you might very well end up with a sluggish tool. Might be good enough?

              Thomas Thomassen — SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

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

              Advertisement