From e9b8edb5b2f5d7b438003551b183ac6ce4db083e Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Thu, 28 Mar 2024 12:37:08 +0500 Subject: [PATCH] use blender units subtype for cad props --- src/blenderbim/blenderbim/bim/module/cad/prop.py | 8 ++++---- .../blenderbim/bim/module/cad/workspace.py | 15 ++++++++++----- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/cad/prop.py b/src/blenderbim/blenderbim/bim/module/cad/prop.py index daf4346716..ed795a74aa 100644 --- a/src/blenderbim/blenderbim/bim/module/cad/prop.py +++ b/src/blenderbim/blenderbim/bim/module/cad/prop.py @@ -24,10 +24,10 @@ from math import pi class BIMCadProperties(PropertyGroup): resolution: bpy.props.IntProperty(name="Arc Resolution", min=1, default=1) - radius: bpy.props.FloatProperty(name="Radius", default=0.1) - distance: bpy.props.FloatProperty(name="Distance", default=0.1) - x: bpy.props.FloatProperty(name="X", default=0.2) - y: bpy.props.FloatProperty(name="Y", default=0.1) + radius: bpy.props.FloatProperty(name="Radius", default=0.1, subtype="DISTANCE") + distance: bpy.props.FloatProperty(name="Distance", default=0.1, subtype="DISTANCE") + x: bpy.props.FloatProperty(name="X", default=0.2, subtype="DISTANCE") + y: bpy.props.FloatProperty(name="Y", default=0.1, subtype="DISTANCE") gable_roof_edge_angle: bpy.props.FloatProperty( name="Gable Roof Edge Angle", default=pi / 2, soft_min=0, soft_max=pi / 2, subtype="ANGLE" ) diff --git a/src/blenderbim/blenderbim/bim/module/cad/workspace.py b/src/blenderbim/blenderbim/bim/module/cad/workspace.py index 60b04dfc9a..e5b8e33d0a 100644 --- a/src/blenderbim/blenderbim/bim/module/cad/workspace.py +++ b/src/blenderbim/blenderbim/bim/module/cad/workspace.py @@ -20,6 +20,7 @@ import os import bpy import blenderbim.tool as tool import blenderbim.bim.module.type.prop as type_prop +import ifcopenshell.util.unit from bpy.types import WorkSpaceTool from blenderbim.bim.module.model.data import AuthoringData, RailingData, RoofData @@ -239,8 +240,9 @@ class CadHotkey(bpy.types.Operator): row.prop(props, "resolution") def hotkey_S_C(self): + si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get()) if self.is_profile(): - bpy.ops.bim.add_ifccircle(radius=self.props.radius) + bpy.ops.bim.add_ifccircle(radius=self.props.radius / si_conversion) else: bpy.ops.bim.cad_arc_from_2_points() @@ -248,13 +250,15 @@ class CadHotkey(bpy.types.Operator): bpy.ops.bim.cad_trim_extend() def hotkey_S_F(self): + si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get()) if self.is_profile(): - bpy.ops.bim.add_ifcarcindex_fillet(radius=self.props.radius) + bpy.ops.bim.add_ifcarcindex_fillet(radius=self.props.radius / si_conversion) else: - bpy.ops.bim.cad_fillet(resolution=self.props.resolution, radius=self.props.radius) + bpy.ops.bim.cad_fillet(resolution=self.props.resolution, radius=self.props.radius / si_conversion) def hotkey_S_O(self): - bpy.ops.bim.cad_offset(distance=self.props.distance) + si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get()) + bpy.ops.bim.cad_offset(distance=self.props.distance / si_conversion) def hotkey_S_Q(self): element = tool.Ifc.get_entity(bpy.context.active_object) @@ -270,7 +274,8 @@ class CadHotkey(bpy.types.Operator): def hotkey_S_R(self): if self.is_profile(): - bpy.ops.bim.add_rectangle(x=self.props.x, y=self.props.y) + si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get()) + bpy.ops.bim.add_rectangle(x=self.props.x / si_conversion, y=self.props.y / si_conversion) elif ( (RoofData.is_loaded or not RoofData.load()) and RoofData.data["pset_data"]