Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
🫛 Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download
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
~
Advertisement