IFC Export - labelname sync definition

Just a few things in advance.
It is important that you post the Ruby code correctly on this forum so that it is readable.

If you want to do more with Ruby scripting in SketchUp or perhaps extension development, it is important to learn how to program with Ruby. Here are a number of useful links that give you more information



The SketchUp Developers website explains more about how to get started with the Ruby API.


The SketchUp Developers website explains more about how to get started with the Ruby API.

Now coming back to your questions.
You can package this script as an extension so that you can “start” it using a button in the toolbar.
And you can also enter other parameters automatically, but then you have to change the path.
See here the documentation from the Ruby API regarding the assignment of classification values.

In addition, I see a number of errors in the code.

I expect you will want to read the material of the component? In that case you have to read the material from the component instance of the definition. Multiple instances of a definition can each contain a different material.

And you must also pay close attention to how you describe the values ​​in the path. This is case sensitive!

Change this piece of code

path = ['IFC 2x3', classify_type.to_s, 'Name', 'IfcLabel']
definition.set_classification_value(path, definition.name)

Into this

path = ['IFC 2x3', classify_type.to_s, 'ObjectType', 'IfcLabel']
definition.set_classification_value(path, definition.instances[0].material.display_name.to_s)

In this case you read the material name from the first component instance of the relevant definition.
The ObjectType IfcLabel will now contain this value.

1 Like