ifcopenshell.api.root.reassign_class#

Module Contents#

class ifcopenshell.api.root.reassign_class.Usecase(file, product=None, ifc_class='IfcBuildingElementProxy', predefined_type=None)#

Changes the class of a product

If you ever created a wall then realised it’s meant to be something else, this function lets you change the IFC class whilst retaining all other geometry and relationships.

This is especially useful when dealing with poorly classified data from proprietary software with limited IFC capabilities.

If you are reassigning a type, the occurrence classes are also reassigned to maintain validity.

Vice versa, if you are reassigning an occurrence, the type is also reassigned in IFC4 and up. In IFC2X3, this may not occur if the type cannot be unambiguously derived, so you are required to manually check this.

Parameters
  • product (ifcopenshell.entity_instance.entity_instance) – The IfcProduct that you want to change the class of.

  • ifc_class (str,optional) – The new IFC class you want to change it to.

  • predefined_type (str,optional) – In case you want to change the predefined type too. User defined types are also allowed, just type what you want.

Returns

The newly modified product.

Return type

ifcopenshell.entity_instance.entity_instance

Example:

# We have a wall.
wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")

# Oh, did I say wall? I meant slab.
slab = ifcopenshell.api.run("root.reassign_class", model, product=wall, ifc_class="IfcSlab")

# Warning: this will crash since wall doesn't exist any more.
print(wall) # Kaboom.
execute(self)#
reassign_class(self, element, ifc_class)#