From f9b83686ac130af1d7627d95e2c2f81d5f17e577 Mon Sep 17 00:00:00 2001 From: Tristan Strathearn Date: Sun, 15 Jan 2023 11:30:14 +1000 Subject: [PATCH] feat: add scene unit scale support for operator overlay values --- bevels/bevel.py | 6 ++++-- bevels/edge_bevel.py | 6 ++++-- bevels/vertex_bevel.py | 6 ++++-- bevels/weighted_normal_bevel.py | 6 ++++-- booleans/boolean_inset.py | 6 ++++-- extrusion/profile_extrude.py | 10 ++++++---- extrusion/screw.py | 4 +++- extrusion/solidify.py | 12 +++++++----- replicate/array_cubed.py | 4 +++- replicate/circular_array.py | 6 ++++-- sketch/panel.py | 6 ++++-- sketch/recon_poly.py | 10 ++++++---- sketch/screw_head.py | 6 ++++-- 13 files changed, 57 insertions(+), 31 deletions(-) diff --git a/bevels/bevel.py b/bevels/bevel.py index 85224f2..a02c309 100644 --- a/bevels/bevel.py +++ b/bevels/bevel.py @@ -305,11 +305,13 @@ def revert(self, context): def draw_text_callback(self): draw_header(self) + + unit_scale = 1000 * bpy.data.scenes["Scene"].unit_settings.scale_length draw_property( self, - "Width: {0:.2f}".format(self.width * 1000), - "(±{0:.2f}) | Shift (±{1:.2f})".format(self.base_width_factor * 1000, (self.base_width_factor / 10) * 1000), + "Width: {0:.2f}".format(self.width * unit_scale), + "(±{0:.2f}) | Shift (±{1:.2f})".format(self.base_width_factor * unit_scale, (self.base_width_factor / 10) * unit_scale), active=self.key_no_modifiers, alt_mode=self.key_shift_no_modifiers, mouse_value=True, diff --git a/bevels/edge_bevel.py b/bevels/edge_bevel.py index e504757..05632fd 100644 --- a/bevels/edge_bevel.py +++ b/bevels/edge_bevel.py @@ -365,10 +365,12 @@ def revert(self, context): def draw_text_callback(self): draw_header(self) + + unit_scale = 1000 * bpy.data.scenes["Scene"].unit_settings.scale_length draw_property( self, - "Weight: {0:.2f} ({1:.2f})".format(self.weight, self.width * 1000 * self.weight), + "Weight: {0:.2f} ({1:.2f})".format(self.weight, self.width * unit_scale * self.weight), "(±0.1) | Shift (±0.01)", active=self.key_no_modifiers, alt_mode=self.key_shift_no_modifiers, @@ -395,7 +397,7 @@ def draw_text_callback(self): draw_property( self, - "Width: {0:.2f}".format(self.width * 1000), + "Width: {0:.2f}".format(self.width * unit_scale), "Ctrl + Alt (±100) | Shift + Ctrl + Alt (±10)", active=self.key_ctrl_alt, alt_mode=self.key_shift_ctrl_alt, diff --git a/bevels/vertex_bevel.py b/bevels/vertex_bevel.py index 2edc267..073a446 100644 --- a/bevels/vertex_bevel.py +++ b/bevels/vertex_bevel.py @@ -356,10 +356,12 @@ def revert(self, context): def draw_text_callback(self): draw_header(self) + unit_scale = 1000 * bpy.data.scenes["Scene"].unit_settings.scale_length + draw_property( self, - "Width: {0:.2f}".format(self.width * 1000), - "(±{0:.2f}) | Shift (±{1:.2f})".format(self.base_width_factor * 1000, (self.base_width_factor / 10) * 1000), + "Width: {0:.2f}".format(self.width * unit_scale), + "(±{0:.2f}) | Shift (±{1:.2f})".format(self.base_width_factor * unit_scale, (self.base_width_factor / 10) * unit_scale), active=self.key_no_modifiers, alt_mode=self.key_shift_no_modifiers, mouse_value=True, diff --git a/bevels/weighted_normal_bevel.py b/bevels/weighted_normal_bevel.py index f615ff1..c3059c0 100644 --- a/bevels/weighted_normal_bevel.py +++ b/bevels/weighted_normal_bevel.py @@ -237,11 +237,13 @@ def revert(self, context): def draw_text_callback(self): draw_header(self) + + unit_scale = 1000 * bpy.data.scenes["Scene"].unit_settings.scale_length draw_property( self, - "Width: {0:.2f}".format(self.width * 1000), - "(±{0:.2f}) | Shift (±{1:.2f})".format(self.base_width_factor * 1000, (self.base_width_factor / 10) * 1000), + "Width: {0:.2f}".format(self.width * unit_scale), + "(±{0:.2f}) | Shift (±{1:.2f})".format(self.base_width_factor * unit_scale, (self.base_width_factor / 10) * unit_scale), active=self.key_no_modifiers, alt_mode=self.key_shift_no_modifiers, mouse_value=True, diff --git a/booleans/boolean_inset.py b/booleans/boolean_inset.py index b621f7c..757de1a 100644 --- a/booleans/boolean_inset.py +++ b/booleans/boolean_inset.py @@ -233,10 +233,12 @@ def revert(self, context): def draw_text_callback(self): draw_header(self) + unit_scale = 1000 * bpy.data.scenes["Scene"].unit_settings.scale_length + draw_property( self, - "Thickness: {0:.2f}".format(self.thickness * 1000), - "(±{0:.2f}) | Shift + (±{1:.2f})".format(self.base_thickness_factor * 1000, (self.base_thickness_factor / 10) * 1000), + "Thickness: {0:.2f}".format(self.thickness * unit_scale), + "(±{0:.2f}) | Shift + (±{1:.2f})".format(self.base_thickness_factor * unit_scale, (self.base_thickness_factor / 10) * unit_scale), active=self.key_no_modifiers, alt_mode=self.key_shift_no_modifiers, mouse_value=True, diff --git a/extrusion/profile_extrude.py b/extrusion/profile_extrude.py index 2d28ae2..b72dab8 100644 --- a/extrusion/profile_extrude.py +++ b/extrusion/profile_extrude.py @@ -306,10 +306,12 @@ def revert(self, context): def draw_text_callback(self): draw_header(self) + unit_scale = 1000 * bpy.data.scenes["Scene"].unit_settings.scale_length + draw_property( self, - "Extrusion: {0:.2f}".format(self.extrusion_length * 1000), - "(±{0:.2f}) | Shift + (±{1:.2f})".format(self.base_extrude_factor * 1000, (self.base_extrude_factor / 10) * 1000), + "Extrusion: {0:.2f}".format(self.extrusion_length * unit_scale), + "(±{0:.2f}) | Shift + (±{1:.2f})".format(self.base_extrude_factor * unit_scale, (self.base_extrude_factor / 10) * unit_scale), active=self.key_no_modifiers, alt_mode=self.key_shift_no_modifiers, mouse_value=True, @@ -317,8 +319,8 @@ def draw_text_callback(self): draw_property( self, - "Offset: {0:.2f}".format(self.offset * 1000), - "Ctrl (±{0:.2f}) | Shift + Ctrl (±{1:.2f})".format(self.base_offset_factor * 1000, (self.base_offset_factor / 10) * 1000), + "Offset: {0:.2f}".format(self.offset * unit_scale), + "Ctrl (±{0:.2f}) | Shift + Ctrl (±{1:.2f})".format(self.base_offset_factor * unit_scale, (self.base_offset_factor / 10) * unit_scale), active=self.key_ctrl, alt_mode=self.key_shift_ctrl, mouse_value=True, diff --git a/extrusion/screw.py b/extrusion/screw.py index 2267d28..72e4107 100644 --- a/extrusion/screw.py +++ b/extrusion/screw.py @@ -317,6 +317,8 @@ def revert(self, context): def draw_text_callback(self): draw_header(self) + unit_scale = 1000 * bpy.data.scenes["Scene"].unit_settings.scale_length + draw_property( self, "Segments: {}".format(self.segments), @@ -339,7 +341,7 @@ def draw_text_callback(self): draw_property( self, "Offset: {0:.2f}".format(self.offset), - "Ctrl (±{0:.2f}) | Shift + Ctrl (±{1:.2f})".format(self.base_offset_factor * 1000, (self.base_offset_factor / 10) * 1000), + "Ctrl (±{0:.2f}) | Shift + Ctrl (±{1:.2f})".format(self.base_offset_factor * unit_scale, (self.base_offset_factor / 10) * unit_scale), active=self.key_ctrl, alt_mode=self.key_shift_ctrl, mouse_value=True, diff --git a/extrusion/solidify.py b/extrusion/solidify.py index d671e07..018e0e9 100644 --- a/extrusion/solidify.py +++ b/extrusion/solidify.py @@ -260,19 +260,21 @@ def revert(self, context): def draw_text_callback(self): draw_header(self) + unit_scale = 1000 * bpy.data.scenes["Scene"].unit_settings.scale_length + draw_property( self, - "Thickness: {0:.2f}".format(self.thickness * 1000), - "(±{0:.2f}) | Shift + (±{1:.2f})".format(self.base_thickness_factor * 1000, (self.base_thickness_factor / 10) * 1000), + "Thickness: {0:.2f}".format(self.thickness * unit_scale), + "(±{0:.2f}) | Shift + (±{1:.2f})".format(self.base_thickness_factor * unit_scale, (self.base_thickness_factor / 10) * unit_scale), active=self.key_no_modifiers, alt_mode=self.key_shift_no_modifiers, mouse_value=True, input_stream=self.thickness_input_stream) draw_property( - self, - "Offset: {0:.2f}".format(self.offset * 1000), - "Ctrl (±{0:.2f}) | Shift + Ctrl (±{1:.2f})".format(self.base_offset_factor * 1000, (self.base_offset_factor / 10) * 1000), + self, + "Offset: {0:.2f}".format(self.offset * unit_scale), + "Ctrl (±{0:.2f}) | Shift + Ctrl (±{1:.2f})".format(self.base_offset_factor * unit_scale, (self.base_offset_factor / 10) * unit_scale), active=self.key_ctrl, alt_mode=self.key_shift_ctrl, mouse_value=True, diff --git a/replicate/array_cubed.py b/replicate/array_cubed.py index ecdcaf7..da64147 100644 --- a/replicate/array_cubed.py +++ b/replicate/array_cubed.py @@ -269,6 +269,8 @@ def revert(self, context): def draw_text_callback(self): draw_header(self) + unit_scale = 1000 * bpy.data.scenes["Scene"].unit_settings.scale_length + draw_property( self, "Count: {0}".format(self.axes[self.axis][1]), @@ -281,7 +283,7 @@ def draw_text_callback(self): draw_property( self, "Offset: {0:.2f}".format(self.axes[self.axis][2]), - "Ctrl (±{0:.2f}) | Shift + Ctrl (±{1:.2f})".format(self.base_offset_factor * 1000, (self.base_offset_factor / 10) * 1000), + "Ctrl (±{0:.2f}) | Shift + Ctrl (±{1:.2f})".format(self.base_offset_factor * unit_scale, (self.base_offset_factor / 10) * unit_scale), active=self.key_ctrl, alt_mode=self.key_shift_ctrl, mouse_value=True, diff --git a/replicate/circular_array.py b/replicate/circular_array.py index 5a9989d..a4761b4 100644 --- a/replicate/circular_array.py +++ b/replicate/circular_array.py @@ -400,6 +400,8 @@ def revert(self, context): def draw_text_callback(self): draw_header(self) + unit_scale = 1000 * bpy.data.scenes["Scene"].unit_settings.scale_length + draw_property( self, "Count: {}".format(self.count), @@ -420,8 +422,8 @@ def draw_text_callback(self): draw_property( self, - "Offset: {0:.2f}".format(self.offset * 1000), - "Ctrl (±{0:.2f}) | Shift + Ctrl (±{1:.2f})".format(self.base_offset_factor * 1000, (self.base_offset_factor / 10) * 1000), + "Offset: {0:.2f}".format(self.offset * unit_scale), + "Ctrl (±{0:.2f}) | Shift + Ctrl (±{1:.2f})".format(self.base_offset_factor * unit_scale, (self.base_offset_factor / 10) * unit_scale), active=self.key_ctrl, alt_mode=self.key_shift_ctrl, mouse_value=True, diff --git a/sketch/panel.py b/sketch/panel.py index a758d3d..3964ff4 100644 --- a/sketch/panel.py +++ b/sketch/panel.py @@ -281,14 +281,16 @@ def revert(self, context): def draw_text_callback(self): draw_header(self) + unit_scale = 1000 * bpy.data.scenes["Scene"].unit_settings.scale_length + if self.stage == 0: draw_hint(self, "Confirm Geometry [Space]", "Comfirm the geometry to extract") if self.stage == 1: draw_property( self, - "Inset Amount: {0:.2f}".format(self.inset * 1000), - "(±{0:.2f}) | Shift (±{1:.2f})".format(self.base_inset_factor * 1000, (self.base_inset_factor / 10) * 1000), + "Inset Amount: {0:.2f}".format(self.inset * unit_scale), + "(±{0:.2f}) | Shift (±{1:.2f})".format(self.base_inset_factor * unit_scale, (self.base_inset_factor / 10) * unit_scale), active=self.key_no_modifiers, alt_mode=self.key_shift_no_modifiers, mouse_value=True, diff --git a/sketch/recon_poly.py b/sketch/recon_poly.py index 080536b..9a54ef5 100644 --- a/sketch/recon_poly.py +++ b/sketch/recon_poly.py @@ -413,10 +413,12 @@ def revert(self, context): def draw_text_callback(self): draw_header(self) + unit_scale = 1000 * bpy.data.scenes["Scene"].unit_settings.scale_length + draw_property( self, - "{0}: {1:.2f}".format("Width" if self.inner_radius > 0 else "Radius", self.width * 1000), - "(±{0:.2f}) | Shift (±{1:.2f})".format(self.base_width_factor * 1000, (self.base_width_factor / 10) * 1000), + "{0}: {1:.2f}".format("Width" if self.inner_radius > 0 else "Radius", self.width * unit_scale), + "(±{0:.2f}) | Shift (±{1:.2f})".format(self.base_width_factor * unit_scale, (self.base_width_factor / 10) * unit_scale), active=self.key_no_modifiers, alt_mode=self.key_shift_no_modifiers, mouse_value=True, @@ -433,8 +435,8 @@ def draw_text_callback(self): draw_property( self, - "Inner Radius: {0:.2f}".format(self.inner_radius * 1000), - "Ctrl (±{0:.2f}) | Shift + Ctrl (±{1:.2f})".format(self.base_inner_radius_factor * 1000, (self.base_inner_radius_factor / 10) * 1000), + "Inner Radius: {0:.2f}".format(self.inner_radius * unit_scale), + "Ctrl (±{0:.2f}) | Shift + Ctrl (±{1:.2f})".format(self.base_inner_radius_factor * unit_scale, (self.base_inner_radius_factor / 10) * unit_scale), active=self.key_ctrl, alt_mode=self.key_shift_ctrl, mouse_value=True, diff --git a/sketch/screw_head.py b/sketch/screw_head.py index e749b54..0cdd874 100644 --- a/sketch/screw_head.py +++ b/sketch/screw_head.py @@ -252,6 +252,8 @@ def revert(self, context): def draw_text_callback(self): draw_header(self) + unit_scale = 1000 * bpy.data.scenes["Scene"].unit_settings.scale_length + draw_property( self, "Type: {0}".format(self.objects[self.head_type_index][1]), @@ -271,8 +273,8 @@ def draw_text_callback(self): draw_property( self, - "Offset: {0:.2f}".format(self.offset * 1000), - "Ctrl (±{0:.2f}) | Shift + Ctrl (±{1:.2f})".format(self.base_offset_factor * 1000, (self.base_offset_factor / 10) * 1000), + "Offset: {0:.2f}".format(self.offset * unit_scale), + "Ctrl (±{0:.2f}) | Shift + Ctrl (±{1:.2f})".format(self.base_offset_factor * unit_scale, (self.base_offset_factor / 10) * unit_scale), active=self.key_ctrl, alt_mode=self.key_shift_ctrl, mouse_value=True,