@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
_