Selection !
-
im new in dev, im working on my first plugin.
i want to select 2 lines in way that when the method is called, u can only select lines
also u dont have free selection (u can select by clicking only - one by one entity )
because i need to retrieve the axis of the click to determine which endpoint or startpoint is closer to the axis click.i tried to do this on ruby console, but i got no success.
Sketchup.active_model.selection.each
but when i used "Sketchup.active_model.selection.clear" after i selected a line, it does work .i need guide plz , i couldnt get much from this :
http://www.sketchup.com/intl/en/developer/docs/ourdoc/selection -
The simplest way is to allow the user to select any entities. Just care only about those selected entities that are edges:
edges = Sketchup.active_model.selection.grep(Sketchup::Edge)
Let's say you now need to be sure there is a minimum of edges:
return UI.messagebox("You need to select two or more edges.") if edges.length < 2The cleanest way would be to implement your own tool class for selecting entities. You would use a PickHelper to get whatever is below the point that the user clicked, and only if it is an edge you would add it to an array or selection (actually you do not really need to add it to the real selection), and then draw/highlight what is selected.
Don't do this until you have enough experience.If something does not work, please give complete (and minimal!) examples and say what does not work. All I could say about
Sketchup.active_model.selection.eachis that it raises an error because it is an iterator method with missing block ("each" is not "edge").
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