Wall polyline tool - refactor offset functionality

This commit is contained in:
Bruno Perdigão
2025-01-23 09:29:33 -03:00
parent 8b678309fd
commit d8342134a0
2 changed files with 17 additions and 21 deletions
@@ -72,17 +72,9 @@ def get_wall_preview_data(context, relating_type):
if direction_sense == "NEGATIVE":
direction = -1
offset_type = model_props.offset_type
offset = 0
if offset_type == "CENTER":
offset = -thickness / 2
elif offset_type == "INTERIOR":
offset = -thickness
# For the model properties, the offset value should just be converted
# However, for the wall preview logic that follows, offset and thickness must change direction
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
model_props.offset = offset / unit_scale
offset = model_props.offset * unit_scale
thickness *= direction
offset *= direction
+16 -12
View File
@@ -419,19 +419,23 @@ class DrawPolylineWall(bpy.types.Operator, PolylineOperator):
"NEGATIVE" if direction_sense == "POSITIVE" else "POSITIVE"
)
if event.value == "RELEASE" and event.type == "O":
offset_type = context.scene.BIMModelProperties.offset_type
items = ["EXTERIOR", "CENTER", "INTERIOR"]
index = items.index(offset_type)
size = len(items)
context.scene.BIMModelProperties.offset_type = items[((index + 1) % size)]
props = bpy.context.scene.BIMModelProperties
wall_config = f"""Direction: {props.direction_sense}
Offset Type: {props.offset_type}
Offset Value: {props.offset}
"""
self.handle_instructions(context, wall_config)
if event.value == "RELEASE" and event.type == "O":
items = ["EXTERIOR", "CENTER", "INTERIOR"]
index = items.index(props.offset_type)
size = len(items)
props.offset_type = items[((index + 1) % size)]
layers = tool.Model.get_material_layer_parameters(self.relating_type)
thickness = layers["thickness"]
offset = 0
if props.offset_type == "CENTER":
offset = -thickness / 2
elif props.offset_type == "INTERIOR":
offset = -thickness
props.offset = offset / self.unit_scale
tool.Blender.update_viewport()
custom_instructions = {
'Choose Axis': {'icons':True, 'keys': ['EVENT_X', 'EVENT_Y']}