Write documentation for root API module

This commit is contained in:
Dion Moult
2022-12-16 15:29:50 +11:00
parent 436482532d
commit 9b3b06adf3
4 changed files with 143 additions and 20 deletions
@@ -21,15 +21,43 @@ import ifcopenshell.util.schema
class Usecase:
def __init__(self, file, **settings):
def __init__(self, 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.
:param product: The IfcProduct that you want to change the class of.
:type product: ifcopenshell.entity_instance.entity_instance
:param ifc_class: The new IFC class you want to change it to.
:type ifc_class: str,optional
:param predefined_type: In case you want to change the predefined type
too. User defined types are also allowed, just type what you want.
:type predefined_type: str,optional
:return: The newly modified product.
:rtype: 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.
"""
self.file = file
self.settings = {
"product": None,
"ifc_class": "IfcBuildingElementProxy",
"predefined_type": None,
"product": product,
"ifc_class": ifc_class,
"predefined_type": predefined_type,
}
for key, value in settings.items():
self.settings[key] = value
def execute(self):
element = ifcopenshell.util.schema.reassign_class(