This commit is contained in:
Andrej730
2024-05-09 14:18:36 +05:00
parent 359dab573b
commit 2d35869c41
57 changed files with 221 additions and 109 deletions
@@ -17,9 +17,11 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell.api
import ifcopenshell.util.element
from typing import Any
def edit_attributes(file, product=None, attributes=None) -> None:
def edit_attributes(file: ifcopenshell.file, product: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
"""Edit the attributes of a product
All IFC entities have attributes. Normally they can be edited directly,
@@ -31,7 +33,7 @@ def edit_attributes(file, product=None, attributes=None) -> None:
entity.
:type product: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
:type attributes: dict, optional
:type attributes: dict
:return: None
:rtype: None
@@ -17,17 +17,18 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell.util.unit
from typing import Optional
def assign_connection_geometry(
file,
rel_space_boundary=None,
outer_boundary=None,
inner_boundaries=None,
location=None,
axis=None,
ref_direction=None,
unit_scale=None,
file: ifcopenshell.file,
rel_space_boundary: ifcopenshell.entity_instance,
outer_boundary: list[tuple[float, float]],
location: tuple[float, float, float],
axis: tuple[float, float, float],
ref_direction: tuple[float, float, float],
inner_boundaries: Optional[list[list[tuple[float, float]]]] = None,
unit_scale: Optional[float] = None,
) -> None:
"""Create and assign a connection geometry to a space boundary relationship
@@ -44,24 +45,24 @@ def assign_connection_geometry(
polyline. The last point will connect to the first point. Each
point is represented by an interable of 2 floats. The coordinates of
the points are relative to the positional matrix arguments.
:type outer_boundary: list[list[float]]
:type outer_boundary: list[tuple[float, float]]
:param inner_boundaries: A list of zero or more inner boundaries to use
for the plane. Each boundary is represented by an open polyline, as
defined by the outer_boundary argument.
:type inner_boundaries: list[list[list[float]]], optional
:type inner_boundaries: list[list[tuple[float, float]]], optional
:param location: The local origin of the connection geometry, defined as
an XYZ coordinate relative to the placement of the space that is
being bounded.
:type location: list[float]
:type location: tuple[float, float, float]
:param axis: The local X axis of the connection geometry, defined as an
XYZ vector relative to the placement of the space that is being
bounded.
:type axis: list[float]
:type axis: tuple[float, float, float]
:param ref_direction: The local Z axis of the connection geometry,
defined as an XYZ vector relative to the placement of the space that
is being bounded. The Y vector is automatically derived using the
right hand rule.
:type ref_direction: list[float]
:type ref_direction: tuple[float, float, float]
:param unit_scale: The unit scale as calculated by
ifcopenshell.util.unit.calculate_unit_scale. If not provided, it
will be automatically calculated for you.
@@ -19,13 +19,13 @@
import ifcopenshell.util.element
def copy_boundary(file, boundary=None) -> None:
def copy_boundary(file: ifcopenshell.file, boundary: ifcopenshell.entity_instance) -> ifcopenshell.entity_instance:
"""Copies a space boundary
:param boundary: The IfcRelSpaceBoundary you want to copy.
:type boundary: ifcopenshell.entity_instance
:return: None
:rtype: None
:return: Duplicate of the IfcRelSpaceBoundary
:rtype: ifcopenshell.entity_instance
Example:
@@ -15,15 +15,17 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
from typing import Optional
def edit_attributes(
file,
entity=None,
relating_space=None,
related_building_element=None,
parent_boundary=None,
corresponding_boundary=None,
file: ifcopenshell.file,
entity: ifcopenshell.entity_instance,
relating_space: ifcopenshell.entity_instance,
related_building_element: ifcopenshell.entity_instance,
parent_boundary: Optional[ifcopenshell.entity_instance] = None,
corresponding_boundary: Optional[ifcopenshell.entity_instance] = None,
) -> None:
"""Modify the relationships of a space boundary relationship
@@ -20,7 +20,7 @@ import ifcopenshell
import ifcopenshell.util.element
def remove_boundary(file, boundary=None) -> None:
def remove_boundary(file: ifcopenshell.file, boundary: ifcopenshell.entity_instance) -> None:
"""Removes a space boundary
The relating space or related building element is untouched. Only the
@@ -15,9 +15,13 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
from typing import Any
def edit_classification(file, classification=None, attributes=None) -> None:
def edit_classification(
file: ifcopenshell.file, classification: ifcopenshell.entity_instance, attributes: dict[str, Any]
) -> None:
"""Edits the attributes of an IfcClassification
For more information about the attributes and data types of an
@@ -26,7 +30,7 @@ def edit_classification(file, classification=None, attributes=None) -> None:
:param classification: The IfcClassification entity you want to edit
:type classification: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
:type attributes: dict, optional
:type attributes: dict
:return: None
:rtype: None
@@ -15,9 +15,13 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
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 IfcClassificationReference
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 IfcClassificationReference 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
@@ -20,7 +20,7 @@ import ifcopenshell
import ifcopenshell.util.element
def remove_classification(file: ifcopenshell.entity_instance, classification: ifcopenshell.entity_instance) -> None:
def remove_classification(file: ifcopenshell.file, classification: ifcopenshell.entity_instance) -> None:
"""Removes an IfcClassification from the project and all references
The classification and all of its relationships, children references,
@@ -19,7 +19,7 @@
import ifcopenshell
def add_metric(file, objective=None) -> None:
def add_metric(file: ifcopenshell.file, objective: ifcopenshell.entity_instance) -> ifcopenshell.entity_instance:
"""Add a new metric benchmark
Qualitative constraints may have a series of quantitative benchmarks
@@ -50,7 +50,7 @@ def add_metric(file, objective=None) -> None:
"Name": "Unnamed",
"ConstraintGrade": "NOTDEFINED",
"Benchmark": "EQUALTO",
}
},
)
if settings["objective"]:
benchmark_values = list(settings["objective"].BenchmarkValues or [])
@@ -19,16 +19,18 @@
import ifcopenshell
def add_metric_reference(file, metric=None, reference_path=None) -> None:
def add_metric_reference(
file: ifcopenshell.file, metric: ifcopenshell.entity_instance, reference_path: str
) -> list[ifcopenshell.entity_instance]:
"""
Adds a chain of references to a metric. The reference path is a string of the form "attribute.attribute.attribute"
Used to reference a value of an attribute of an instance through a metric objective entity.
"""
settings = {"metric": metric, "reference_path": reference_path}
references_created = []
if settings["reference_path"]:
attributes = settings["reference_path"].split(".")
references_created = []
for i in range(len(attributes)):
if i == 0:
reference = file.create_entity("IfcReference")
@@ -40,4 +42,4 @@ def add_metric_reference(file, metric=None, reference_path=None) -> None:
reference.AttributeIdentifier = attributes[i]
references_created[i - 1].InnerReference = reference
references_created.append(reference)
return references_created
return references_created
@@ -19,7 +19,7 @@
import ifcopenshell
def add_objective(file) -> None:
def add_objective(file: ifcopenshell.file) -> ifcopenshell.entity_instance:
"""Add a new objective constraint
Parametric constraints may be defined by the user. The constraint is defined
@@ -15,9 +15,11 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
from typing import Any
def edit_metric(file, metric=None, attributes=None) -> None:
def edit_metric(file: ifcopenshell.file, metric: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
"""Edit the attributes of a metric
For more information about the attributes and data types of an
@@ -26,7 +28,7 @@ def edit_metric(file, metric=None, attributes=None) -> None:
:param metric: The IfcMetric you want to edit.
:type metric: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
:type attributes: dict, optional
:type attributes: dict
:return: None
:rtype: None
@@ -15,9 +15,13 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
from typing import Any
def edit_objective(file, objective=None, attributes=None) -> None:
def edit_objective(
file: ifcopenshell.file, objective: ifcopenshell.entity_instance, attributes: dict[str, Any]
) -> None:
"""Edit the attributes of a objective
For more information about the attributes and data types of an
@@ -26,7 +30,7 @@ def edit_objective(file, objective=None, attributes=None) -> None:
:param objective: The IfcObjective you want to edit.
:type objective: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
:type attributes: dict, optional
:type attributes: dict
:return: None
:rtype: None
@@ -20,7 +20,7 @@ import ifcopenshell
import ifcopenshell.util.element
def remove_constraint(file, constraint=None) -> None:
def remove_constraint(file: ifcopenshell.file, constraint: ifcopenshell.entity_instance) -> None:
"""Remove a constraint (typically an objective)
Removes a constraint definition and all of its associations to any
@@ -15,9 +15,10 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
def remove_metric(file, metric=None) -> None:
def remove_metric(file: ifcopenshell.file, metric: ifcopenshell.entity_instance) -> None:
"""Remove a metric benchmark
Removes a metric benchmark and all of its associations to any products
@@ -17,9 +17,11 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
import ifcopenshell.api
import ifcopenshell.util.element
def remove_context(file: ifcopenshell.entity_instance, context: ifcopenshell.entity_instance) -> None:
def remove_context(file: ifcopenshell.file, context: ifcopenshell.entity_instance) -> None:
"""Removes an IfcGeometricRepresentationContext
Any representation geometry that is assigned to the context is also
@@ -19,9 +19,14 @@
import ifcopenshell
import ifcopenshell.api
import ifcopenshell.guid
from typing import Union
def assign_control(file, relating_control=None, related_object=None) -> None:
def assign_control(
file: ifcopenshell.file,
relating_control: ifcopenshell.entity_instance,
related_object: ifcopenshell.entity_instance,
) -> Union[ifcopenshell.entity_instance, None]:
"""Assigns a planning control or constraint to an object
IFC can describe concepts that control other objects. For example, a
@@ -19,9 +19,14 @@
import ifcopenshell
import ifcopenshell.api
import ifcopenshell.util.element
from typing import Union
def unassign_control(file, relating_control=None, related_object=None) -> None:
def unassign_control(
file: ifcopenshell.file,
relating_control: ifcopenshell.entity_instance,
related_object: ifcopenshell.entity_instance,
) -> Union[ifcopenshell.entity_instance, None]:
"""Unassigns a planning control or constraint to an object
:param relating_control: The IfcControl entity that is creating the
@@ -18,22 +18,29 @@
import ifcopenshell.api
import ifcopenshell.guid
from typing import Optional
def add_cost_item(file, cost_schedule=None, cost_item=None) -> None:
def add_cost_item(
file: ifcopenshell.file,
cost_schedule: Optional[ifcopenshell.entity_instance] = None,
cost_item: Optional[ifcopenshell.entity_instance] = None,
) -> ifcopenshell.entity_instance:
"""Add a new cost item
A cost item represents a single line item in a cost schedule. Cost items
may then be broken down into cost subitems.
Either `cost_schedule` or `cost_item` must be provided.
:param cost_schedule: If the cost item is to be added as a root or top
level cost item to a cost schedule, the IfcCostSchedule may be
specified. This is mutually exlclusive to the cost_item parameter.
:type cost_schedule: ifcopenshell.entity_instance
:type cost_schedule: ifcopenshell.entity_instance, optional.
:param cost_item: If the cost item is to be added as a subitem to an
existing cost item, the parent IfcCostItem may be specified. This is
mutually exclusive to the cost_schedule parameter.
:type cost_item: ifcopenshell.entity_instance
:type cost_item: ifcopenshell.entity_instance, optional
:return: The newly created IfcCostItem
:rtype: ifcopenshell.entity_instance
@@ -62,7 +69,7 @@ def add_cost_item(file, cost_schedule=None, cost_item=None) -> None:
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
"RelatedObjects": [cost_item],
"RelatingControl": settings["cost_schedule"],
}
},
)
elif settings["cost_item"]:
ifcopenshell.api.run(
@@ -19,7 +19,9 @@
import ifcopenshell.api
def add_cost_item_quantity(file, cost_item=None, ifc_class="IfcQuantityCount") -> None:
def add_cost_item_quantity(
file: ifcopenshell.file, cost_item: ifcopenshell.entity_instance, ifc_class: str = "IfcQuantityCount"
) -> ifcopenshell.entity_instance:
"""Adds a new quantity associated with a cost item
Cost items calculate their subtotal by multiplying the sum of the cost
@@ -19,9 +19,10 @@
import ifcopenshell.api
import ifcopenshell.util.date
from datetime import datetime
from typing import Optional
def add_cost_schedule(file, name=None, predefined_type="NOTDEFINED") -> None:
def add_cost_schedule(file: ifcopenshell.file, name: Optional[str] = None, predefined_type="NOTDEFINED") -> None:
"""Add a new cost schedule
A cost schedule is a group of cost items which typically represent a
@@ -15,9 +15,10 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
def add_cost_value(file, parent=None) -> None:
def add_cost_value(file: ifcopenshell.file, parent: ifcopenshell.entity_instance) -> ifcopenshell.entity_instance:
"""Adds a new value or subvalue to a cost item
A cost item's subtotal can be specified in two ways.
@@ -17,9 +17,15 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell.api
from typing import Optional
def assign_cost_item_quantity(file, cost_item=None, products=None, prop_name="") -> None:
def assign_cost_item_quantity(
file: ifcopenshell.file,
cost_item: ifcopenshell.entity_instance,
products: list[ifcopenshell.entity_instance],
prop_name: Optional[str] = "",
) -> None:
"""Adds a cost item quantity that is parametrically connected to a product
A cost item may have its subtotal calculated by multiplying a unit value
@@ -19,7 +19,9 @@
import ifcopenshell.api
def assign_cost_value(file, cost_item=None, cost_rate=None) -> None:
def assign_cost_value(
file: ifcopenshell.file, cost_item: ifcopenshell.entity_instance, cost_rate: ifcopenshell.entity_instance
) -> None:
"""Assigns a cost value to a cost item from a schedule of rates
Instead of assigning cost values from scratch for each cost item in a
@@ -21,7 +21,7 @@ import ifcopenshell.util.date
import ifcopenshell.util.resource
def calculate_cost_item_resource_value(file, cost_item=None) -> None:
def calculate_cost_item_resource_value(file: ifcopenshell.file, cost_item: ifcopenshell.entity_instance) -> None:
"""Calculates the total cost of all resources associated with a cost item
A cost item may have construction resources (e.g. equipment, material,
@@ -19,9 +19,14 @@
import ifcopenshell
import ifcopenshell.api
import ifcopenshell.util.element
from typing import Union
def copy_cost_item(file, cost_item=None) -> None:
def copy_cost_item(
file: ifcopenshell.file, cost_item: ifcopenshell.entity_instance
) -> Union[ifcopenshell.entity_instance, list[ifcopenshell.entity_instance]]:
# TODO: currently it never returns list of duplicated cost items
# though it is stated in the docs
"""Copies all cost items and related relationships
The following relationships are also duplicated:
@@ -33,7 +38,7 @@ def copy_cost_item(file, cost_item=None) -> None:
:param cost_item: The cost item to be duplicated
:type cost_item: ifcopenshell.entity_instance
:return: The duplicated cost item or the list of duplicated cost items if the latter has children
:rtype: ifcopenshell.entity_instance or list of ifcopenshell.entity_instance
:rtype: ifcopenshell.entity_instance or list[ifcopenshell.entity_instance]
Example:
.. code:: python
@@ -55,7 +60,7 @@ def copy_cost_item(file, cost_item=None) -> None:
class Usecase:
def execute(self):
self.new_cost_items = []
self.duplicate_cost_item(self.settings["cost_item"])
return self.duplicate_cost_item(self.settings["cost_item"])
def duplicate_cost_item(self, cost_item):
new_cost_item = ifcopenshell.util.element.copy_deep(self.file, cost_item)
@@ -20,7 +20,9 @@ import ifcopenshell.util.element
import ifcopenshell.api
def copy_cost_item_values(file, source=None, destination=None) -> None:
def copy_cost_item_values(
file: ifcopenshell.file, source: ifcopenshell.entity_instance, destination: ifcopenshell.entity_instance
) -> None:
"""Copies all cost values from one cost item to another
Any previously existing values will be removed. The entire value is
@@ -15,9 +15,13 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
from typing import Any
def edit_cost_item(file, cost_item=None, attributes=None) -> None:
def edit_cost_item(
file: ifcopenshell.file, cost_item: ifcopenshell.entity_instance, attributes: dict[str, Any]
) -> None:
"""Edits the attributes of an IfcCostItem
For more information about the attributes and data types of an
@@ -26,7 +30,7 @@ def edit_cost_item(file, cost_item=None, attributes=None) -> None:
:param cost_item: The IfcCostItem entity you want to edit
:type cost_item: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
:type attributes: dict, optional
:type attributes: dict
:return: None
:rtype: None
@@ -15,9 +15,13 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
from typing import Any
def edit_cost_item_quantity(file, physical_quantity=None, attributes=None) -> None:
def edit_cost_item_quantity(
file: ifcopenshell.file, physical_quantity: ifcopenshell.entity_instance, attributes: dict[str, Any]
) -> None:
"""Edits the attributes of an IfcPhysicalQuantity
For more information about the attributes and data types of an
@@ -26,7 +30,7 @@ def edit_cost_item_quantity(file, physical_quantity=None, attributes=None) -> No
:param physical_quantity: The IfcPhysicalQuantity entity you want to edit
:type physical_quantity: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
:type attributes: dict, optional
:type attributes: dict
:return: None
:rtype: None
@@ -15,9 +15,13 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
from typing import Any
def edit_cost_schedule(file, cost_schedule=None, attributes=None) -> None:
def edit_cost_schedule(
file: ifcopenshell.file, cost_schedule: ifcopenshell.entity_instance, attributes: dict[str, Any]
) -> None:
"""Edits the attributes of an IfcCostSchedule
For more information about the attributes and data types of an
@@ -26,7 +30,7 @@ def edit_cost_schedule(file, cost_schedule=None, attributes=None) -> None:
:param cost_schedule: The IfcCostSchedule entity you want to edit
:type cost_schedule: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
:type attributes: dict, optional
:type attributes: dict
:return: None
:rtype: None
@@ -19,9 +19,12 @@
import ifcopenshell
import ifcopenshell.util.unit
import ifcopenshell.util.element
from typing import Any
def edit_cost_value(file, cost_value=None, attributes=None) -> None:
def edit_cost_value(
file: ifcopenshell.file, cost_value: ifcopenshell.entity_instance, attributes: dict[str, Any]
) -> None:
"""Edits the attributes of an IfcCostValue
For more information about the attributes and data types of an
@@ -30,7 +33,7 @@ def edit_cost_value(file, cost_value=None, attributes=None) -> None:
:param cost_value: The IfcCostValue entity you want to edit
:type cost_value: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
:type attributes: dict, optional
:type attributes: dict
:return: None
:rtype: None
@@ -22,7 +22,7 @@ import ifcopenshell.util.unit
import ifcopenshell.util.element
def edit_cost_value_formula(file, cost_value=None, formula=None) -> None:
def edit_cost_value_formula(file: ifcopenshell.file, cost_value: ifcopenshell.entity_instance, formula: str) -> None:
"""Sets a cost value based on a formula, similar to formulas in spreadsheets
Costs may be made up of many components (e.g. labour, material, waste
@@ -21,7 +21,7 @@ import ifcopenshell.api
import ifcopenshell.util.element
def remove_cost_item(file, cost_item=None) -> None:
def remove_cost_item(file: ifcopenshell.file, cost_item: ifcopenshell.entity_instance) -> None:
"""Removes a cost item
All associated relationships with the cost item are also removed,
@@ -15,9 +15,12 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
def remove_cost_item_quantity(file, cost_item=None, physical_quantity=None) -> None:
def remove_cost_item_quantity(
file: ifcopenshell.file, cost_item: ifcopenshell.entity_instance, physical_quantity: ifcopenshell.entity_instance
) -> None:
"""Removes a quantity assigned to a cost item
If the quantity is part of a product (e.g. wall), then the quantity will
@@ -21,7 +21,7 @@ import ifcopenshell.api
import ifcopenshell.util.element
def remove_cost_schedule(file, cost_schedule=None) -> None:
def remove_cost_schedule(file: ifcopenshell.file, cost_schedule: ifcopenshell.entity_instance) -> None:
"""Removes a cost schedule
All associated relationships with the cost schedule are also removed,
@@ -15,9 +15,12 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
def remove_cost_value(file, parent=None, cost_value=None) -> None:
def remove_cost_value(
file: ifcopenshell.file, parent: ifcopenshell.entity_instance, cost_value: ifcopenshell.entity_instance
) -> None:
"""Removes a cost value
The cost value may be assigned either to a cost item, a construction
@@ -19,7 +19,9 @@
import ifcopenshell.api
def unassign_cost_item_quantity(file, cost_item=None, products=None) -> None:
def unassign_cost_item_quantity(
file: ifcopenshell.file, cost_item: ifcopenshell.entity_instance, products: list[ifcopenshell.entity_instance]
) -> None:
"""Removes quantities of a cost item that are calculated on products
A cost item may have quantities that are parametrically calculated on
@@ -18,9 +18,12 @@
import ifcopenshell
import ifcopenshell.guid
from typing import Optional
def add_information(file, parent=None) -> None:
def add_information(
file: ifcopenshell.file, parent: Optional[ifcopenshell.entity_instance] = None
) -> ifcopenshell.entity_instance:
"""Adds a new document information to the project
An IFC document information is a document associated with the project.
@@ -21,7 +21,11 @@ import ifcopenshell.api
import ifcopenshell.guid
def assign_product(file, relating_product=None, related_object=None) -> None:
def assign_product(
file: ifcopenshell.file,
relating_product: ifcopenshell.entity_instance,
related_object: ifcopenshell.entity_instance,
) -> ifcopenshell.entity_instance:
"""Associates a product and an object, typically for annotation
Warning: this is an experimental API.
@@ -104,7 +108,7 @@ def assign_product(file, relating_product=None, related_object=None) -> None:
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
"RelatedObjects": [settings["related_object"]],
"RelatingProduct": settings["relating_product"],
}
},
)
if is_grid_axis:
@@ -15,9 +15,13 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
from typing import Any
def edit_text_literal(file, text_literal=None, attributes=None) -> None:
def edit_text_literal(
file: ifcopenshell.file, text_literal: ifcopenshell.entity_instance, attributes: dict[str, Any]
) -> None:
"""Edits the attributes of an IfcTextLiteral
For more information about the attributes and data types of an
@@ -26,7 +30,7 @@ def edit_text_literal(file, text_literal=None, attributes=None) -> None:
:param reference: The IfcTextLiteral 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
@@ -21,7 +21,11 @@ import ifcopenshell.api
import ifcopenshell.util.element
def unassign_product(file, relating_product=None, related_object=None) -> None:
def unassign_product(
file: ifcopenshell.file,
relating_product: ifcopenshell.entity_instance,
related_object: ifcopenshell.entity_instance,
) -> None:
"""Unassigns a product and an object (typically an annotation)
Smart annotation objects can be associated with products so that they
@@ -34,8 +38,8 @@ def unassign_product(file, relating_product=None, related_object=None) -> None:
:param related_object: The object (typically IfcAnnotation) that the
product is related to
:type related_object: ifcopenshell.entity_instance
:return: The created IfcRelAssignsToProduct relationship
:rtype: ifcopenshell.entity_instance
:return: None
:rtype: None
Example:
@@ -68,4 +72,3 @@ def unassign_product(file, relating_product=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
@@ -19,7 +19,7 @@ import ifcopenshell
def add_person(
file: ifcopenshell.entity_instance,
file: ifcopenshell.file,
identification: str = "HSeldon",
family_name: str = "Seldon",
given_name: str = "Hari",
@@ -19,7 +19,7 @@ import ifcopenshell
def add_person_and_organisation(
file: ifcopenshell.entity_instance,
file: ifcopenshell.file,
person: ifcopenshell.entity_instance,
organisation: ifcopenshell.entity_instance,
) -> ifcopenshell.entity_instance:
@@ -22,7 +22,7 @@ import ifcopenshell.api.owner.settings
from typing import Union
def create_owner_history(file: ifcopenshell.entity_instance) -> Union[ifcopenshell.entity_instance, None]:
def create_owner_history(file: ifcopenshell.file) -> Union[ifcopenshell.entity_instance, None]:
"""Creates a new owner history indicating an element was added
Any object in IFC with a unique ID and name (such as physical products,
@@ -24,7 +24,7 @@ from typing import Union
def assign_declaration(
file: ifcopenshell.entity_instance,
file: ifcopenshell.file,
definitions: list[ifcopenshell.entity_instance],
relating_context: ifcopenshell.entity_instance,
) -> Union[ifcopenshell.entity_instance, None]:
@@ -142,6 +142,6 @@ def assign_declaration(
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
"RelatedDefinitions": list(objects_to_change),
"RelatingContext": relating_context,
}
},
)
return declares
@@ -22,7 +22,7 @@ from typing import Optional, Any, Union
def edit_pset(
file: ifcopenshell.entity_instance,
file: ifcopenshell.file,
pset: ifcopenshell.entity_instance,
name: Optional[str] = None,
properties: Optional[dict[str, Any]] = None,
@@ -15,9 +15,15 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
def add_context_dependent_unit(file, unit_type="USERDEFINED", name="THINGAMAJIG", dimensions=None) -> None:
def add_context_dependent_unit(
file: ifcopenshell.file,
unit_type: str = "USERDEFINED",
name: str = "THINGAMAJIG",
dimensions: tuple[int, int, int, int, int, int, int] = (0, 0, 0, 0, 0, 0, 0),
) -> ifcopenshell.entity_instance:
"""Add a new arbitrary unit that can only be interpreted in a project specific context
Occasionally the construction industry uses arbitrary units to quantify
@@ -51,7 +57,7 @@ def add_context_dependent_unit(file, unit_type="USERDEFINED", name="THINGAMAJIG"
# Boxes of things
ifcopenshell.api.run("unit.add_context_dependent_unit", model, name="BOXES")
"""
settings = {"unit_type": unit_type, "name": name, "dimensions": dimensions or (0, 0, 0, 0, 0, 0, 0)}
settings = {"unit_type": unit_type, "name": name, "dimensions": dimensions}
return file.create_entity(
"IfcContextDependentUnit",
@@ -15,9 +15,10 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
def add_monetary_unit(file, currency="DOLLARYDOO") -> None:
def add_monetary_unit(file: ifcopenshell.file, currency: str = "DOLLARYDOO") -> ifcopenshell.entity_instance:
"""Add a new currency
Currency units are useful in cost plans to know in what currency the
@@ -15,9 +15,11 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
from typing import Any
def edit_derived_unit(file, unit=None, attributes=None) -> None:
def edit_derived_unit(file: ifcopenshell.file, unit: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
"""Edits the attributes of an IfcDerivedUnit
For more information about the attributes and data types of an
@@ -26,7 +28,7 @@ def edit_derived_unit(file, unit=None, attributes=None) -> None:
:param unit: The IfcDerivedUnit entity you want to edit
:type unit: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
:type attributes: dict, optional
:type attributes: dict
:return: None
:rtype: None
"""
@@ -15,9 +15,11 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
from typing import Any
def edit_monetary_unit(file, unit=None, attributes=None) -> None:
def edit_monetary_unit(file: ifcopenshell.file, unit: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
"""Edits the attributes of an IfcMonetaryUnit
For more information about the attributes and data types of an
@@ -26,7 +28,7 @@ def edit_monetary_unit(file, unit=None, attributes=None) -> None:
:param unit: The IfcMonetaryUnit entity you want to edit
:type unit: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
:type attributes: dict, optional
:type attributes: dict
:return: None
:rtype: None
@@ -15,9 +15,11 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
from typing import Any
def edit_named_unit(file, unit=None, attributes=None) -> None:
def edit_named_unit(file: ifcopenshell.file, unit: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
"""Edits the attributes of an IfcNamedUnit
Named units include SI units, conversion based units (imperial units),
@@ -29,7 +31,7 @@ def edit_named_unit(file, unit=None, attributes=None) -> None:
:param unit: The IfcNamedUnit entity you want to edit
:type unit: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
:type attributes: dict, optional
:type attributes: dict
:return: None
:rtype: None
@@ -20,7 +20,7 @@ import ifcopenshell.util.unit
import ifcopenshell.util.element
def remove_unit(file, unit=None) -> None:
def remove_unit(file: ifcopenshell.file, unit: ifcopenshell.entity_instance) -> None:
"""Remove a unit
Be very careful when a unit is removed, as it may mean that previously
@@ -21,7 +21,9 @@ import ifcopenshell.guid
import ifcopenshell.util.element
def add_filling(file, opening=None, element=None) -> None:
def add_filling(
file: ifcopenshell.file, opening: ifcopenshell.entity_instance, element: ifcopenshell.entity_instance
) -> ifcopenshell.entity_instance:
"""Fill an opening with an element
Physical elements may have openings in them. For example, a wall might
@@ -106,13 +108,13 @@ def add_filling(file, opening=None, element=None) -> None:
if fills_voids:
if fills_voids[0].RelatingOpeningElement == settings["opening"]:
return
return fills_voids[0]
history = fills_voids[0].OwnerHistory
file.remove(fills_voids[0])
if history:
ifcopenshell.util.element.remove_deep2(file, history)
file.create_entity(
return file.create_entity(
"IfcRelFillsElement",
GlobalId=ifcopenshell.guid.new(),
RelatingOpeningElement=settings["opening"],
@@ -20,7 +20,7 @@ import ifcopenshell
import ifcopenshell.util.element
def remove_filling(file, element=None) -> None:
def remove_filling(file: ifcopenshell.file, element: ifcopenshell.entity_instance) -> None:
"""Remove a filling relationship
If an element is filling an opening, this removes the relationship such
@@ -20,7 +20,7 @@ import ifcopenshell.api
import ifcopenshell.util.element
def remove_opening(file: ifcopenshell.entity_instance, opening: ifcopenshell.entity_instance) -> None:
def remove_opening(file: ifcopenshell.file, opening: ifcopenshell.entity_instance) -> None:
"""Remove an opening
Fillings are retained as orphans. Voided elements remain. Openings
@@ -281,11 +281,11 @@ class entity_instance:
return entity_instance.walk(is_instance, unwrap, v)
def attribute_type(self, attr: int) -> str:
def attribute_type(self, attr: Union[int, str]) -> str:
"""Return the data type of a positional attribute of the element
:param attr: The index of the attribute
:type attr: int
:param attr: The index or name of the attribute
:type attr: Union[int, str]
:rtype: string
"""
attr_idx = attr if isinstance(attr, numbers.Integral) else self.wrapped_data.get_argument_index(attr)
@@ -19,7 +19,7 @@
import numpy as np
import numpy.typing as npt
import ifcopenshell
from typing import Literal, Iterable
from typing import Literal, Iterable, Optional
MatrixType = npt.NDArray[np.float64]
@@ -97,7 +97,7 @@ def get_axis2placement(placement: ifcopenshell.entity_instance) -> MatrixType:
return a2p(o, z, x)
def get_local_placement(placement: ifcopenshell.entity_instance) -> MatrixType:
def get_local_placement(placement: Optional[ifcopenshell.entity_instance] = None) -> MatrixType:
"""Parse a local placement into a 4x4 transformation matrix
This is typically used to find the location and rotation of an element. The
@@ -118,7 +118,7 @@ def get_local_placement(placement: ifcopenshell.entity_instance) -> MatrixType:
matrix = ifcopenshell.util.placement.get_local_placement(placement)
:param placement: The IfcLocalPlacement entity
:type placement: ifcopenshell.entity_instance
:type placement: ifcopenshell.entity_instance, optional
:return: A 4x4 numpy matrix
:rtype: MatrixType
"""