diff --git a/src/ifcopenshell-python/ifcopenshell/api/layer/add_layer.py b/src/ifcopenshell-python/ifcopenshell/api/layer/add_layer.py
index 5379ff1b3a..df171a4ded 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/layer/add_layer.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/layer/add_layer.py
@@ -15,9 +15,11 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
+from typing import Optional
-def add_layer(file, Name=None) -> None:
+def add_layer(file: ifcopenshell.file, Name: Optional[str] = None) -> ifcopenshell.entity_instance:
"""Adds a new layer
An IFC layer is like a CAD layer. Portions of an object's geometry
@@ -41,6 +43,4 @@ def add_layer(file, Name=None) -> None:
ifcopenshell.api.run("layer.add_layer", model, Name="AI-WALL-FULL-DIMS-N")
"""
- settings = {"Name": Name or "Unnamed"}
-
- return file.create_entity("IfcPresentationLayerAssignment", Name=settings["Name"])
+ return file.create_entity("IfcPresentationLayerAssignment", Name=Name)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/layer/edit_layer.py b/src/ifcopenshell-python/ifcopenshell/api/layer/edit_layer.py
index 9d96156cfc..1590cc4559 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/layer/edit_layer.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/layer/edit_layer.py
@@ -15,9 +15,11 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
+from typing import Any
-def edit_layer(file, layer=None, attributes=None) -> None:
+def edit_layer(file: ifcopenshell.file, layer: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
"""Edits the attributes of an IfcPresentationLayerAssignment
For more information about the attributes and data types of an
@@ -26,7 +28,7 @@ def edit_layer(file, layer=None, attributes=None) -> None:
:param layer: The IfcPresentationLayerAssignment entity you want to edit
:type layer: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
- :type attributes: dict, optional
+ :type attributes: dict
:return: None
:rtype: None
@@ -38,7 +40,7 @@ def edit_layer(file, layer=None, attributes=None) -> None:
ifcopenshell.api.run("layer.edit_layer", model,
layer=layer, attributes={"Description": "All walls, based on the AIA standard."})
"""
- settings = {"layer": layer, "attributes": attributes or {}}
+ settings = {"layer": layer, "attributes": attributes}
for name, value in settings["attributes"].items():
setattr(settings["layer"], name, value)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/layer/remove_layer.py b/src/ifcopenshell-python/ifcopenshell/api/layer/remove_layer.py
index 790b396174..27b3e80ac1 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/layer/remove_layer.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/layer/remove_layer.py
@@ -15,9 +15,10 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
-def remove_layer(file, layer=None) -> None:
+def remove_layer(file: ifcopenshell.file, layer: ifcopenshell.entity_instance) -> None:
"""Removes a layer
All representation items assigned to the layer will remain, but the
@@ -35,6 +36,4 @@ def remove_layer(file, layer=None) -> None:
layer = ifcopenshell.api.run("layer.add_layer", model, Name="AI-WALL")
ifcopenshell.api.run("layer.remove_layer", model, layer=layer)
"""
- settings = {"layer": layer}
-
- file.remove(settings["layer"])
+ file.remove(layer)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/library/add_library.py b/src/ifcopenshell-python/ifcopenshell/api/library/add_library.py
index 16cd00b914..fdd21c3424 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/library/add_library.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/library/add_library.py
@@ -21,7 +21,7 @@ import ifcopenshell.util.schema
import ifcopenshell.util.date
-def add_library(file, name=None) -> None:
+def add_library(file: ifcopenshell.entity_instance, name: str) -> ifcopenshell.entity_instance:
"""Adds a new library to the project
A library is an external data source that is related to the project. It
@@ -60,6 +60,4 @@ def add_library(file, name=None) -> None:
ifcopenshell.api.run("library.add_library", model, name="Brickschema")
"""
- settings = {"name": name}
-
- return file.create_entity("IfcLibraryInformation", Name=settings["name"])
+ return file.create_entity("IfcLibraryInformation", Name=name)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/library/edit_library.py b/src/ifcopenshell-python/ifcopenshell/api/library/edit_library.py
index 5a53869a3f..81b96c0692 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/library/edit_library.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/library/edit_library.py
@@ -15,9 +15,11 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
+from typing import Any
-def edit_library(file, library=None, attributes=None) -> None:
+def edit_library(file: ifcopenshell.file, library: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
"""Edits the attributes of an IfcLibraryInformation
For more information about the attributes and data types of an
@@ -26,7 +28,7 @@ def edit_library(file, library=None, attributes=None) -> None:
:param library: The IfcLibraryInformation entity you want to edit
:type library: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
- :type attributes: dict, optional
+ :type attributes: dict
:return: None
:rtype: None
@@ -39,7 +41,7 @@ def edit_library(file, library=None, attributes=None) -> None:
attributes={"Description": "A Brickschema TTL including only mechanical distribution systems."})
"""
- settings = {"library": library, "attributes": attributes or {}}
+ settings = {"library": library, "attributes": attributes}
for name, value in settings["attributes"].items():
setattr(settings["library"], name, value)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/library/edit_reference.py b/src/ifcopenshell-python/ifcopenshell/api/library/edit_reference.py
index 1d2487820a..621dd32271 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/library/edit_reference.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/library/edit_reference.py
@@ -15,9 +15,13 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
+from typing import Any
-def edit_reference(file, reference=None, attributes=None) -> None:
+def edit_reference(
+ file: ifcopenshell.file, reference: ifcopenshell.entity_instance, attributes: dict[str, Any]
+) -> None:
"""Edits the attributes of an IfcLibraryReference
For more information about the attributes and data types of an
@@ -26,7 +30,7 @@ def edit_reference(file, reference=None, attributes=None) -> None:
:param reference: The IfcLibraryReference entity you want to edit
:type reference: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
- :type attributes: dict, optional
+ :type attributes: dict
:return: None
:rtype: None
@@ -40,7 +44,7 @@ def edit_reference(file, reference=None, attributes=None) -> None:
ifcopenshell.api.run("library.edit_reference", model,
reference=reference, attributes={"Identification": "http://example.org/digitaltwin#AHU01"})
"""
- settings = {"reference": reference, "attributes": attributes or {}}
+ settings = {"reference": reference, "attributes": attributes}
for name, value in settings["attributes"].items():
setattr(settings["reference"], name, value)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/library/remove_library.py b/src/ifcopenshell-python/ifcopenshell/api/library/remove_library.py
index ba5244537c..d0c6cc4cc5 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/library/remove_library.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/library/remove_library.py
@@ -20,7 +20,7 @@ import ifcopenshell
import ifcopenshell.util.element
-def remove_library(file, library=None) -> None:
+def remove_library(file: ifcopenshell.file, library: ifcopenshell.entity_instance) -> None:
"""Removes a library
All references along with their relationships will also be removed. Any
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/add_constituent.py b/src/ifcopenshell-python/ifcopenshell/api/material/add_constituent.py
index b1f3f76073..d7a8a19ace 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/add_constituent.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/add_constituent.py
@@ -15,9 +15,12 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
-def add_constituent(file, constituent_set=None, material=None) -> None:
+def add_constituent(
+ file: ifcopenshell.file, constituent_set: ifcopenshell.entity_instance, material: ifcopenshell.entity_instance
+) -> ifcopenshell.entity_instance:
"""Adds a new constituent to a constituent set
A constituent describes how a portion of an object is made out of a
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/add_layer.py b/src/ifcopenshell-python/ifcopenshell/api/material/add_layer.py
index 68885715ee..c0dc7c8b76 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/add_layer.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/add_layer.py
@@ -15,9 +15,12 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
-def add_layer(file, layer_set=None, material=None) -> None:
+def add_layer(
+ file: ifcopenshell.file, layer_set: ifcopenshell.entity_instance, material: ifcopenshell.entity_instance
+) -> ifcopenshell.entity_instance:
"""Adds a new layer to a layer set
A layer represents a portion of material within a layered build up,
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/add_list_item.py b/src/ifcopenshell-python/ifcopenshell/api/material/add_list_item.py
index 7eaa8159ce..52cb4ecfa8 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/add_list_item.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/add_list_item.py
@@ -19,7 +19,9 @@
import ifcopenshell
-def add_list_item(file, material_list=None, material=None) -> None:
+def add_list_item(
+ file: ifcopenshell.file, material_list: ifcopenshell.entity_instance, material: ifcopenshell.entity_instance
+) -> None:
"""Adds a new material in a list of materials
In IFC2X3, if you wanted an object to have multiple materials (i.e. a
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/add_material.py b/src/ifcopenshell-python/ifcopenshell/api/material/add_material.py
index 534d9e911c..f8cd351e03 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/add_material.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/add_material.py
@@ -15,9 +15,13 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
+from typing import Optional
-def add_material(file, name=None, category=None) -> None:
+def add_material(
+ file: ifcopenshell.file, name: Optional[str] = None, category: Optional[str] = None
+) -> ifcopenshell.entity_instance:
"""Adds a new material
A material in IFC represents a physical material, such as timber, steel,
@@ -48,7 +52,7 @@ def add_material(file, name=None, category=None) -> None:
:param name: The name of the material, typically tagged in a finishes
drawing or schedule.
- :type name: str
+ :type name: str, optional
:param category: The category of the material.
:type category: str, optional
:return: The newly created IfcMaterial
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/add_material_set.py b/src/ifcopenshell-python/ifcopenshell/api/material/add_material_set.py
index 99cfafad41..51edd0b2be 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/add_material_set.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/add_material_set.py
@@ -15,9 +15,12 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
-def add_material_set(file, name="Unnamed", set_type="IfcMaterialConstituentSet") -> None:
+def add_material_set(
+ file: ifcopenshell.file, name: str = "Unnamed", set_type: str = "IfcMaterialConstituentSet"
+) -> ifcopenshell.entity_instance:
"""Adds a new material set
IFC allows you to state that objects are made out of multiple materials.
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/assign_profile.py b/src/ifcopenshell-python/ifcopenshell/api/material/assign_profile.py
index 15c7e4d779..d82a296f34 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/assign_profile.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/assign_profile.py
@@ -19,7 +19,9 @@
import ifcopenshell.util.representation
-def assign_profile(file, material_profile=None, profile=None) -> None:
+def assign_profile(
+ file: ifcopenshell.file, material_profile: ifcopenshell.entity_instance, profile: ifcopenshell.entity_instance
+) -> None:
"""Changes the profile curve of a material profile item in a profile set
In addition to changing the profile curve, it will also change the
@@ -94,7 +96,8 @@ def assign_profile(file, material_profile=None, profile=None) -> None:
class Usecase:
- def execute(self):
+ file: ifcopenshell.file
+ def execute(self) -> None:
# TODO: handle composite profiles
old_profile = self.settings["material_profile"].Profile
self.settings["material_profile"].Profile = self.settings["profile"]
@@ -117,7 +120,7 @@ class Usecase:
# TODO: check remove deep
self.file.remove(old_profile)
- def change_profile(self, element):
+ def change_profile(self, element: ifcopenshell.entity_instance) -> None:
representation = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
if not representation:
return
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/copy_material.py b/src/ifcopenshell-python/ifcopenshell/api/material/copy_material.py
index 45886e7121..5655fa97da 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/copy_material.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/copy_material.py
@@ -20,7 +20,7 @@ import ifcopenshell
import ifcopenshell.util.element
-def copy_material(file, material=None) -> None:
+def copy_material(file: ifcopenshell.file, material: ifcopenshell.entity_instance) -> ifcopenshell.entity_instance:
"""Copies a material
All material psets and styles are copied. The copied material is not
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/edit_assigned_material.py b/src/ifcopenshell-python/ifcopenshell/api/material/edit_assigned_material.py
index 3102d5a645..129654d902 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/edit_assigned_material.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/edit_assigned_material.py
@@ -15,9 +15,11 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
+from typing import Any
-def edit_assigned_material(file, element=None, attributes=None) -> None:
+def edit_assigned_material(file: ifcopenshell.file, element: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
"""Edits the attributes of an IfcMaterial
For more information about the attributes and data types of an
@@ -26,7 +28,7 @@ def edit_assigned_material(file, element=None, attributes=None) -> None:
:param element: The IfcMaterial entity you want to edit
:type element: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
- :type attributes: dict, optional
+ :type attributes: dict
:return: None
:rtype: None
@@ -38,7 +40,7 @@ def edit_assigned_material(file, element=None, attributes=None) -> None:
ifcopenshell.api.run("material.edit_assigned_material", model,
element=concrete, attributes={"Description": "40MPA concrete with broom finish"})
"""
- settings = {"element": element, "attributes": attributes or {}}
+ settings = {"element": element, "attributes": attributes}
for name, value in settings["attributes"].items():
setattr(settings["element"], name, value)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/edit_constituent.py b/src/ifcopenshell-python/ifcopenshell/api/material/edit_constituent.py
index 998bef98bd..a11a5ed630 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/edit_constituent.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/edit_constituent.py
@@ -15,9 +15,16 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
+from typing import Optional, Any
-def edit_constituent(file, constituent=None, attributes=None, material=None) -> None:
+def edit_constituent(
+ file: ifcopenshell.file,
+ constituent: ifcopenshell.entity_instance,
+ attributes: Optional[dict[str, Any]] = None,
+ material: Optional[ifcopenshell.entity_instance] = None,
+) -> None:
"""Edits the attributes of an IfcMaterialConstituent
For more information about the attributes and data types of an
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/edit_layer.py b/src/ifcopenshell-python/ifcopenshell/api/material/edit_layer.py
index 78ce15132f..57d0b04795 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/edit_layer.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/edit_layer.py
@@ -15,9 +15,16 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
+from typing import Optional, Any
-def edit_layer(file, layer=None, attributes=None, material=None) -> None:
+def edit_layer(
+ file: ifcopenshell.file,
+ layer: ifcopenshell.entity_instance,
+ attributes: Optional[dict[str, Any]] = None,
+ material: Optional[ifcopenshell.entity_instance] = None,
+) -> None:
"""Edits the attributes of an IfcMaterialLayer
For more information about the attributes and data types of an
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/edit_layer_usage.py b/src/ifcopenshell-python/ifcopenshell/api/material/edit_layer_usage.py
index 9204728004..e05fc02cab 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/edit_layer_usage.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/edit_layer_usage.py
@@ -15,9 +15,11 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
+from typing import Any
-def edit_layer_usage(file, usage=None, attributes=None) -> None:
+def edit_layer_usage(file: ifcopenshell.file, usage: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
"""Edits the attributes of an IfcMaterialLayerSetUsage
This is typically used to change the offset from the reference line to
@@ -29,7 +31,7 @@ def edit_layer_usage(file, usage=None, attributes=None) -> None:
:param usage: The IfcMaterialLayerSetUsage entity you want to edit
:type usage: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
- :type attributes: dict, optional
+ :type attributes: dict
:return: None
:rtype: None
@@ -73,7 +75,7 @@ def edit_layer_usage(file, usage=None, attributes=None) -> None:
ifcopenshell.api.run("material.edit_layer_usage", model,
usage=rel.RelatingMaterial, attributes={"OffsetFromReferenceLine": 200})
"""
- settings = {"usage": usage, "attributes": attributes or {}}
+ settings = {"usage": usage, "attributes": attributes}
for name, value in settings["attributes"].items():
setattr(settings["usage"], name, value)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/edit_material.py b/src/ifcopenshell-python/ifcopenshell/api/material/edit_material.py
index 87b3f2c7fb..ddf541503c 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/edit_material.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/edit_material.py
@@ -15,12 +15,12 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
+from typing import Any
-def edit_material(file, material=None, attributes=None) -> None:
+def edit_material(file: ifcopenshell.file, material: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
"""Edits the attributes of an IfcMaterial"""
- settings = {"material": material, "attributes": attributes or {}}
-
- for name, value in settings["attributes"].items():
- setattr(settings["material"], name, value)
+ for name, value in attributes.items():
+ setattr(material, name, value)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/edit_profile.py b/src/ifcopenshell-python/ifcopenshell/api/material/edit_profile.py
index aa1310dbca..e4fe4b3610 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/edit_profile.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/edit_profile.py
@@ -17,7 +17,17 @@
# along with IfcOpenShell. If not, see .
-def edit_profile(file, profile=None, attributes=None, profile_def=None, material=None) -> None:
+from typing import Any, Optional
+import ifcopenshell
+
+
+def edit_profile(
+ file: ifcopenshell.file,
+ profile: ifcopenshell.entity_instance,
+ attributes: Optional[dict[str, Any]] = None,
+ profile_def: Optional[ifcopenshell.entity_instance] = None,
+ material: Optional[ifcopenshell.entity_instance] = None,
+) -> None:
"""Edits the attributes of an IfcMaterialProfile
For more information about the attributes and data types of an
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/edit_profile_usage.py b/src/ifcopenshell-python/ifcopenshell/api/material/edit_profile_usage.py
index 8ad5192570..37a57825f5 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/edit_profile_usage.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/edit_profile_usage.py
@@ -15,12 +15,14 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-
import ifcopenshell.geom
import ifcopenshell.util.representation
+from typing import Any
-def edit_profile_usage(file, usage=None, attributes=None) -> None:
+def edit_profile_usage(
+ file: ifcopenshell.file, usage: ifcopenshell.entity_instance, attributes: dict[str, Any]
+) -> None:
"""Edits the attributes of an IfcMaterialProfileSetUsage
This is typically used to change the cardinal point of the profile.
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/remove_constituent.py b/src/ifcopenshell-python/ifcopenshell/api/material/remove_constituent.py
index 02256e0695..d28934e77e 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/remove_constituent.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/remove_constituent.py
@@ -15,9 +15,10 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
-def remove_constituent(file, constituent=None) -> None:
+def remove_constituent(file: ifcopenshell.file, constituent: ifcopenshell.entity_instance) -> None:
"""Removes a constituent from a constituent set
Note that it is invalid to have zero items in a set, so you should leave
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/remove_layer.py b/src/ifcopenshell-python/ifcopenshell/api/material/remove_layer.py
index fda5cf2151..744a59b65d 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/remove_layer.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/remove_layer.py
@@ -15,9 +15,10 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
-def remove_layer(file, layer=None) -> None:
+def remove_layer(file: ifcopenshell.file, layer: ifcopenshell.entity_instance) -> None:
"""Removes a layer from a layer set
Note that it is invalid to have zero items in a set, so you should leave
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/remove_list_item.py b/src/ifcopenshell-python/ifcopenshell/api/material/remove_list_item.py
index a41b6ec7a8..cdcf8d42cd 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/remove_list_item.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/remove_list_item.py
@@ -19,7 +19,9 @@
import ifcopenshell
-def remove_list_item(file, material_list=None, material_index=0) -> None:
+def remove_list_item(
+ file: ifcopenshell.file, material_list: ifcopenshell.entity_instance, material_index: int = 0
+) -> None:
"""Removes an item in an material list
Note that it is invalid to have zero items in a list, so you should leave
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/remove_material.py b/src/ifcopenshell-python/ifcopenshell/api/material/remove_material.py
index 1b0924f717..fe75da3039 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/remove_material.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/remove_material.py
@@ -20,7 +20,7 @@ import ifcopenshell
import ifcopenshell.util.element
-def remove_material(file, material=None) -> None:
+def remove_material(file: ifcopenshell.file, material: ifcopenshell.entity_instance) -> None:
"""Removes a material
If the material is used in a material set, the corresponding layer,
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/remove_material_set.py b/src/ifcopenshell-python/ifcopenshell/api/material/remove_material_set.py
index 5ede76c1c2..d38b1ec03d 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/remove_material_set.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/remove_material_set.py
@@ -20,7 +20,7 @@ import ifcopenshell
import ifcopenshell.util.element
-def remove_material_set(file, material=None) -> None:
+def remove_material_set(file: ifcopenshell.file, material: ifcopenshell.entity_instance) -> None:
"""Removes a material set
All set items, such as layers, profiles, or constituents will also be
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/remove_profile.py b/src/ifcopenshell-python/ifcopenshell/api/material/remove_profile.py
index 858b6f1289..699c265708 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/remove_profile.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/remove_profile.py
@@ -21,7 +21,7 @@ import ifcopenshell
import ifcopenshell.util.element
-def remove_profile(file, profile=None) -> None:
+def remove_profile(file: ifcopenshell.file, profile: ifcopenshell.entity_instance) -> None:
"""Removes a profile item from a profile set
Note that it is invalid to have zero items in a set, so you should leave
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/reorder_set_item.py b/src/ifcopenshell-python/ifcopenshell/api/material/reorder_set_item.py
index 481050ff63..fbe8dd7bd9 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/reorder_set_item.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/reorder_set_item.py
@@ -15,9 +15,12 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
-def reorder_set_item(file, material_set=None, old_index=0, new_index=0) -> None:
+def reorder_set_item(
+ file: ifcopenshell.file, material_set: ifcopenshell.entity_instance, old_index: int = 0, new_index: int = 0
+) -> None:
"""Reorders an item in a material set
In some material sets, the order have meaning, like in a layer set. In
diff --git a/src/ifcopenshell-python/ifcopenshell/api/nest/change_nest.py b/src/ifcopenshell-python/ifcopenshell/api/nest/change_nest.py
index 22ba7d0fc3..fec740477b 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/nest/change_nest.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/nest/change_nest.py
@@ -21,15 +21,15 @@ import ifcopenshell.api
import ifcopenshell.util.element
-def change_nest(file, item=None, new_parent=None) -> None:
+def change_nest(
+ file: ifcopenshell.file, item: ifcopenshell.entity_instance, new_parent: ifcopenshell.entity_instance
+) -> None:
"""Assigns a cost item to a new parent cost item"""
- settings = {"item": item, "new_parent": new_parent}
-
- if not settings["item"].Nests:
+ if not item.Nests:
return
- nests = settings["item"].Nests[0]
+ nests = item.Nests[0]
related_objects = list(nests.RelatedObjects)
- related_objects.remove(settings["item"])
+ related_objects.remove(item)
if related_objects:
nests.RelatedObjects = related_objects
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": nests})
@@ -41,6 +41,6 @@ def change_nest(file, item=None, new_parent=None) -> None:
ifcopenshell.api.run(
"nest.assign_object",
file,
- related_objects=[settings["item"]],
- relating_object=settings["new_parent"],
+ related_objects=[item],
+ relating_object=new_parent,
)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/nest/reorder_nesting.py b/src/ifcopenshell-python/ifcopenshell/api/nest/reorder_nesting.py
index 63b591ee28..88eab25513 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/nest/reorder_nesting.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/nest/reorder_nesting.py
@@ -15,19 +15,18 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
-def reorder_nesting(file, item=None, old_index=0, new_index=0) -> None:
+def reorder_nesting(
+ file: ifcopenshell.file, item: ifcopenshell.entity_instance, old_index: int = 0, new_index: int = 0
+) -> None:
"""Reorders an item in a nesting set"""
- settings = {"item": item, "old_index": old_index, "new_index": new_index}
-
- if not settings["item"].Nests:
+ if not item.Nests:
return
- nesting_set = settings["item"].Nests[0]
- if not settings["old_index"]:
- old_index = nesting_set.RelatedObjects.index(settings["item"])
- else:
- old_index = settings["old_index"]
+ nesting_set = item.Nests[0]
+ if not old_index:
+ old_index = nesting_set.RelatedObjects.index(item)
items = list(getattr(nesting_set, "RelatedObjects") or [])
- items.insert(settings["new_index"], items.pop(old_index))
+ items.insert(new_index, items.pop(old_index))
setattr(nesting_set, "RelatedObjects", items)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/add_actor.py b/src/ifcopenshell-python/ifcopenshell/api/owner/add_actor.py
index 124561f136..d4c82315c9 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/add_actor.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/add_actor.py
@@ -19,9 +19,14 @@
import ifcopenshell
import ifcopenshell.api
+from typing import Literal
-def add_actor(file, actor=None, ifc_class="IfcActor") -> None:
+def add_actor(
+ file: ifcopenshell.file,
+ actor: ifcopenshell.entity_instance,
+ ifc_class: Literal["IfcActor", "IfcOccupant"] = "IfcActor",
+) -> ifcopenshell.entity_instance:
"""Adds a new actor
An actor is a person or an organisation who has a responsibility or role
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/add_address.py b/src/ifcopenshell-python/ifcopenshell/api/owner/add_address.py
index a214c86d81..cc8d8bfb33 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/add_address.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/add_address.py
@@ -15,9 +15,12 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
-def add_address(file, assigned_object=None, ifc_class="IfcPostalAddress") -> None:
+def add_address(
+ file: ifcopenshell.file, assigned_object: ifcopenshell.entity_instance, ifc_class: str = "IfcPostalAddress"
+) -> ifcopenshell.entity_instance:
"""Add a new telecom or postal address to an organisation or person
A person or organisation may have associated contact details such as
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/add_application.py b/src/ifcopenshell-python/ifcopenshell/api/owner/add_application.py
index 07a59db0d7..fd46625ae5 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/add_application.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/add_application.py
@@ -17,15 +17,16 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell.api
+from typing import Optional
def add_application(
- file,
- application_developer=None,
- version=None,
- application_full_name="IfcOpenShell",
- application_identifier="IfcOpenShell",
-) -> None:
+ file: ifcopenshell.file,
+ application_developer: Optional[ifcopenshell.entity_instance] = None,
+ version: Optional[str] = None,
+ application_full_name: str = "IfcOpenShell",
+ application_identifier: str = "IfcOpenShell",
+) -> ifcopenshell.entity_instance:
"""Adds a new application
IFC data may be associated with an authoring application to identify
@@ -46,6 +47,8 @@ def add_application(
:param application_identifier: An identification string for the
application intended for computers to read.
:type application_identifier: str, optional
+ :return: The newly created IfcApplication
+ :rtype: ifcopenshell.entity_instance
Example:
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/add_person.py b/src/ifcopenshell-python/ifcopenshell/api/owner/add_person.py
index 7abdfb1598..d408f39b69 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/add_person.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/add_person.py
@@ -23,7 +23,7 @@ def add_person(
identification: str = "HSeldon",
family_name: str = "Seldon",
given_name: str = "Hari",
-) -> None:
+) -> ifcopenshell.entity_instance:
"""Adds a new person
Persons are used to identify a legal or liable representative of an
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/add_role.py b/src/ifcopenshell-python/ifcopenshell/api/owner/add_role.py
index 415ed4efde..7c73de69a9 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/add_role.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/add_role.py
@@ -15,9 +15,10 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
-def add_role(file, assigned_object=None, role="ARCHITECT") -> None:
+def add_role(file: ifcopenshell.file, assigned_object: ifcopenshell.entity_instance, role: str = "ARCHITECT") -> ifcopenshell.entity_instance:
"""Adds and assigns a new role
People and organisations must play one or more roles on a project. Roles
@@ -32,7 +33,7 @@ def add_role(file, assigned_object=None, role="ARCHITECT") -> None:
be assigned to.
:type assigned_object: ifcopenshell.entity_instance
:param role: The type of role, taken from the IFC documentation for
- IfcActorRole, or a custom name.
+ IfcActorRole, or a custom name. Defaults to "ARCHITECT".
:type role: str, optional
:return: The newly created IfcActorRole
:rtype: ifcopenshell.entity_instance
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/assign_actor.py b/src/ifcopenshell-python/ifcopenshell/api/owner/assign_actor.py
index 1680e5369f..7f2e4a863b 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/assign_actor.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/assign_actor.py
@@ -21,7 +21,9 @@ import ifcopenshell.api
import ifcopenshell.guid
-def assign_actor(file, relating_actor=None, related_object=None) -> None:
+def assign_actor(
+ file: ifcopenshell.file, relating_actor: ifcopenshell.entity_instance, related_object: ifcopenshell.entity_instance
+) -> ifcopenshell.entity_instance:
"""Assigns an actor to an object
An actor may be assigned to objects which implies that the actor is
@@ -80,7 +82,7 @@ def assign_actor(file, relating_actor=None, related_object=None) -> None:
if settings["related_object"].HasAssignments:
for rel in settings["related_object"].HasAssignments:
if rel.is_a("IfcRelAssignsToActor") and rel.RelatingActor == settings["relating_actor"]:
- return
+ return rel
rel = None
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/edit_actor.py b/src/ifcopenshell-python/ifcopenshell/api/owner/edit_actor.py
index e1125ab212..619e806097 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/edit_actor.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/edit_actor.py
@@ -15,9 +15,11 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
+from typing import Any
-def edit_actor(file, actor=None, attributes=None) -> None:
+def edit_actor(file: ifcopenshell.file, actor: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
"""Edits the attributes of an IfcActor
For more information about the attributes and data types of an
@@ -26,7 +28,7 @@ def edit_actor(file, actor=None, attributes=None) -> None:
:param actor: The IfcActor entity you want to edit
:type actor: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
- :type attributes: dict, optional
+ :type attributes: dict
:return: None
:rtype: None
@@ -47,7 +49,7 @@ def edit_actor(file, actor=None, attributes=None) -> None:
ifcopenshell.api.run("actor.edit_actor", model,
actor=actor, attributes={"Description": "Responsible for buildings A, B, and C."})
"""
- settings = {"actor": actor, "attributes": attributes or {}}
+ settings = {"actor": actor, "attributes": attributes}
for name, value in settings["attributes"].items():
setattr(settings["actor"], name, value)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/edit_address.py b/src/ifcopenshell-python/ifcopenshell/api/owner/edit_address.py
index ba74f0ede6..4f6df196db 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/edit_address.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/edit_address.py
@@ -15,9 +15,11 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
+from typing import Any
-def edit_address(file, address=None, attributes=None) -> None:
+def edit_address(file: ifcopenshell.file, address: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
"""Edits the attributes of an IfcAddress
For more information about the attributes and data types of an
@@ -26,7 +28,7 @@ def edit_address(file, address=None, attributes=None) -> None:
:param address: The IfcAddress entity you want to edit
:type address: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
- :type attributes: dict, optional
+ :type attributes: dict
:return: None
:rtype: None
@@ -49,7 +51,7 @@ def edit_address(file, address=None, attributes=None) -> None:
"ElectronicMailAddresses": ["bobthebuilder@example.com"],
"WWWHomePageURL": "https://thinkmoult.com"})
"""
- settings = {"address": address, "attributes": attributes or {}}
+ settings = {"address": address, "attributes": attributes}
for name, value in settings["attributes"].items():
setattr(settings["address"], name, value)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/edit_organisation.py b/src/ifcopenshell-python/ifcopenshell/api/owner/edit_organisation.py
index 012e9152ba..f3991918ca 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/edit_organisation.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/edit_organisation.py
@@ -15,9 +15,11 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
+from typing import Any
-def edit_organisation(file, organisation=None, attributes=None) -> None:
+def edit_organisation(file: ifcopenshell.file, organisation: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
"""Edits the attributes of an IfcOrganization
For more information about the attributes and data types of an
@@ -26,7 +28,7 @@ def edit_organisation(file, organisation=None, attributes=None) -> None:
:param organisation: The IfcOrganization entity you want to edit
:type organisation: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
- :type attributes: dict, optional
+ :type attributes: dict
:return: None
:rtype: None
@@ -39,7 +41,7 @@ def edit_organisation(file, organisation=None, attributes=None) -> None:
ifcopenshell.api.run("owner.edit_organisation", model, organisation=organisation,
attributes={"name": "Architects Without Ballpens"})
"""
- settings = {"organisation": organisation, "attributes": attributes or {}}
+ settings = {"organisation": organisation, "attributes": attributes}
for name, value in settings["attributes"].items():
setattr(settings["organisation"], name, value)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/edit_person.py b/src/ifcopenshell-python/ifcopenshell/api/owner/edit_person.py
index a8fdb56168..1a66068727 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/edit_person.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/edit_person.py
@@ -15,9 +15,11 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
+from typing import Any
-def edit_person(file, person=None, attributes=None) -> None:
+def edit_person(file: ifcopenshell.file, person: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
"""Edits the attributes of an IfcPerson
For more information about the attributes and data types of an
@@ -26,7 +28,7 @@ def edit_person(file, person=None, attributes=None) -> None:
:param person: The IfcPerson entity you want to edit
:type person: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
- :type attributes: dict, optional
+ :type attributes: dict
:return: None
:rtype: None
@@ -39,7 +41,7 @@ def edit_person(file, person=None, attributes=None) -> None:
ifcopenshell.api.run("owner.edit_person", model, person=person,
attributes={"MiddleNames": ["The"], "FamilyName": "Builder"})
"""
- settings = {"person": person, "attributes": attributes or {}}
+ settings = {"person": person, "attributes": attributes}
for name, value in settings["attributes"].items():
setattr(settings["person"], name, value)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/edit_role.py b/src/ifcopenshell-python/ifcopenshell/api/owner/edit_role.py
index 6934af27e0..034a685d5d 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/edit_role.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/edit_role.py
@@ -15,9 +15,11 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
+from typing import Any
-def edit_role(file, role=None, attributes=None) -> None:
+def edit_role(file: ifcopenshell.file, role: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
"""Edits the attributes of an IfcActorRole
For more information about the attributes and data types of an
@@ -26,7 +28,7 @@ def edit_role(file, role=None, attributes=None) -> None:
:param role: The IfcActorRole entity you want to edit
:type role: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
- :type attributes: dict, optional
+ :type attributes: dict
:return: None
:rtype: None
@@ -43,7 +45,7 @@ def edit_role(file, role=None, attributes=None) -> None:
# But Bob is not an architect
ifcopenshell.api.run("owner.edit_role", model, role=role, attributes={"Role": "CONSTRUCTIONMANAGER"})
"""
- settings = {"role": role, "attributes": attributes or {}}
+ settings = {"role": role, "attributes": attributes}
for name, value in settings["attributes"].items():
setattr(settings["role"], name, value)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/remove_actor.py b/src/ifcopenshell-python/ifcopenshell/api/owner/remove_actor.py
index 49feb54179..d11f18657d 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/remove_actor.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/remove_actor.py
@@ -20,7 +20,7 @@ import ifcopenshell
import ifcopenshell.util.element
-def remove_actor(file, actor=None) -> None:
+def remove_actor(file: ifcopenshell.file, actor: ifcopenshell.entity_instance) -> None:
"""Removes an actor
:param actor: The IfcActor to remove.
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/remove_address.py b/src/ifcopenshell-python/ifcopenshell/api/owner/remove_address.py
index 5fba84583b..31fc19b675 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/remove_address.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/remove_address.py
@@ -15,9 +15,10 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
-def remove_address(file, address=None) -> None:
+def remove_address(file: ifcopenshell.file, address: ifcopenshell.entity_instance) -> None:
"""Removes an address
Naturally, any organisations or people using that address will have the
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/remove_application.py b/src/ifcopenshell-python/ifcopenshell/api/owner/remove_application.py
index 16973cfcc4..f441205925 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/remove_application.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/remove_application.py
@@ -15,9 +15,10 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
-def remove_application(file, application=None) -> None:
+def remove_application(file: ifcopenshell.file, application: ifcopenshell.entity_instance) -> None:
"""Removes an application
Warning: removing an application may invalidate ownership histories.
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/remove_organisation.py b/src/ifcopenshell-python/ifcopenshell/api/owner/remove_organisation.py
index 42111e017e..c1652a1fce 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/remove_organisation.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/remove_organisation.py
@@ -19,7 +19,7 @@
import ifcopenshell.api
-def remove_organisation(file, organisation=None) -> None:
+def remove_organisation(file: ifcopenshell.file, organisation: ifcopenshell.entity_instance) -> None:
"""Remove an organisation
All roles and addresses assigned to the organisation will also be
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/remove_person.py b/src/ifcopenshell-python/ifcopenshell/api/owner/remove_person.py
index 77d297527f..5ce265cae2 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/remove_person.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/remove_person.py
@@ -19,7 +19,7 @@
import ifcopenshell.api
-def remove_person(file, person=None) -> None:
+def remove_person(file: ifcopenshell.file, person: ifcopenshell.entity_instance) -> None:
"""Remove an person
All roles and addresses assigned to the person will also be
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/remove_person_and_organisation.py b/src/ifcopenshell-python/ifcopenshell/api/owner/remove_person_and_organisation.py
index 8473e04b87..1311dfa642 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/remove_person_and_organisation.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/remove_person_and_organisation.py
@@ -19,7 +19,9 @@
import ifcopenshell.api
-def remove_person_and_organisation(file, person_and_organisation=None) -> None:
+def remove_person_and_organisation(
+ file: ifcopenshell.file, person_and_organisation: ifcopenshell.entity_instance
+) -> None:
"""Removes a person and organisation
Note that the underlying person and organisation is not removed, only
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/remove_role.py b/src/ifcopenshell-python/ifcopenshell/api/owner/remove_role.py
index 08bf39881c..7ecfa8847e 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/remove_role.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/remove_role.py
@@ -15,9 +15,10 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
-def remove_role(file, role=None) -> None:
+def remove_role(file: ifcopenshell.file, role: ifcopenshell.entity_instance) -> None:
"""Removes a role
People and organisations using the role will be untouched. This may
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/unassign_actor.py b/src/ifcopenshell-python/ifcopenshell/api/owner/unassign_actor.py
index c57d0172f5..38f63688a6 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/unassign_actor.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/unassign_actor.py
@@ -21,7 +21,9 @@ import ifcopenshell.api
import ifcopenshell.util.element
-def unassign_actor(file, relating_actor=None, related_object=None) -> None:
+def unassign_actor(
+ file: ifcopenshell.file, relating_actor: ifcopenshell.entity_instance, related_object: ifcopenshell.entity_instance
+) -> None:
"""Unassigns an actor to an object
This means that the actor is no longer responsible for the object.
@@ -30,9 +32,8 @@ def unassign_actor(file, relating_actor=None, related_object=None) -> None:
:type relating_actor: ifcopenshell.entity_instance
:param related_object: The object the actor is responsible for.
:type related_object: ifcopenshell.entity_instance
- :return: The updated IfcRelAssignsToActor relationship or none if there
- is no more valid relationship.
- :rtype: None, ifcopenshell.entity_instance
+ :return: None
+ :rtype: None
Example:
@@ -72,4 +73,3 @@ def unassign_actor(file, relating_actor=None, related_object=None) -> None:
related_objects.remove(settings["related_object"])
rel.RelatedObjects = related_objects
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": rel})
- return rel
diff --git a/src/ifcopenshell-python/ifcopenshell/api/profile/add_arbitrary_profile.py b/src/ifcopenshell-python/ifcopenshell/api/profile/add_arbitrary_profile.py
index 9acc800b89..8c432c9626 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/profile/add_arbitrary_profile.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/profile/add_arbitrary_profile.py
@@ -17,9 +17,12 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell.util.unit
+from typing import Optional
-def add_arbitrary_profile(file, profile=None, name=None) -> None:
+def add_arbitrary_profile(
+ file: ifcopenshell.file, profile: list[tuple[float, float]], name: Optional[str] = None
+) -> ifcopenshell.entity_instance:
"""Adds a new arbitrary polyline-based profile
The profile is represented as a polyline defined by a list of
@@ -30,7 +33,7 @@ def add_arbitrary_profile(file, profile=None, name=None) -> None:
identical.
:param profile: A list of coordinates
- :type profile: list[list[float]]
+ :type profile: list[tuple[float, float]]
:param name: If the profile is semantically significant (i.e. to be
managed and reused by the user) then it must be named. Otherwise,
this may be left as none.
diff --git a/src/ifcopenshell-python/ifcopenshell/api/profile/add_arbitrary_profile_with_voids.py b/src/ifcopenshell-python/ifcopenshell/api/profile/add_arbitrary_profile_with_voids.py
index e1a6fe9cdb..52287aee7c 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/profile/add_arbitrary_profile_with_voids.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/profile/add_arbitrary_profile_with_voids.py
@@ -17,9 +17,15 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell.util.unit
+from typing import Optional
-def add_arbitrary_profile_with_voids(file, outer_profile=None, inner_profiles=None, name=None) -> None:
+def add_arbitrary_profile_with_voids(
+ file: ifcopenshell.file,
+ outer_profile: list[tuple[float, float]],
+ inner_profiles: list[list[tuple[float, float]]],
+ name: Optional[str] = None,
+) -> ifcopenshell.entity_instance:
"""Adds a new arbitrary polyline-based profile with voids
The outer profile is represented as a polyline defined by a list of
@@ -35,9 +41,9 @@ def add_arbitrary_profile_with_voids(file, outer_profile=None, inner_profiles=No
provided in SI meters.
:param outer_profile: A list of coordinates
- :type profile: list[float]
+ :type profile: list[tuple[float, float]]
:param inner_profiles: A list of polylines
- :type profile: list[list[float]]
+ :type profile: list[list[tuple[float, float]]]
:param name: If the profile is semantically significant (i.e. to be
managed and reused by the user) then it must be named. Otherwise,
this may be left as none.
diff --git a/src/ifcopenshell-python/ifcopenshell/api/profile/add_parameterized_profile.py b/src/ifcopenshell-python/ifcopenshell/api/profile/add_parameterized_profile.py
index c0a6348656..abb205ba5e 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/profile/add_parameterized_profile.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/profile/add_parameterized_profile.py
@@ -15,9 +15,10 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
-def add_parameterized_profile(file, ifc_class=None) -> None:
+def add_parameterized_profile(file: ifcopenshell.file, ifc_class: str) -> ifcopenshell.entity_instance:
"""Adds a new parameterised profile
IFC offers parameterised profiles for common standardised hot roll
diff --git a/src/ifcopenshell-python/ifcopenshell/api/profile/edit_profile.py b/src/ifcopenshell-python/ifcopenshell/api/profile/edit_profile.py
index 4d525a5d32..bfcb9da595 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/profile/edit_profile.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/profile/edit_profile.py
@@ -15,9 +15,11 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import ifcopenshell
+from typing import Any
-def edit_profile(file, profile=None, attributes=None) -> None:
+def edit_profile(file: ifcopenshell.file, profile: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
"""Edits the attributes of an IfcProfileDef
For more information about the attributes and data types of an
@@ -26,7 +28,7 @@ def edit_profile(file, profile=None, attributes=None) -> None:
:param profile: The IfcProfileDef entity you want to edit
:type profile: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
- :type attributes: dict, optional
+ :type attributes: dict
:return: None
:rtype: None
@@ -41,7 +43,7 @@ def edit_profile(file, profile=None, attributes=None) -> None:
ifcopenshell.api.run("profile.edit_profile", model,
profile=circle, attributes={"ProfileName": "1000mm Dia"})
"""
- settings = {"profile": profile, "attributes": attributes or {}}
+ settings = {"profile": profile, "attributes": attributes}
for name, value in settings["attributes"].items():
setattr(settings["profile"], name, value)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/profile/remove_profile.py b/src/ifcopenshell-python/ifcopenshell/api/profile/remove_profile.py
index 58f3eebedb..f20cfc89fc 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/profile/remove_profile.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/profile/remove_profile.py
@@ -20,7 +20,7 @@ import ifcopenshell
import ifcopenshell.util.element
-def remove_profile(file, profile=None) -> None:
+def remove_profile(file: ifcopenshell.file, profile: ifcopenshell.entity_instance) -> None:
"""Removes a profile
:param profile: The IfcProfileDef to remove.
diff --git a/src/ifcopenshell-python/ifcopenshell/api/project/append_asset.py b/src/ifcopenshell-python/ifcopenshell/api/project/append_asset.py
index b63b4cb719..df1a3246c6 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/project/append_asset.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/project/append_asset.py
@@ -19,7 +19,8 @@
import ifcopenshell
import ifcopenshell.api
import ifcopenshell.api.owner.settings
-from typing import Optional
+import ifcopenshell.util.element
+from typing import Optional, Any, Union
def append_asset(
@@ -124,6 +125,9 @@ def append_asset(
class Usecase:
+ file: ifcopenshell.file
+ settings: dict[str, Any]
+
def execute(self):
# mapping of old element ids to new elements
self.added_elements: dict[int, ifcopenshell.entity_instance] = {}
@@ -223,7 +227,7 @@ class Usecase:
return element
- def add_element(self, element):
+ def add_element(self, element: ifcopenshell.entity_instance) -> Union[ifcopenshell.entity_instance, None]:
if element.id() == 0:
return
existing_element = self.get_existing_element(element)
@@ -262,7 +266,7 @@ class Usecase:
elif value:
return True
- def check_inverses(self, element):
+ def check_inverses(self, element: ifcopenshell.entity_instance) -> None:
for source_class, attributes in self.whitelisted_inverse_attributes.items():
if not element.is_a(source_class):
continue
diff --git a/src/ifcopenshell-python/ifcopenshell/util/date.py b/src/ifcopenshell-python/ifcopenshell/util/date.py
index ce2c72289a..e547e5dbbf 100644
--- a/src/ifcopenshell-python/ifcopenshell/util/date.py
+++ b/src/ifcopenshell-python/ifcopenshell/util/date.py
@@ -19,6 +19,7 @@
import datetime
from re import findall
from dateutil import parser
+from typing import Literal, Union, Any
try:
import isodate
@@ -104,7 +105,18 @@ def readable_ifc_duration(string):
return final_string
-def datetime2ifc(dt, ifc_type):
+def datetime2ifc(
+ dt: Union[datetime.date, str],
+ ifc_type: Literal[
+ "IfcDuration",
+ "IfcTimeStamp",
+ "IfcDateTime",
+ "IfcDate",
+ "IfcTime",
+ "IfcCalendarDate",
+ "IfcLocalTime",
+ ],
+) -> Union[int, str, dict[str, Any]]:
if isinstance(dt, str):
if ifc_type == "IfcDuration":
return dt
@@ -145,6 +157,7 @@ def datetime2ifc(dt, ifc_type):
"MinuteComponent": dt.minute,
"SecondComponent": dt.second,
}
+ raise TypeError(f"Unsupported ifc_type for conversion from datetime.datetime = {ifc_type}.")
def string_to_date(string):