[Bug] Add_group inside a component
-
@matt666 said:
However I think it's the
.add_group
function is bugged...Well, there sure is something about it, as the manual says: http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/entities.html#add_group
@unknownuser said:
NOTE: calling add_group with entities in its parameters has been known to crash SketchUp. It is preferable to create an empty group and then add things to its Entities collection.
Though, how you go about not providing entities to the method's argument, I don't know. http://www.sketchucation.com/forums/scf/viewtopic.php?f=180&t=17153
-
@matt666 said:
I tried to create a group of all entities from the definition, and it create the group on the origin of the definition. And when you close the drawing, it bugs. So when you try this
'component.definition.entities.add_group(sub_component)'
and you aren't inside this component on your model space, it bugs.Exactly the same as what I see. Wonder if we could summon a SU developer to provide some feedback.
-
# get the required component-definition and the required transformation... g1 = model.active_entities.add_group g1ents = g1.entities g1ents.add_instance(component_definition,transformation) g1ents.add_line([0,0,0],[1,1,1]) # this adds a component, then an edge... # you can even add a group inside a group thus... g2 = g1ents.add_group triangle_face= g2.entities.add_face([0,0,0],[1,0,0],[0,1,0]) # etc etc...
...
-
How would you add existing geometry to a group though TIG? There is no
entities.add_existing_entities
method. ornew_ents = entities.copy!
or anything. -
@chris fullmer said:
How would you add existing geometry to a group though TIG? There is no
entities.add_existing_entities
method. ornew_ents = entities.copy!
or anything.model=Sketchup.active_model g1=model.active_entities.add_group ### initially empty g2=model.entities.add_group(model.selection) ### or any other 'list' of miscellaneous geometry, ### text, instances, groups, dims etc g1.entities.add_group(g2) g2.explode ### if required... ### misc stuff moved into a group. ### I know you can skip making g1 and just use g2 ### but here g1 is either 'pre-existing' or needed later... ### OR ### to copy items into a group, rather than move them ### into a group you can use... g1=model.active_entities.add_group ### initially empty g2=model.entities.add_group(model.selection) ### as above... g3=g2.copy g2.explode ### to restore originals back as they were... g1.entities.add_group(g3) g3.explode ### if required... ### more misc stuff copied into a group. ### I know you can skip making g1 and just use g2 and g3 ### but here g1 is either 'pre-existing' or needed later...
...
-
So the problem isn't with adding existing geometry to a group, it is with adding geometry to a group that is nested.
Seems like it should be quite possible then to find all nested components. Then find the deepest one. Then add its existing geometry to a new group created inside the component. Then explode the outer componentinstance. Thanks TIG (again and again and again)
Chris
-
Adding entities to a definition is bug ridden... you can try...
g1=model.active_entities.add_group(model.selection) component=instance.definition g=component.entities.add_group(g1) g.explode g1.explode
to give you 'loose' stuff inside the component definition...
BUT when it Bug-splats it's NOT my fault !
It doesn't work because it's trying to move these grouped entities from their parent - the model - into the definition, which itself is another 'parent'. You CAN add new geometry or a group into a definition, BUT then to do that you need to add each of these bits as brand-new geometry. It would be possible to 'copy the info' of each of the group's entities as base-level entities and then recreate them inside the definition bit-by-bit, and at the end you can delete the original items since they are 'moved' into the definition... However, that's a pretty complex task... Info for every group, mining down into it's components, then info for each face, its edges, its materials, its layer etc etc...
We need a 'definition.entities.adopt(array_of_another_parents_entities)' method to transfer to another 'parent' ? I don't have time to do it right now - has anyone go one ???
... -
... Google?
-
Work around...
I've go a half-baked script that might work. I'll post it in a separate thread soon...
... -
Aaah... Cool!
Advertisement