I believe that a Dynamic Component wants there to be a component at it’s top level.
It can have both nested (child) dynamic group instances and dynamic component instances.
If you do not have your DC setup this way, the extension may not work properly.
Also, as I said previously, the DC extension is complex and has complex behavior.
Nested dynamic groups always have all dynamic attributes attached to an instance dictionary.
Nested dynamic components always have a dynamic dictionary attached to the definition that has all the default values. The nested dynamic component instances start out with only a few informational attributes in their dynamic dictionary, and may contain any overrides (deviations) from the default values in their definition’s dynamic dictionary.
Also, what the user sees as 1 dynamic property, is actually a set of dictionary attributes.
You also did not add the attribute for whether the user can see or edit them in the Options dialog.
The main mistake is that the code above is adding the DC attributes into a dictionary attached to an edge, and not to the group instance.
This code works when attaching the attributes to the group and not one of it’s edges:
module BoxTest
DCO ||= $dc_observers.get_latest_class
def self.makebox(x, y, z)
model = Sketchup.active_model
model.start_operation('Komponens létrehozása', true)
# Define an array of points:
points = [
Geom::Point3d.new(0, 0, 0),
Geom::Point3d.new(x.mm, 0, 0),
Geom::Point3d.new(x.mm, y.mm, 0),
Geom::Point3d.new(0, y.mm, 0)
]
# Add a group to the entities in the model:
group = model.active_entities.add_group
# Add the face to the entities in the group:
face = group.entities.add_face(points)
face.pushpull(-z.mm)
#
#entity1 = group.entities[1]
#puts entity1.inspect # <<----<<< it's an Edge !
#
# Set the DC attributes on the group instance:
group.set_attribute("dynamic_attributes", "summary", "testsummary")
group.set_attribute("dynamic_attributes", "name", "testname")
# Redraw the instance object:
DCO.redraw_with_undo(group)
model.commit_operation
end
end
BoxTest::makebox(100,100,100)