How to get the center of a ComponentDefinition array?
-
I have an array of ComponentDefinition. I want to find the center of these ComponentDefinitions.
Maybe I should find the union bounds of these ComponentDefinitions, but I did not find the way
... Could any one help me? -
I don't understand the question. ComponentDefinitions doesn't exist in modelspace - so I do not see how you would get the centre of a collection of definitions.
Can you describe the abstract of what you are trying to do?
-
If you meant ComponentInstance then they each have bounds.
Make a new empty bounding-box object [bb], and then add each of theinstance.boundsto thatbb.add(instance.bounds).
The center isbb.center......... -
@thomthom said:
I don't understand the question. ComponentDefinitions doesn't exist in modelspace - so I do not see how you would get the centre of a collection of definitions.
Can you describe the abstract of what you are trying to do?
I'm sorry I made a mistake, the type is not ComponentDefinition, but a Group. I use the following code:
model = Sketchup.active_model;
groups = [];
model.definitions.each{|d| groups << d if d.group? }
name = "left_head"
pgrp = [];
groups.each{|d| pgrp << d.instances[0] if d.instances[0].name==name }
the type of gprp is Sketchup::Group.Actually, I want to get the center of a group with the group name "left_head", but there are several groups with the name "left_head", so I have to find the union bounding box of them.
-
@tig said:
If you meant ComponentInstance then they each have bounds.
Make a new empty bounding-box object [bb], and then add each of theinstance.boundsto thatbb.add(instance.bounds).
The center isbb.center.........Thanks for your tip. I will test the code.
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