From b4b6404b65943b9c3dae45ca0f4f8c97e76dbd8b Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Wed, 19 Apr 2023 17:30:59 +0500 Subject: [PATCH] Added DISTANCE subtype to BIM Tool Extrusion Depth and Length In BIM Tool it looks like this right now - https://i.imgur.com/JWVPssg.png (note the units) Previously it was displaying value like this - https://i.imgur.com/244aYTN.png The benefit is that you can specify other units in that kind of property and it will automatically convert to current project's unit. For example if you have millimeters as project's unit you can still type "10m" instead of "5000" and it will automatically convert it to 5000mm. Or type in inches like 5" 11'. --- src/blenderbim/blenderbim/bim/module/model/profile.py | 6 ++---- src/blenderbim/blenderbim/bim/module/model/prop.py | 4 ++-- src/blenderbim/blenderbim/bim/module/model/wall.py | 7 +++---- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/model/profile.py b/src/blenderbim/blenderbim/bim/module/model/profile.py index 6fbfb1680a..143459558e 100644 --- a/src/blenderbim/blenderbim/bim/module/model/profile.py +++ b/src/blenderbim/blenderbim/bim/module/model/profile.py @@ -260,7 +260,7 @@ class DumbProfileJoiner: body[1 if connection == "ATEND" else 0] = intersect self.recreate_profile(element1, profile1, axis, body) - def set_depth(self, profile1, length): + def set_depth(self, profile1, si_length): element1 = tool.Ifc.get_entity(profile1) if not element1: return @@ -270,8 +270,6 @@ class DumbProfileJoiner: axis1 = self.get_profile_axis(profile1) axis = copy.deepcopy(axis1) body = copy.deepcopy(axis1) - unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get()) - si_length = unit_scale * length end = profile1.matrix_world @ Vector((0, 0, si_length)) axis[1] = end body[1] = end @@ -977,5 +975,5 @@ class EditExtrusionAxis(bpy.types.Operator, tool.Ifc.Operator): bpy.context.view_layer.update() joiner = DumbProfileJoiner() - joiner.set_depth(obj, depth / self.unit_scale) + joiner.set_depth(obj, depth) return {"FINISHED"} diff --git a/src/blenderbim/blenderbim/bim/module/model/prop.py b/src/blenderbim/blenderbim/bim/module/model/prop.py index 874c8c4a98..80f4743e48 100644 --- a/src/blenderbim/blenderbim/bim/module/model/prop.py +++ b/src/blenderbim/blenderbim/bim/module/model/prop.py @@ -86,7 +86,7 @@ class BIMModelProperties(PropertyGroup): ) occurrence_name_function: bpy.props.StringProperty(name="Occurrence Name Function") getter_enum = {"ifc_class": get_ifc_class, "relating_type": get_relating_type_id} - extrusion_depth: bpy.props.FloatProperty(default=42.0) + extrusion_depth: bpy.props.FloatProperty(default=42.0, subtype="DISTANCE") cardinal_point: bpy.props.EnumProperty( items=( # TODO: complain to buildingSMART @@ -113,7 +113,7 @@ class BIMModelProperties(PropertyGroup): name="Cardinal Point", default="5", ) - length: bpy.props.FloatProperty(default=42.0) + length: bpy.props.FloatProperty(default=42.0, subtype="DISTANCE") openings: bpy.props.CollectionProperty(type=ObjProperty) x: bpy.props.FloatProperty(name="X", default=0.5) y: bpy.props.FloatProperty(name="Y", default=0.5) diff --git a/src/blenderbim/blenderbim/bim/module/model/wall.py b/src/blenderbim/blenderbim/bim/module/model/wall.py index 2178a08da3..4e266d9dbf 100644 --- a/src/blenderbim/blenderbim/bim/module/model/wall.py +++ b/src/blenderbim/blenderbim/bim/module/model/wall.py @@ -207,6 +207,7 @@ class ChangeExtrusionDepth(bpy.types.Operator, tool.Ifc.Operator): def _execute(self, context): layer2_objs = [] + si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get()) for obj in context.selected_objects: element = tool.Ifc.get_entity(obj) if not element: @@ -219,7 +220,7 @@ class ChangeExtrusionDepth(bpy.types.Operator, tool.Ifc.Operator): return x, y, z = extrusion.ExtrudedDirection.DirectionRatios x_angle = Vector((0, 1)).angle_signed(Vector((y, z))) - extrusion.Depth = self.depth * (1 / cos(x_angle)) + extrusion.Depth = self.depth / si_conversion * (1 / cos(x_angle)) if tool.Model.get_usage_type(element) == "LAYER2": for rel in element.ConnectedFrom: if rel.is_a() == "IfcRelConnectsElements": @@ -996,7 +997,7 @@ class DumbWallJoiner: self.recreate_wall(element1, wall1, axis, body) - def set_length(self, wall1, length): + def set_length(self, wall1, si_length): element1 = tool.Ifc.get_entity(wall1) if not element1: return @@ -1006,8 +1007,6 @@ class DumbWallJoiner: axis1 = tool.Model.get_wall_axis(wall1) axis = copy.deepcopy(axis1["reference"]) body = copy.deepcopy(axis1["reference"]) - unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get()) - si_length = unit_scale * length end = (wall1.matrix_world @ Vector((si_length, 0, 0))).to_2d() axis[1] = end body[1] = end