OSArch Community

[IfcOpenShell] How to change element attributes, a note

  1. M

    My task is to remove transparency values of out of our Ifc files.

    In our case i need to set the transparency value of "IfcSurfaceStyleRendering" to zero (0.).

    I' ve searched quite a while to find out how to change (this) attribute(s) with IfcOpenShell. That's why i want to share how i did this.

    Comments and notes welcome.

    Edit: Please be aware that this is just snippet and cannot be executed on it's own.

    
    surface_list = self.ifc.by_type("IfcSurfaceStyleRendering")
    
    for surface in surface_list:
    
        try:
    
            ifcopenshell.api.run("attribute.edit_attributes", self.ifc, product=surface, attributes={"Transparency": 0.0})
    
            new_file_name = self.ifcfilepath.stem + "_intransparent" + self.ifcfilepath.suffix
    
            new_ifc_file_path = str(self.ifcfilepath.with_name(new_file_name))
    
            self.ifc.write(new_ifc_file_path)
    
            return True
    
        except Exception as err:
    
            print("Error on writing the new Ifc file: ", err)
    
            traceback.print_exception(*sys.exc_info())
    
            return False
    
  2. C
  3. M

    Hi, thank's for the feedback. We're not working with BlenderBIM but a different authoring tool. You're right, modifying with a text editor would work as well. But the team is a little bit bigger that's why i wanted to have a '1-click' GUI solution instead.

Login or Register to reply.