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

[IfcOpenShell] How to change element attributes, a note

edited December 2022 in General

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
GorgiousVDobranov

Comments

  • edited November 2022

    Hi,
    I used to have a problem with Transparencies. Maybe this post can help:
    https://community.osarch.org/discussion/1137/after-re-importing-all-styles-are-transparent
    The Bug that was causing the issue was repaired. For files not being originally with BlenderBIM the solution for removing transparency with a simple search and replace may be easier.

  • 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.

Sign In or Register to comment.