How to add attribute into component option using ruby?


hello …
i want to add some attribute to option component is there any materials for that


Component Options are not directly entity attributes, but a GUI with its own features, called “component options”.

If you want to access the underlaying entity attributes, you need to know the attribute dictionary names and attribute names. These are not displayed in Component Options. You need a tool for displaying entity attributes, like Attribute Helper, Eneroth Attribute Editor or Attribute Inspector.


And then read up on these …

Also note that there are some options that are not allowed to be set via Ruby. (Multiple choice select options.)


Anyone interested in working with BIM and IFC in SketchUp may benefit from reading this topic thread …


The attributes pointed to in that screenshot is related to Classifications. While you can read/write these manually with the generic get/set_attribute methods, you would have to know exactly how they are organized.

While dealing with classification attributes you should use the Classifiction API:


The native export to ifc is still broken:


i also trying to do same your work … so i wondering if can i add sub attribute dictionary to attribute dictionary because i searched to found any api can do this job, but all api i found that can used to add key and its value to a dictionary , so i want to add sub dictionary in IFC 2x3 dictionary like in image below and the sub dictionary contains a number of keys with them values

best regards


You would have to have xml writing software and make your own schema or .SKC file:


Yes you can.

The Sketchup::AttributeDictionary class is a subclass of Sketchup::Entity.

ANY Sketchup::Entity subclass can have a collection of Sketchup::AttributeDictionary instances.

a. As a subclass of the Sketchup::Entity class, the Sketchup::AttributeDictionary class inherits functionality from Sketchup::Entity, because it is one of it’s ancestor classes.

At the Ruby console …

#=> [
 Sketchup::AttributeDictionary, Enumerable, Sketchup::Entity,
 Object, PP::ObjectMixin, JSON::Ext::Generator::GeneratorMethods::Object,
 Kernel, BasicObject

b. The SketchUp API documentation for the Sketchup::AttributeDictionary class, clearly lists the methods that are inherited from it’s ancestor, the Sketchup::Entity class, viz:


The API documentation only lists methods inherited from API ancestor classes.
To see the methods from Core Ruby classes refer to the Core Ruby documentation …


(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)


i used set_attribute “dictName” , “key” , “value”
this method used to adding key in dictionary “dictName” And that is what I do not want
i want to add nested dictionary to parent dictionary for example i have dictionary called parent and other one called child , i want to add child dictionary to parent then adds keys to child by using set_attribute “child” , “x” , “y”
can that happens or i have misunderstand


I answered the question above …

To create the child dictionary, either …

create = true
child_dict = parent_dict.attribute_dictionary( "child", create )
child_dict["x"]= "y" #=> "y"

… or …

parent_dict.set_attribute( "child", "x", "y" ) #=> "y"
child_dict = parent_dict.attribute_dictionaries["child"]