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
@@ -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