This commit is contained in:
Andrej730
2025-01-17 15:23:59 +05:00
parent e1da08579c
commit 686a5e7387
+8 -9
View File
@@ -662,28 +662,27 @@ class Model(bonsai.core.tool.Model):
return "PROFILE" return "PROFILE"
@classmethod @classmethod
def get_wall_axis( def get_wall_axis(cls, obj: bpy.types.Object, layers: Optional[dict[str, Any]] = None) -> dict[str, list[Vector]]:
cls, obj: bpy.types.Object, layers: Optional[dict[str, Any]] = None """Each item of a resulting dictionary is a list of 2 2D vectors."""
) -> dict[str, tuple[Vector, Vector]]:
x_values = [v[0] for v in obj.bound_box] x_values = [v[0] for v in obj.bound_box]
min_x = min(x_values) min_x = min(x_values)
max_x = max(x_values) max_x = max(x_values)
axes = {} axes = {}
if layers: if layers:
axes = { axes = {
"base": ( "base": [
(obj.matrix_world @ Vector((min_x, layers["offset"], 0.0))).to_2d(), (obj.matrix_world @ Vector((min_x, layers["offset"], 0.0))).to_2d(),
(obj.matrix_world @ Vector((max_x, layers["offset"], 0.0))).to_2d(), (obj.matrix_world @ Vector((max_x, layers["offset"], 0.0))).to_2d(),
), ],
"side": ( "side": [
(obj.matrix_world @ Vector((min_x, layers["offset"] + layers["thickness"], 0.0))).to_2d(), (obj.matrix_world @ Vector((min_x, layers["offset"] + layers["thickness"], 0.0))).to_2d(),
(obj.matrix_world @ Vector((max_x, layers["offset"] + layers["thickness"], 0.0))).to_2d(), (obj.matrix_world @ Vector((max_x, layers["offset"] + layers["thickness"], 0.0))).to_2d(),
), ],
} }
axes["reference"] = ( axes["reference"] = [
(obj.matrix_world @ Vector((min_x, 0.0, 0.0))).to_2d(), (obj.matrix_world @ Vector((min_x, 0.0, 0.0))).to_2d(),
(obj.matrix_world @ Vector((max_x, 0.0, 0.0))).to_2d(), (obj.matrix_world @ Vector((max_x, 0.0, 0.0))).to_2d(),
) ]
return axes return axes
@classmethod @classmethod