Error - while adding custom attributes through ruby

i am trying to add of list of custom attributes through ruby for a dynamic component (a small cube).

The coding was done based on the reference from the thread

attached herewith
test.rb (20.1 KB)
Error msg in dynamic component attributes window

Error msg in ruby console window

Image of Attributes Inspector

Seems the attributes are attached to the model. but not displayed in the component attribute window
Pls advice!

(1) Do you have the latest Dynamic Components extension installed for your version of SketchUp ?

(2) ALL the default dynamic attributes are attached to the component definition’s "dynamic_attributes" dictionary.

When a DC component instance gets created, only a few normal “housekeeping” dynamic attributes are attached to the instance and then as the user makes changes, if the attribute values differ from the defaults stored in the component definition’s "dynamic_attributes" dictionary, then the instance will get these “override” attributes created in it’s own "dynamic_attributes" dictionary.

Butnested DC groups always have ALL their dynamic attributes attached in the group instance’s "dynamic_attributes" dictionary.

They will be IF you’ve directly opened a DC component skp file, because in this case the model is the component.

test_repair.rb (20.8 KB)

s.set_attribute “dynamic_attributes”,"_c2_material_door_use_idbanding_formulaunits", “NOT REQUIRED”
is in error, and is really not required

You should consider making a few functions and constants as Dan showed you previously. Saves a lot of work

yes that was an error. thanks.
Noted your comments on the re-modified code.


yes i installed the latest extension of DC.
Thanks for the comments.

1 Like

Continuing on this thread, the dynamic custom attributes are unusable for editing even though in the component definition.
Attached herewith the file and image for the reference.
where the attributes are displaying full name, while linking or referenced in other attribute.
Also shows as undefined.
is this the nature of the DC, when the attributes are imported through the ruby code.?

Untitled01.skp (60.8 KB)

I don’t know. Perhaps it is a bug in the latest version ?
You could try rolling back to an earlier DC version.

As said many times elsewhere, Dynamic Components is a proprietary, closed-source native extension for SketchUp (whose intellectual property belongs to Trimble, Inc.)

Using Ruby code to create DC components is basically “hacking”. It requires guru level knowledge and ability in Ruby, SketchUp and Dynamic Components. There is no handbook or programmer’s reference to “hacking” DC components. (Sorry.)

That said, I do not know what you are doing that is giving you issues. I do not have the time to figure it out.

You are on your own. All I can suggest is that you do something manually using the native DC interface dialogs, and then examine the “dynamic_attributes” dictionaries using Aerilius’ Attribute Inspector to see the results that are normal hidden from users. After changes, always examine both the definition and instance.

Ok. Thanks :+1: