How to get a selected object center?
-
I Want to get a object center point, the object may be a mesh,face,or group.my method is
UI.add_context_menu_handler do |context_menu| context_menu.add_separator context_menu.add_item("center point") { model = Sketchup.active_model entities = model.active_entities first_entity = entities[0] bbx=first_entity.bounds # selection = model.selection # # selection.each { |entity| # $boundbox = entity.model.bounds # UI.messagebox($boundbox.corner 0) # UI.messagebox($boundbox.corner 1) # # } # puts selection.count # puts $boundbox.center puts bbx.center.to_sbut the result is always the same,would tell me why? thank u
-
because you are finding the bounding box for the first entitiy in the list of entities. What you want is to find the bounding box of the first entitiy in the selection set I would bet.
model = Sketchup.active_model sel = model.selection first_entity = sel[0]try that
-
@chris fullmer said:
because you are finding the bounding box for the first entitiy in the list of entities. What you want is to find the bounding box of the first entitiy in the selection set I would bet.
model = Sketchup.active_model sel = model.selection first_entity = sel[0]try that
i got it ,thank u
~
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