sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    View.pickhelper

    Scheduled Pinned Locked Moved Developers' Forum
    19 Posts 5 Posters 1.3k Views 5 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.
    • AdamBA Offline
      AdamB
      last edited by

      @thomthom said:

      "Query Object"?

      As in an object that encapsulates the query and all associated state into 1 handy 'thing'. It's a common pattern for picking / raytesting because you often want to make decisions about what your looking for as you walk through the results and don't necessarily want all answers/info - which can be large.

      The point being its not a simple procedural call. Its returning a result which is a first class object on which you can operate to get the answer you want.

      Adam

      Developer of LightUp Click for website

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        Sorry for being so dense, but I don't understand this at all.

        What's the difference between:

        ip = view.pickhelper ip.pick(x, y)

        and

        ip = view.pickhelper(x, y)

        ❓

        Why are they not the same, and what would the use of ip = view.pickhelper(x, y) be?

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

        1 Reply Last reply Reply Quote 0
        • thomthomT Offline
          thomthom
          last edited by

          Think there is some confusion to what people think I'm asking about.

          I'm not asking what the purpose of the PickHelper class is. But the difference in the examples in my previous post. The arguments of the method view.pick_helper that returns a PickHelper.

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

          1 Reply Last reply Reply Quote 0
          • AdamBA Offline
            AdamB
            last edited by

            @thomthom said:

            Sorry for being so dense, but I don't understand this at all.

            What's the difference between:

            ip = view.pickhelper ip.pick(x, y)

            and

            ip = view.pickhelper(x, y)

            ❓

            Why are they not the same, and what would the use of ip = view.pickhelper(x, y) be?

            pickhelper(x,y) is a convenience. But you may want to create a pickhelper (which holds all the state) and then do a series of .pick(x,y) calls.

            Developer of LightUp Click for website

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              Surely you can still do this?

              ` ip = view.pickhelper(x, y)

              ...

              ip.pick(n,m)

              ...

              ip.pick(i,j)`

              ip = view.pickhelper
              This returns a PickHelper object. Which you then later uses .pick with.

              ip = view.pickhelper(x, y)
              This also returns a PickHelper object - which you also can use to later call .pick with. But specifying x and y doesn't seem to make it pick - which I wonder if it is a bug?

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

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

                @thomthom said:

                I'm confused to where ORIGIN comes into this..?

                @tig said:

                To be honest I never use anything but a 'bare' pick_helper with no arguments and then a ph.do_pick etc....

                That's what I've do so far as well. Just looked like I could skip that last step - combine the two statements. But I'm not sure if it's a SU bug - or if the arguments for view.pick_helper works differently from what I'd expect.

                ORIGIN is a built-in global-variable like X_AXIS, Y_AXIS and Z_AXIS...........

                TIG

                1 Reply Last reply Reply Quote 0
                • Chris FullmerC Offline
                  Chris Fullmer
                  last edited by

                  I understand Thom, I always assumed it was a bug, or designed for something I did not understand. To make it easy on myself I've always used pickhelper without and parameters, and then use pick or dopick or whatever with parameters. You're not crazy.

                  Chris

                  Lately you've been tan, suspicious for the winter.
                  All my Plugins I've written

                  1 Reply Last reply Reply Quote 0
                  • thomthomT Offline
                    thomthom
                    last edited by

                    I couldn't find any bug reports on it - wanted to check. will submit a new ticket.

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

                    1 Reply Last reply Reply Quote 0
                    • thomthomT Offline
                      thomthom
                      last edited by

                      Reported as a bug. example script attached.


                      tt_picktest.rb

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

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

                        @thomthom said:

                        View.pick_helper
                        http://code.google.com/apis/sketchup/docs/ourdoc/view.html#pick_helper

                        @unknownuser said:

                        If you supply x and y, they are screen coordinates of the point at which you want to do a pick. Typically, there will be points that were passed to a method on a tool class.

                        From that I'm given the impression that I can do:
                        ip = view.pick_helper(x, y)
                        And it'd then return a PickHelper that's picked a point.
                        But that does not seem to work.

                        The API should probably say "If you supply x and y, they are screen coordinates of the point at which you will want to do a pick." (refering to the pick as a future event, yet to occur.)

                        @thomthom said:

                        If I do this:
                        ip = view.pick_helper ip.do_pick(x, y)
                        Then it works.

                        Because the description of PickHelper.do_pick states: "The do_pickmethod is used to perform the initial pick."
                        So, prior to this method getting called, the picklist should always be empty; and PickHelper.count should return 0.

                        @thomthom said:

                        Bug?

                        YES bug.

                        I think it either may have once worked and because of changes it no longer does, OR it was intended to work, but when the code for PickHelper class was written it wasn't possible, or someone forget the intention, etc. (perhaps more than one person was working on it and things got lost in the shuffle.)

                        What is supposed to happen when you call:
                        ph = view.pick_helper(x,y,apt) ?
                        I think something like this:

                        
                        class Sketchup;;View
                          def pick_helper(*args)
                            case args.size
                            when 0
                              Sketchup;;PickHelper.new()
                            when 1
                              raise ArgumentError,"x and y required", caller
                            else
                              Sketchup;;PickHelper.new().init(args)
                            end
                          end#def
                        end#class
                        
                        

                        @thomthom said:

                        • then what's the point of the arguments in the view_pickhelper method?

                        So the arguments for View.pick_helper were really 'intended' to be passed to PickHelper.init, so that you could then use either PickHelper.test_point or PickHelper.do_pick without having to again specify the x,y. Any method that takes an apeture would also use either the one set by .init or (as we are told in the API,) the "standard Sketchup aperture size".

                        However, PickHelper.do_pick always requires the two x,y arguments (regardless of whether .init was first called.)

                        And PickHelper.test_point, I cannot get to return true (regardless of whether .init was first called, or all arguments are specified.) Even when the point argument is exactly the same as the x,y .. still .test_point returns false.

                        p3.test_point [200,200],200,200,20
                        >> false
                        

                        _

                        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