š” LightUp 7.1 | SketchUp's only real-time renderer that uses object-based rendering
Download Trial
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_s
but 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