This commit is contained in:
Andrej730
2025-02-18 15:18:23 +05:00
parent 83a351b1c7
commit 17642ca4e9
117 changed files with 683 additions and 1005 deletions
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell.util.unit
from typing import Union
from typing import Union, Any
COORD = Union[tuple[float, float], tuple[float, float, float]]
@@ -82,6 +82,9 @@ def add_axis_representation(
class Usecase:
file: ifcopenshell.file
settings: dict[str, Any]
def execute(self):
self.settings["unit_scale"] = ifcopenshell.util.unit.calculate_unit_scale(self.file)
is_2d = len(self.settings["axis"][0]) == 2
@@ -26,14 +26,9 @@ def add_footprint_representation(
# A list of IFC curves to include in the curve set
curves: list[ifcopenshell.entity_instance],
) -> ifcopenshell.entity_instance:
settings = {
"context": context,
"curves": curves,
}
return file.createIfcShapeRepresentation(
settings["context"],
settings["context"].ContextIdentifier,
context,
context.ContextIdentifier,
"GeometricCurveSet",
[file.createIfcGeometricCurveSet(settings["curves"])],
[file.createIfcGeometricCurveSet(curves)],
)
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell.util.unit
from typing import Optional
from typing import Optional, Any
COORD_3D = tuple[float, float, float]
@@ -60,6 +60,9 @@ def add_mesh_representation(
class Usecase:
file: ifcopenshell.file
settings: dict[str, Any]
def execute(self):
if self.settings["unit_scale"] is None:
self.settings["unit_scale"] = ifcopenshell.util.unit.calculate_unit_scale(self.file)
@@ -52,6 +52,9 @@ def add_profile_representation(
class Usecase:
file: ifcopenshell.file
settings: dict[str, Any]
def execute(self):
self.settings["unit_scale"] = ifcopenshell.util.unit.calculate_unit_scale(self.file)
self.settings["clippings"] = [Clipping.parse(c) for c in self.settings["clippings"]]
@@ -426,6 +426,9 @@ def add_window_representation(
class Usecase:
file: ifcopenshell.file
settings: dict[str, Any]
def execute(self):
builder = ShapeBuilder(self.file)
np_X, np_Y, np_Z = 0, 1, 2
@@ -31,53 +31,33 @@ def connect_path(
related_connection: str = "NOTDEFINED",
description: Optional[str] = None,
) -> ifcopenshell.entity_instance:
settings = {
"relating_element": relating_element,
"related_element": related_element,
"relating_connection": relating_connection,
"related_connection": related_connection,
"description": description,
}
incompatible_connections = []
for rel in settings["relating_element"].ConnectedTo:
incompatible_connections: list[ifcopenshell.entity_instance] = []
for rel in relating_element.ConnectedTo:
if not rel.is_a("IfcRelConnectsPathElements"):
continue
if rel.RelatedElement == settings["related_element"]:
if rel.RelatedElement == related_element:
incompatible_connections.append(rel)
elif (
rel.RelatingConnectionType in ["ATSTART", "ATEND"]
and rel.RelatingConnectionType == settings["relating_connection"]
):
elif rel.RelatingConnectionType in ["ATSTART", "ATEND"] and rel.RelatingConnectionType == relating_connection:
incompatible_connections.append(rel)
for rel in settings["relating_element"].ConnectedFrom:
for rel in relating_element.ConnectedFrom:
if not rel.is_a("IfcRelConnectsPathElements"):
continue
if (
rel.RelatedConnectionType in ["ATSTART", "ATEND"]
and rel.RelatedConnectionType == settings["relating_connection"]
):
if rel.RelatedConnectionType in ["ATSTART", "ATEND"] and rel.RelatedConnectionType == relating_connection:
incompatible_connections.append(rel)
for rel in settings["related_element"].ConnectedFrom:
for rel in related_element.ConnectedFrom:
if not rel.is_a("IfcRelConnectsPathElements"):
continue
if (
rel.RelatedConnectionType in ["ATSTART", "ATEND"]
and rel.RelatedConnectionType == settings["related_connection"]
):
if rel.RelatedConnectionType in ["ATSTART", "ATEND"] and rel.RelatedConnectionType == related_connection:
incompatible_connections.append(rel)
for rel in settings["related_element"].ConnectedTo:
for rel in related_element.ConnectedTo:
if not rel.is_a("IfcRelConnectsPathElements"):
continue
if rel.RelatedElement == settings["relating_element"]:
if rel.RelatedElement == relating_element:
incompatible_connections.append(rel)
elif (
rel.RelatingConnectionType in ["ATSTART", "ATEND"]
and rel.RelatingConnectionType == settings["related_connection"]
):
elif rel.RelatingConnectionType in ["ATSTART", "ATEND"] and rel.RelatingConnectionType == related_connection:
incompatible_connections.append(rel)
if incompatible_connections:
@@ -87,14 +67,15 @@ def connect_path(
if history:
ifcopenshell.util.element.remove_deep2(file, history)
return file.createIfcRelConnectsPathElements(
return file.create_entity(
"IfcRelConnectsPathElements",
ifcopenshell.guid.new(),
OwnerHistory=ifcopenshell.api.owner.create_owner_history(file),
Description=settings["description"],
RelatingElement=settings["relating_element"],
RelatedElement=settings["related_element"],
RelatingConnectionType=settings["relating_connection"],
RelatedConnectionType=settings["related_connection"],
Description=description,
RelatingElement=relating_element,
RelatedElement=related_element,
RelatingConnectionType=relating_connection,
RelatedConnectionType=related_connection,
RelatingPriorities=[],
RelatedPriorities=[],
)