If you're reading this, we've just migrated servers! If anything looks broken please email dion@thinkmoult.com :)

IfcOpenShell add an IfcClassificationReference

How do you add an IfcClassificationReference using the ifcopenshell.api?

Comments


  • @Moult
    Thanks! Works perfect! :-), I see it's even possible to get it from a classification file in your script.
    I now all create it from a CSV file

    Moulttheoryshaw
  • Is there any documentation for the ifcopenshell.api
    I found this:
    https://github.com/IfcOpenShell/IfcOpenShell/tree/v0.7.0/src/ifcopenshell-python/test/api
    But i would like to know if it's possible with the ifcopenshell.api to add a IfcBeamType instance with an IfcParametrizedProfile definition and if I there any examples available.
    Don;t really understand how to search in the link @theoryshaw gave

  • Found this:
    https://sourcegraph.com/search?q=context:global+beam+repo:^github\.com/IfcOpenShell/IfcOpenShell$+file:src/ifcopenshell-python&patternType=standard

    element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcElementAssembly")
    subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBeam")
    

    But don't understand how to create a profile

  • edited November 2022

    So far I managed to get to here

    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 = ifcopenshell.api.run("material.assign_material", ifc_file, product=element, type="IfcMaterialProfileSetUsage")
    profile_set = profile.RelatingMaterial
    
    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")   
    

    It outputs this:

    ISO-10303-21;
    HEADER;
    FILE_DESCRIPTION(('ViewDefinition[DesignTransferView]'),'2;1');
    FILE_NAME('/dev/null','2022-11-05T16:51:21+01:00',(),(),'IfcOpenShell v0.7.0-cdde5366','IfcOpenShell v0.7.0-cdde5366','Nobody');
    FILE_SCHEMA(('IFC4'));
    ENDSEC;
    DATA;
    #1=IFCPROJECT('29TuDR8$L3XhjCo8BJe6xp',$,'BlenderBIM Demo',$,$,$,$,$,#6);
    #2=IFCRELDECLARES('0g0T6yn6H939CEcN26MMcy',$,$,$,#1,(#8,#1));
    #3=IFCSIUNIT(*,.LENGTHUNIT.,$,.METRE.);
    #4=IFCSIUNIT(*,.AREAUNIT.,$,.SQUARE_METRE.);
    #5=IFCSIUNIT(*,.VOLUMEUNIT.,$,.CUBIC_METRE.);
    #6=IFCUNITASSIGNMENT((#5,#3,#4));
    #7=IFCMATERIAL('beam_material',$,$);
    #8=IFCBEAMTYPE('1h64ajpwTAIwRfMi8TTqV6',$,'my_beam',$,$,$,$,$,$,.NOTDEFINED.);
    #9=IFCMATERIALPROFILESET($,$,$,$);
    #10=IFCMATERIALPROFILESETUSAGE(#9,$,$);
    #11=IFCRELASSOCIATESMATERIAL('3pgzJhC5r8$90wUmyG78qs',$,$,$,(#8),#10);
    ENDSEC;
    END-ISO-10303-21;
    
    

    Clueless how to add a profile, but should be possible since there is a generated library made from BOLTS?
    @bernd Do you perhaps know how to create an IfcBeamType instance from with an IfcParametrizedProfileDef using IfcMaterialProfileSetUsage?

  • sorry I've never worked with ifc types in ifcos and python so far ...

  • @Coen
    stummbled over IfcClassificationReference as well and found this. Do you still use it? How does BIMCollab Zoom displays it? How about other viewers.
    ATM for us the classification is written in a normal text pset.property. I do not really know what is the advantage of using a separate ifc entity for this?
    cheers bernd

  • I do not really know what is the advantage of using a separate ifc entity for this?

    If I understand it correctly, the advantage is you could use external classificition files to reference IFC entities. From the BS documentation:

    The IfcClassificationReference can be used as a form of 'lightweight' classification through the 'ItemReference' attribute inherited from the abstract IfcExternalReference class. In this case, the 'ItemReference' could take (for instance) the Uniclass notation "L6814" which, if the classification was well understood by all parties and was known to be taken from a particular classification source, would be sufficient. The Name attribute could be the title "Tanking". This would remove the need for the overhead of the more complete classification structure of the model.

    In the Netherlands the nlsfb is used a lot to classify. I think you could load a certain .txt file into Revit/Archicad whatever and then you could a classificion menu. I think BlenderBIM also has this. But I never tried it.

  • https://www.bimloket.nl/p/715/Tabellen

    Here you can download these classifcations, this organization also maintains these files. See the last update is from 2021.

  • edited March 2023

    Do you have a simple example file? I would like to know how this looks in BIMCollab Zoom before starting to try something ...

    BTW:
    Switzerland starts something too ... https://www.crb.ch/Normen-Standards/Baukostenplaene/eBKP-Plugin.html Since we use our own code to classify (which is for sure based on IfcOpenShell) I might switch from PSet.Property to this IfcClassificationReference to be on the same road as all the others ...

  • Do you have a simple example file?

    Do you mean ifc file or .txt classification file?
    The schependomlaan.ifc is really classified neatly:

    makes it really easy to filter out structural elements and other stuff.

  • The benefits of using IfcClassificationReference over a property set are:

    • The classification reference knows that it is part of an IfcClassification, which hosts the name and edition date and other metadata. For systems like Uniclass, which easily get outdated and are revised multiple times a year, this additional metadata is critical.
    • The classification reference knows it is part of a hierarchy with a list of separators. That way if your object has a classification reference identifier of "12.23.34", it knows that if you filter by "12.23" or "12", then it still passes the filter.
    • The classification reference entity may be provided as an external IFC project library which can then be referenced by projects: https://github.com/Moult/IfcClassification whereas actual properties cannot.
    • The classification reference contains inverse relationships back to the elements it references. That makes it very efficient to filter objects by classification, as opposed to filtering by property which is more expensive since you need to search all properties and group by element.
    • You can have multiple classification references across multiple systems, whereas there is no convention on how this will work in properties and complex properties are being phased out.
    • Inheritance from types and overrides are well defined for multiple classifications where overrides occur specific to a classification system.
    Coenbernd
  • That all totally makes sense. Great stuff. I will jump in the IfcClassificationRace ... I will use swiss classification system ...

  • edited March 2023

    Ahh thanks for the schependomlaan hint

Sign In or Register to comment.