mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 22:11:36 +00:00
Fix issue with updating slab offset with negative direction sense.
This commit is contained in:
@@ -300,8 +300,9 @@ class DumbSlabPlaner:
|
|||||||
existing_x_angle = tool.Model.get_existing_x_angle(extrusion)
|
existing_x_angle = tool.Model.get_existing_x_angle(extrusion)
|
||||||
existing_x_angle = 0 if tool.Cad.is_x(existing_x_angle, 0, tolerance=0.001) else existing_x_angle
|
existing_x_angle = 0 if tool.Cad.is_x(existing_x_angle, 0, tolerance=0.001) else existing_x_angle
|
||||||
existing_x_angle = 0 if tool.Cad.is_x(existing_x_angle, pi, tolerance=0.001) else existing_x_angle
|
existing_x_angle = 0 if tool.Cad.is_x(existing_x_angle, pi, tolerance=0.001) else existing_x_angle
|
||||||
|
existing_x_angle = 0 if tool.Cad.is_x(existing_x_angle, 2*pi, tolerance=0.001) else existing_x_angle
|
||||||
direction_ratios = Vector(extrusion.ExtrudedDirection.DirectionRatios)
|
direction_ratios = Vector(extrusion.ExtrudedDirection.DirectionRatios)
|
||||||
offset_direction = direction_ratios.copy()
|
offset_direction = Vector((abs(direction_ratios.x), abs(direction_ratios.y), abs(direction_ratios.z))) # The offset direction doesn't change with direction sense
|
||||||
perpendicular_depth = thickness * abs(1 / cos(existing_x_angle))
|
perpendicular_depth = thickness * abs(1 / cos(existing_x_angle))
|
||||||
perpendicular_offset = layer_params["offset"] * abs(1 / cos(existing_x_angle)) / self.unit_scale
|
perpendicular_offset = layer_params["offset"] * abs(1 / cos(existing_x_angle)) / self.unit_scale
|
||||||
|
|
||||||
@@ -311,19 +312,15 @@ class DumbSlabPlaner:
|
|||||||
):
|
):
|
||||||
# The extrusion direction is positive. If the layer_parameter is set to negative,
|
# The extrusion direction is positive. If the layer_parameter is set to negative,
|
||||||
# then the we change the extrusion direction.
|
# then the we change the extrusion direction.
|
||||||
# The offset direction must always be positive, so we keep it.
|
|
||||||
if layer_params["direction_sense"] == "NEGATIVE":
|
if layer_params["direction_sense"] == "NEGATIVE":
|
||||||
direction_ratios *= -1
|
direction_ratios *= -1
|
||||||
# offset_direction *= -1
|
|
||||||
elif (abs(existing_x_angle) > (pi / 2) and direction_ratios.z > 0) or (
|
elif (abs(existing_x_angle) > (pi / 2) and direction_ratios.z > 0) or (
|
||||||
abs(existing_x_angle) < (pi / 2) and direction_ratios.z < 0
|
abs(existing_x_angle) < (pi / 2) and direction_ratios.z < 0
|
||||||
):
|
):
|
||||||
# The extrusion direction is negative. If the layer_parameter is set to positive,
|
# The extrusion direction is negative. If the layer_parameter is set to positive,
|
||||||
# then the we change the extrusion direction.
|
# then the we change the extrusion direction.
|
||||||
# The offset direction must always be positive, so we change it too.
|
|
||||||
if layer_params["direction_sense"] == "POSITIVE":
|
if layer_params["direction_sense"] == "POSITIVE":
|
||||||
direction_ratios *= -1
|
direction_ratios *= -1
|
||||||
offset_direction *= -1
|
|
||||||
|
|
||||||
extrusion.ExtrudedDirection.DirectionRatios = tuple(direction_ratios)
|
extrusion.ExtrudedDirection.DirectionRatios = tuple(direction_ratios)
|
||||||
extrusion.Depth = perpendicular_depth
|
extrusion.Depth = perpendicular_depth
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ class ChangeExtrusionXAngle(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
layer_params = tool.Model.get_material_layer_parameters(element)
|
layer_params = tool.Model.get_material_layer_parameters(element)
|
||||||
perpendicular_depth = layer_params["thickness"] * abs(1 / cos(x_angle)) / unit_scale
|
perpendicular_depth = layer_params["thickness"] * abs(1 / cos(x_angle)) / unit_scale
|
||||||
perpendicular_offset = layer_params["offset"] * abs(1 / cos(x_angle)) / unit_scale
|
perpendicular_offset = layer_params["offset"] * abs(1 / cos(x_angle)) / unit_scale
|
||||||
offset_direction = direction_ratios.copy()
|
offset_direction = Vector((abs(direction_ratios.x), abs(direction_ratios.y), abs(direction_ratios.z))) # The offset direction doesn't change with direction sense
|
||||||
|
|
||||||
# Check angle and z direction to determine whether the extrusion direction is positive or negative
|
# Check angle and z direction to determine whether the extrusion direction is positive or negative
|
||||||
if (abs(x_angle) < (pi / 2) and direction_ratios.z > 0) or (
|
if (abs(x_angle) < (pi / 2) and direction_ratios.z > 0) or (
|
||||||
@@ -272,7 +272,6 @@ class ChangeExtrusionXAngle(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
):
|
):
|
||||||
# The extrusion direction is positive. If the layer_parameter is set to negative,
|
# The extrusion direction is positive. If the layer_parameter is set to negative,
|
||||||
# then the we change the extrusion direction.
|
# then the we change the extrusion direction.
|
||||||
# The offset direction must always be positive, so we keep it.
|
|
||||||
if layer_params["direction_sense"] == "NEGATIVE":
|
if layer_params["direction_sense"] == "NEGATIVE":
|
||||||
direction_ratios *= -1
|
direction_ratios *= -1
|
||||||
elif ((x_angle) > (pi / 2) and direction_ratios.z > 0) or (
|
elif ((x_angle) > (pi / 2) and direction_ratios.z > 0) or (
|
||||||
@@ -280,10 +279,8 @@ class ChangeExtrusionXAngle(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
):
|
):
|
||||||
# The extrusion direction is negative. If the layer_parameter is set to positive,
|
# The extrusion direction is negative. If the layer_parameter is set to positive,
|
||||||
# then the we change the extrusion direction.
|
# then the we change the extrusion direction.
|
||||||
# The offset direction must always be positive, so we change it too.
|
|
||||||
if layer_params["direction_sense"] == "POSITIVE":
|
if layer_params["direction_sense"] == "POSITIVE":
|
||||||
direction_ratios *= -1
|
direction_ratios *= -1
|
||||||
offset_direction *= -1
|
|
||||||
|
|
||||||
extrusion.ExtrudedDirection.DirectionRatios = tuple(direction_ratios)
|
extrusion.ExtrudedDirection.DirectionRatios = tuple(direction_ratios)
|
||||||
extrusion.Depth = perpendicular_depth
|
extrusion.Depth = perpendicular_depth
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ import bonsai.core.geometry
|
|||||||
import bonsai.core.tool
|
import bonsai.core.tool
|
||||||
import bonsai.tool as tool
|
import bonsai.tool as tool
|
||||||
import bonsai.core.geometry as geometry
|
import bonsai.core.geometry as geometry
|
||||||
from math import atan, cos, degrees, radians
|
from math import atan, cos, degrees, radians, pi
|
||||||
from mathutils import Matrix, Vector
|
from mathutils import Matrix, Vector
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from functools import partial
|
from functools import partial
|
||||||
@@ -2084,7 +2084,7 @@ class Model(bonsai.core.tool.Model):
|
|||||||
x, y, z = extrusion.ExtrudedDirection.DirectionRatios
|
x, y, z = extrusion.ExtrudedDirection.DirectionRatios
|
||||||
vector = Vector((0, 1))
|
vector = Vector((0, 1))
|
||||||
x_angle = vector.angle_signed(Vector((y, z)))
|
x_angle = vector.angle_signed(Vector((y, z)))
|
||||||
return x_angle
|
return x_angle if z > 0 else (x_angle + pi)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_axis_curve(cls, obj: bpy.types.Object, grid_axis: ifcopenshell.entity_instance) -> None:
|
def create_axis_curve(cls, obj: bpy.types.Object, grid_axis: ifcopenshell.entity_instance) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user