My attempt has been as following:
- Tried to create an IfcProfile using
ifcopenshell.api
.
Looked here:
Read the BS documentation:
- Tried to create a IfcBeamType instance with IfcMaterial:
import ifcopenshell.api
element_name='my_beam'
ifc_file = ifcopenshell.api.run("project.create_file")
project = ifcopenshell.api.run("root.create_entity", ifc_file, ifc_class="IfcProject", name="BlenderBIM Demo")
ifcopenshell.api.run( "project.assign_declaration", ifc_file, definition=project, relating_context=project)
ifcopenshell.api.run("unit.assign_unit", ifc_file, length={"is_metric": True, "raw": "METERS"})
material = ifcopenshell.api.run("material.add_material", ifc_file, name='beam_material')
element = ifcopenshell.api.run("root.create_entity", ifc_file, ifc_class='IfcBeamType', name=element_name)
profile_1 = ifcopenshell.api.run("material.assign_material", ifc_file, product=element, type="IfcMaterialProfileSetUsage")
profile_set = profile_1.RelatingMaterial
profile_2 = ifc_file.create_entity("IfcMaterialProfile")
ifcopenshell.api.run("project.assign_declaration", ifc_file, definition=element, relating_context=project)
ifc_file.write("D:\\02_ifc\\ifc_bibliotheek\\" + str(element_name) + ".ifc")
Quite clueless on how to tie it all together, this script just outputs this:
ISO-10303-21;
HEADER;
FILE_DESCRIPTION(('ViewDefinition[DesignTransferView]'),'2;1');
FILE_NAME('/dev/null','2022-11-06T11:31:03+01:00',(),(),'IfcOpenShell v0.7.0-cdde5366','IfcOpenShell v0.7.0-cdde5366','Nobody');
FILE_SCHEMA(('IFC4'));
ENDSEC;
DATA;
#1=IFCPROJECT('3NWCe2Fg16oO7d$m1LJcmY',$,'BlenderBIM Demo',$,$,$,$,$,#6);
#2=IFCRELDECLARES('0WOKmCVaz6$QsPWDCFj_FP',$,$,$,#1,(#8,#1));
#3=IFCSIUNIT(*,.LENGTHUNIT.,$,.METRE.);
#4=IFCSIUNIT(*,.AREAUNIT.,$,.SQUARE_METRE.);
#5=IFCSIUNIT(*,.VOLUMEUNIT.,$,.CUBIC_METRE.);
#6=IFCUNITASSIGNMENT((#4,#5,#3));
#7=IFCMATERIAL('beam_material',$,$);
#8=IFCBEAMTYPE('2CPnfvwOT6O9ZQyImvzlxU',$,'my_beam',$,$,$,$,$,$,.NOTDEFINED.);
#9=IFCMATERIALPROFILESET($,$,$,$);
#10=IFCMATERIALPROFILESETUSAGE(#9,$,$);
#11=IFCRELASSOCIATESMATERIAL('0LU7BOA5v1h9_90260WfJ0',$,$,$,(#8),#10);
#12=IFCMATERIALPROFILE($,$,$,$,$,$);
ENDSEC;
END-ISO-10303-21;
Somehow I need to define the IfcParametrizedProfileDef somewhere, hardcoded the X and Y dimensions, say to the IfcBeamType instance, you are now using an IfcProfile..
Is there a very simple example script somewhere?