mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 13:46:54 +00:00
typing
This commit is contained in:
@@ -38,7 +38,7 @@ from bonsai.bim.module.geometry.helper import Helper
|
|||||||
from bonsai.bim.module.model.wall import DumbWallRecalculator
|
from bonsai.bim.module.model.wall import DumbWallRecalculator
|
||||||
from bonsai.bim.module.model.decorator import ProfileDecorator, PolylineDecorator, ProductDecorator
|
from bonsai.bim.module.model.decorator import ProfileDecorator, PolylineDecorator, ProductDecorator
|
||||||
from bonsai.bim.module.model.polyline import PolylineOperator
|
from bonsai.bim.module.model.polyline import PolylineOperator
|
||||||
from typing import Union, Any
|
from typing import Union, Any, Optional
|
||||||
|
|
||||||
|
|
||||||
class DumbProfileGenerator:
|
class DumbProfileGenerator:
|
||||||
@@ -317,7 +317,7 @@ class DumbProfileJoiner:
|
|||||||
self.axis_context = ifcopenshell.util.representation.get_context(tool.Ifc.get(), "Model", "Axis", "GRAPH_VIEW")
|
self.axis_context = ifcopenshell.util.representation.get_context(tool.Ifc.get(), "Model", "Axis", "GRAPH_VIEW")
|
||||||
self.body_context = ifcopenshell.util.representation.get_context(tool.Ifc.get(), "Model", "Body", "MODEL_VIEW")
|
self.body_context = ifcopenshell.util.representation.get_context(tool.Ifc.get(), "Model", "Body", "MODEL_VIEW")
|
||||||
|
|
||||||
def unjoin(self, profile1):
|
def unjoin(self, profile1: bpy.types.Object) -> None:
|
||||||
element1 = tool.Ifc.get_entity(profile1)
|
element1 = tool.Ifc.get_entity(profile1)
|
||||||
if not element1:
|
if not element1:
|
||||||
return
|
return
|
||||||
@@ -330,7 +330,7 @@ class DumbProfileJoiner:
|
|||||||
body = copy.deepcopy(axis1)
|
body = copy.deepcopy(axis1)
|
||||||
self.recreate_profile(element1, profile1, axis, body)
|
self.recreate_profile(element1, profile1, axis, body)
|
||||||
|
|
||||||
def join_E(self, profile1, target, connection=None):
|
def join_E(self, profile1: bpy.types.Object, target: Vector, connection: Optional[str] = None) -> None:
|
||||||
"""`connection` = `ATEND` / `ATSTART` to explicitly define the reference point for the join.
|
"""`connection` = `ATEND` / `ATSTART` to explicitly define the reference point for the join.
|
||||||
|
|
||||||
For example if profile 1m long and `target` is at (0, 0, 0.1) and `connection` = `None`
|
For example if profile 1m long and `target` is at (0, 0, 0.1) and `connection` = `None`
|
||||||
@@ -354,7 +354,7 @@ class DumbProfileJoiner:
|
|||||||
body[1 if connection == "ATEND" else 0] = intersect
|
body[1 if connection == "ATEND" else 0] = intersect
|
||||||
self.recreate_profile(element1, profile1, axis, body)
|
self.recreate_profile(element1, profile1, axis, body)
|
||||||
|
|
||||||
def set_depth(self, profile1, si_length):
|
def set_depth(self, profile1: bpy.types.Object, si_length: float) -> None:
|
||||||
element1 = tool.Ifc.get_entity(profile1)
|
element1 = tool.Ifc.get_entity(profile1)
|
||||||
if not element1:
|
if not element1:
|
||||||
return
|
return
|
||||||
@@ -369,7 +369,7 @@ class DumbProfileJoiner:
|
|||||||
body[1] = end
|
body[1] = end
|
||||||
self.recreate_profile(element1, profile1, axis, body)
|
self.recreate_profile(element1, profile1, axis, body)
|
||||||
|
|
||||||
def join_T(self, profile1, profile2):
|
def join_T(self, profile1: bpy.types.Object, profile2: bpy.types.Object) -> None:
|
||||||
element1 = tool.Ifc.get_entity(profile1)
|
element1 = tool.Ifc.get_entity(profile1)
|
||||||
element2 = tool.Ifc.get_entity(profile2)
|
element2 = tool.Ifc.get_entity(profile2)
|
||||||
axis1 = self.get_profile_axis(profile1)
|
axis1 = self.get_profile_axis(profile1)
|
||||||
@@ -393,7 +393,7 @@ class DumbProfileJoiner:
|
|||||||
|
|
||||||
self.recreate_profile(element1, profile1, axis1, axis1)
|
self.recreate_profile(element1, profile1, axis1, axis1)
|
||||||
|
|
||||||
def join_V(self, profile1, profile2):
|
def join_V(self, profile1: bpy.types.Object, profile2: bpy.types.Object) -> None:
|
||||||
element1 = tool.Ifc.get_entity(profile1)
|
element1 = tool.Ifc.get_entity(profile1)
|
||||||
element2 = tool.Ifc.get_entity(profile2)
|
element2 = tool.Ifc.get_entity(profile2)
|
||||||
axis1 = self.get_profile_axis(profile1)
|
axis1 = self.get_profile_axis(profile1)
|
||||||
@@ -419,7 +419,7 @@ class DumbProfileJoiner:
|
|||||||
self.recreate_profile(element1, profile1, axis1, axis1)
|
self.recreate_profile(element1, profile1, axis1, axis1)
|
||||||
self.recreate_profile(element2, profile2, axis2, axis2)
|
self.recreate_profile(element2, profile2, axis2, axis2)
|
||||||
|
|
||||||
def join_L(self, profile1, profile2):
|
def join_L(self, profile1: bpy.types.Object, profile2: bpy.types.Object) -> None:
|
||||||
element1 = tool.Ifc.get_entity(profile1)
|
element1 = tool.Ifc.get_entity(profile1)
|
||||||
element2 = tool.Ifc.get_entity(profile2)
|
element2 = tool.Ifc.get_entity(profile2)
|
||||||
axis1 = self.get_profile_axis(profile1)
|
axis1 = self.get_profile_axis(profile1)
|
||||||
@@ -445,7 +445,7 @@ class DumbProfileJoiner:
|
|||||||
self.recreate_profile(element1, profile1, axis1, axis1)
|
self.recreate_profile(element1, profile1, axis1, axis1)
|
||||||
self.recreate_profile(element2, profile2, axis2, axis2)
|
self.recreate_profile(element2, profile2, axis2, axis2)
|
||||||
|
|
||||||
def recreate_profile(self, element, obj, axis=None, body=None):
|
def recreate_profile(self, element: ifcopenshell.entity_instance, obj: bpy.types.Object, axis=None, body=None):
|
||||||
if axis is None or body is None:
|
if axis is None or body is None:
|
||||||
axis = body = self.get_profile_axis(obj)
|
axis = body = self.get_profile_axis(obj)
|
||||||
self.axis = copy.deepcopy(axis)
|
self.axis = copy.deepcopy(axis)
|
||||||
@@ -836,10 +836,10 @@ class DumbProfileJoiner:
|
|||||||
z_axis = obj.matrix_world.to_quaternion() @ Vector((-1, 0, 0))
|
z_axis = obj.matrix_world.to_quaternion() @ Vector((-1, 0, 0))
|
||||||
return self.create_matrix(p, x_axis, y_axis, z_axis)
|
return self.create_matrix(p, x_axis, y_axis, z_axis)
|
||||||
|
|
||||||
def create_matrix(self, p, x, y, z):
|
def create_matrix(self, p: Vector, x: Vector, y: Vector, z: Vector) -> Matrix:
|
||||||
return Matrix([x, y, z, p]).to_4x4().transposed()
|
return Matrix([x, y, z, p]).to_4x4().transposed()
|
||||||
|
|
||||||
def get_profile_axis(self, obj):
|
def get_profile_axis(self, obj: bpy.types.Object) -> list[Vector]:
|
||||||
z_values = [v[2] for v in obj.bound_box]
|
z_values = [v[2] for v in obj.bound_box]
|
||||||
return [
|
return [
|
||||||
(obj.matrix_world @ Vector((0.0, 0.0, min(z_values)))),
|
(obj.matrix_world @ Vector((0.0, 0.0, min(z_values)))),
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import inspect
|
|||||||
import collections
|
import collections
|
||||||
import importlib
|
import importlib
|
||||||
import importlib.util
|
import importlib.util
|
||||||
from typing import Union, Iterable, Optional, Any, TypedDict, Literal
|
from typing import Union, Iterable, Optional, Any, TypedDict, Literal, Sequence
|
||||||
from typing_extensions import NotRequired
|
from typing_extensions import NotRequired
|
||||||
|
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ class ArgumentsDict(TypedDict):
|
|||||||
file: NotRequired[ifcopenshell.file]
|
file: NotRequired[ifcopenshell.file]
|
||||||
input: NotRequired[str]
|
input: NotRequired[str]
|
||||||
log: NotRequired[str]
|
log: NotRequired[str]
|
||||||
arguments: NotRequired[list]
|
arguments: NotRequired[Sequence[Any]]
|
||||||
|
|
||||||
|
|
||||||
def execute(args: ArgumentsDict) -> Union[ifcopenshell.file, str]:
|
def execute(args: ArgumentsDict) -> Union[ifcopenshell.file, str]:
|
||||||
|
|||||||
Reference in New Issue
Block a user