How to add attribute into component option using ruby?


#1


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


#2

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.


#3

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.)


#4

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


#5

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:





#6

The native export to ifc is still broken:


#7

hello…
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


#8

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

https://help.sketchup.com/ja/sketchup/classifying-objects


#9

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.ancestors
#=> [
 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:

image

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 …


#11

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


#12

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"]

#13

Are you working with IFC data? Or are you adding arbitrary data not related to IFC?


#14

ya i working with ifc data , and i trying to solve any problem facing to me …
first problem faced me when import ifc file to sketchup layers and materials not imported inside sketchup , so i wrote some script to get layers and materials using ifcopenshell in python language and ruby to dealing with sketchup .
and now i working on how to add ifcPropertSet to any SU component