@tiktuk said:
@thomthom said:
I'm guessing it refer to line 58. I'm pretty sure it's because you make the containing group after you make the child entities. Refactor the code so you always create the container first - and then add the entities to the container.
strut = create_strut edge, center, size frame_group.entities.add_group strut
I think you are onto something there. I just noticed that I am creating an extra group in that line, that I don't want or need. create_strut is already returning a group and I have used add_group strut to add that group to my frame_group but while doing that I am creating another group.
How do I add an existing entity (a group in this instance), to an existing group? I can't find any methods for that.
I'm not aware of any way to do this directly. If it's a group you want to add you can say:
new_group.entities.add_instance original_group.entities.parent
(original_group.entities.parent will give you the original group's definition, so you add it like you're adding a component instance)
as far as adding individual items to a group, you can do it this way, but it's a little iffy:
entities_i_want_to_add = [] #array of entities you want to add to the new group
new_group = entities.add_group entities_i_want_to_add
then I guess you could find the definition of this new group and add it to whatever entities collection you want, then explode the original
The most foolproof way to add entities to a group is to add the raw geometry using Entities.add_edges and Entities.add_face. You'd also need to copy the materials and any attributes you wanted to go along with them.