Pick vertex?
-
I want to be able to pick a vertex, how would I do that? The pickhelper doesn't seem to return vertices.
Also, I got this little test code:
def pick Sketchup.active_model.select_tool Stix.new end class Stix #def self.onMouseMove(flags, x, y, view) # #end def onLButtonUp(flags, x, y, view) ph = view.pick_helper ph.do_pick(x, y) picked = ph.all_picked puts 'picked;' puts picked end endWhen I group a cube and click on a point that would be a vertex, all_picked return the group multiple times.
picked; #<Sketchup;;Group;0x88c5ce0> #<Sketchup;;Group;0x88c5ce0> #<Sketchup;;Group;0x88c5ce0> #<Sketchup;;Group;0x88c5ce0> #<Sketchup;;Group;0x88c5ce0> #<Sketchup;;Group;0x88c5ce0>As oppose to this when it's not grouped, or inside the group.
picked; #<Sketchup;;Edge;0x8851fe8> #<Sketchup;;Edge;0x8851fd0> #<Sketchup;;Face;0x88545b0> #<Sketchup;;Edge;0x88545e0> #<Sketchup;;Face;0x8851fb8> #<Sketchup;;Face;0x88545c8>I had expected it to list the group as well as the edges and faces inside it.
How come I get this result? What's the point in returning the same group multiple times?
-
You should use an InputPoint instead, if you are just interested by the vertex.
ip = Sketchup;;Input.point.new ip.pick view, x, y vertex = ip.vertex #or nil if none edge = ip.edge #or nil if none face = ip.face #or nil if none #use tr * ip.position to have the absolute coords if your vertex is embedded # in groups or components tr = ip.transformationredo
-
Ah! Thanks Fredo!
If it's nested in multiple groups, do I have to do transformation * transformation on all groups first?
group1.transformation * group2.transformation * ip.position? -
Still curious to why pickhelper returns the group so many times though...
-
No, just use ip.transformationto get the coordinates in the current active_model (it is cumulative).
You don't have to use the pickhelper, except if you want to know more about the hierarchy of groups and components.Fredo
-
Thanks allot, once more.

Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement