mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
See #5938. Correctly detect negative extrusion depths and directions.
This commit is contained in:
@@ -134,7 +134,7 @@ def update_bim_tool_props():
|
||||
if AuthoringData.data["active_material_usage"] == "LAYER2":
|
||||
x_angle = get_x_angle(extrusion)
|
||||
axis = tool.Model.get_wall_axis(obj)["reference"]
|
||||
props.extrusion_depth = extrusion.Depth * si_conversion * cos(x_angle)
|
||||
props.extrusion_depth = abs(extrusion.Depth * si_conversion * cos(x_angle))
|
||||
props.length = (axis[1] - axis[0]).length
|
||||
props.x_angle = x_angle
|
||||
|
||||
|
||||
@@ -454,7 +454,7 @@ class Helper:
|
||||
x_axis = (mesh.vertices[loop[0]].co - center).normalized()
|
||||
else:
|
||||
x_axis = (mesh.vertices[loop[1]].co - mesh.vertices[loop[0]].co).normalized()
|
||||
z_axis = profile_face.polygons[0].normal.normalized() * (-1)
|
||||
z_axis = profile_face.polygons[0].normal.normalized() * -1
|
||||
y_axis = z_axis.cross(x_axis).normalized()
|
||||
matrix = Matrix((x_axis, y_axis, z_axis))
|
||||
matrix.normalize()
|
||||
|
||||
@@ -97,6 +97,12 @@ def update_slab_direction_decorator(self, context):
|
||||
SlabDirectionDecorator.uninstall()
|
||||
|
||||
|
||||
def update_x_angle(self, context):
|
||||
angle_deg = math.degrees(self.x_angle)
|
||||
if tool.Cad.is_x(angle_deg, -90, 0.5) or tool.Cad.is_x(angle_deg, 90, 0.5):
|
||||
self.x_angle = 0
|
||||
|
||||
|
||||
class BIMModelProperties(PropertyGroup):
|
||||
ifc_class: bpy.props.EnumProperty(items=get_ifc_class, name="Construction Class", update=update_ifc_class)
|
||||
relating_type_id: bpy.props.EnumProperty(
|
||||
@@ -161,7 +167,7 @@ class BIMModelProperties(PropertyGroup):
|
||||
rl2: bpy.props.FloatProperty(name="RL", default=1, subtype="DISTANCE", description="Z offset for windows")
|
||||
# Used for plan calculation points such as in room generation
|
||||
rl3: bpy.props.FloatProperty(name="RL", default=1, subtype="DISTANCE", description="Z offset for space calculation")
|
||||
x_angle: bpy.props.FloatProperty(name="X Angle", default=0, subtype="ANGLE", min=-pi / 180 * 89, max=pi / 180 * 89)
|
||||
x_angle: bpy.props.FloatProperty(name="X Angle", default=0, subtype="ANGLE", min=math.radians(-180), max=math.radians(180), update=update_x_angle)
|
||||
type_page: bpy.props.IntProperty(name="Type Page", default=1, update=update_type_page)
|
||||
type_name: bpy.props.StringProperty(name="Name", default="TYPEX")
|
||||
boundary_class: bpy.props.EnumProperty(items=get_boundary_class, name="Boundary Class")
|
||||
|
||||
@@ -40,7 +40,9 @@ class AssignType(bpy.types.Operator, tool.Ifc.Operator):
|
||||
related_object: bpy.props.StringProperty()
|
||||
|
||||
def _execute(self, context):
|
||||
type = tool.Ifc.get().by_id(self.relating_type or int(context.active_object.BIMTypeProperties.relating_type))
|
||||
relating_type = tool.Ifc.get().by_id(
|
||||
self.relating_type or int(context.active_object.BIMTypeProperties.relating_type)
|
||||
)
|
||||
related_objects = (
|
||||
[bpy.data.objects.get(self.related_object)]
|
||||
if self.related_object
|
||||
@@ -49,9 +51,9 @@ class AssignType(bpy.types.Operator, tool.Ifc.Operator):
|
||||
model_props = context.scene.BIMModelProperties
|
||||
for obj in related_objects:
|
||||
element = tool.Ifc.get_entity(obj)
|
||||
core.assign_type(tool.Ifc, tool.Type, element=element, type=type)
|
||||
core.assign_type(tool.Ifc, tool.Type, element=element, type=relating_type)
|
||||
if model_props.occurrence_name_style == "TYPE":
|
||||
obj.name = tool.Model.generate_occurrence_name(type, element.is_a())
|
||||
obj.name = tool.Model.generate_occurrence_name(relating_type, element.is_a())
|
||||
|
||||
|
||||
class UnassignType(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
@@ -144,7 +144,7 @@ class Blender(bonsai.core.tool.Blender):
|
||||
|
||||
@classmethod
|
||||
def get_active_object(cls) -> bpy.types.Object:
|
||||
return bpy.context.view_layer.objects.active or bpy.context.active_object
|
||||
return bpy.context.view_layer.objects.active or getattr(bpy.context, "active_object", None)
|
||||
|
||||
@classmethod
|
||||
def get_selected_objects(cls) -> set[bpy.types.Object]:
|
||||
|
||||
Reference in New Issue
Block a user