I want to generate the su model by ruby and save the ifc information at the same time.
That’s my code:
#1. create a group by l, b, h and transform group to component
l = 5000
b = 600
h = 800
model = Sketchup.active_model
entities = model.active_entities
status = entities.clear! #clear the entities!!!
group = entities.add_group
pts = []
pts[0] = [0, 0, 0]
pts[1] = [l, 0, 0]
pts[2] = [l, b, 0]
pts[3] = [0, b, 0]
face = group.entities.add_face(pts)
status = face.pushpull(h)
componentinstance = group.to_component
#2. get component's defination and add ifc classification. for example: IfcBeam
definition = componentinstance.definition
ifc_format = "IFC 2x3"
ifc_classification = "IfcBeam"
success = definition.add_classification(ifc_format, ifc_classification)
puts "ifc classification " + success.to_s
#3. define Ifc attributes
def setAndGetIfc(path, ifc_prop, definition)
definition.set_classification_value(path, ifc_prop)
success = definition.get_classification_value(path)
puts path.to_s + " " + success.to_s
return success, definition
end
#3.1 define component's name
definition.name = "beamTypeA"
componentinstance.name = definition.name + "-001"
#3.2 define component's type
path = ["IFC 2x3", "IfcBeam", "ObjectType", "IfcLabel"]
ifc_prop = "Steel Beam"
success, definition = setAndGetIfc(path, ifc_prop, definition)
#3.3 define ifc's name
path = ["IFC 2x3", "IfcBeam", "Name", "IfcLabel"]
ifc_prop = "workshop_beam_001"
success, definition = setAndGetIfc(path, ifc_prop, definition)
#3.4 define ifc's description
path = ["IFC 2x3", "IfcBeam", "Description", "IfcText"]
ifc_prop = "25 tons; crane beam"
success, definition = setAndGetIfc(path, ifc_prop, definition)
It can save the name, descritpion.
My question is: How to save my User-defined properties? For example, how to save the IfcBeam’s l, b ,h attributes.