Add entity to an existing component

Hi guys,

I have this furniture (a DC component):

Now need to create a face and add that face to the context, but don’t know how to do that.
I’ve tried:

ent = Sketchup.active_model.selection.first

x = ent.transformation.origin.x
y = ent.transformation.origin.y
z = ent.transformation.origin.z

p1 = [x + 0.01, y + 0.01, z + 0.01]
p2 = [x + 0.11, y + 0.01, z + 0.01]
p3 = [x + 0.11, y + 0.11, z + 0.01]
p4 = [x + 0.01, y + 0.11, z + 0.01]

face = ents.add_face(p1, p2, p3, p4)
instance = Sketchup.active_model.entities.add_group(face).to_component
instance.hidden = true
sel.add(instance)

ent.explode.each do |e| 
  sel.add(e) if e.is_a?(Sketchup::ComponentInstance)
end
ents.add_group(sel).to_component

The result is exactly what I need:

But, I can’t explode the entity, because when I do that, the entity lose all formula references.
Then when I resize the furniture:

Is there another way to do that?

Thanks.

Add the things directly to the Definition’s Entities.

Sketchup.active_model.selection[0].definition.entities.add_whatever(...)`

2 Likes

Ahhh, alright… I’ve tried that before, but having some trouble with a each loop.

Many thanks.