Refactor wall offset and direction after f724bb692

This commit is contained in:
Bruno Perdigão
2025-01-23 14:23:37 -03:00
parent 5ec5594c69
commit fa174feaae
3 changed files with 14 additions and 22 deletions
@@ -61,20 +61,21 @@ def create_bmesh_from_vertices(vertices, is_closed=False):
def get_wall_preview_data(context, relating_type):
# Get properties from object type
layers = tool.Model.get_material_layer_parameters(relating_type)
if not layers["thickness"]:
return
thickness = layers["thickness"]
model_props = context.scene.BIMModelProperties
direction_sense = model_props.direction_sense
direction = 1
if direction_sense == "NEGATIVE":
direction = -1
offset_type = model_props.offset_type
layers = tool.Model.get_material_layer_parameters(relating_type)
if not layers["thickness"]:
return
thickness = layers["thickness"]
thickness *= direction
offset_type = model_props.offset_type_vertical
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
offset = model_props.offset * unit_scale
thickness *= direction
offset *= direction
height = float(model_props.extrusion_depth)
+2 -2
View File
@@ -200,9 +200,9 @@ class BIMModelProperties(PropertyGroup):
name="Material Usage Direction Sense",
default="POSITIVE",
)
offset_type: bpy.props.EnumProperty(
offset_type_vertical: bpy.props.EnumProperty(
items=[("EXTERIOR", "Exterior", ""), ("CENTER", "Center", ""), ("INTERIOR", "Interior", "")],
name="Layer Offset Type",
name="Vertical Layer Offset Type",
default="EXTERIOR",
description="It's a convention that affects the offset to reference line",
)
+5 -14
View File
@@ -422,20 +422,10 @@ class DrawPolylineWall(bpy.types.Operator, PolylineOperator):
props = bpy.context.scene.BIMModelProperties
if event.value == "RELEASE" and event.type == "O":
items = ["EXTERIOR", "CENTER", "INTERIOR"]
index = items.index(props.offset_type)
index = items.index(props.offset_type_vertical)
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()
props.offset_type_vertical = items[((index + 1) % size)]
self.set_offset(context, self.relating_type)
custom_instructions = {
'Choose Axis': {'icons':True, 'keys': ['EVENT_X', 'EVENT_Y']}
@@ -443,7 +433,7 @@ class DrawPolylineWall(bpy.types.Operator, PolylineOperator):
wall_config = [
f"Direction: {props.direction_sense}",
f"Offset Type: {props.offset_type}",
f"Offset Type: {props.offset_type_vertical}",
f"Offset Value: {tool.Polyline.format_input_ui_units(props.offset * self.unit_scale)}",
]
@@ -486,6 +476,7 @@ class DrawPolylineWall(bpy.types.Operator, PolylineOperator):
ProductDecorator.install(context)
self.tool_state.use_default_container = True
self.tool_state.plane_method = "XY"
self.set_offset(context, self.relating_type)
return {"RUNNING_MODAL"}