mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 21:42:19 +00:00
Refactor wall offset and direction after f724bb692
This commit is contained in:
@@ -61,20 +61,21 @@ def create_bmesh_from_vertices(vertices, is_closed=False):
|
|||||||
|
|
||||||
def get_wall_preview_data(context, relating_type):
|
def get_wall_preview_data(context, relating_type):
|
||||||
# Get properties from object 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
|
model_props = context.scene.BIMModelProperties
|
||||||
direction_sense = model_props.direction_sense
|
direction_sense = model_props.direction_sense
|
||||||
direction = 1
|
direction = 1
|
||||||
if direction_sense == "NEGATIVE":
|
if direction_sense == "NEGATIVE":
|
||||||
direction = -1
|
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())
|
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
||||||
offset = model_props.offset * unit_scale
|
offset = model_props.offset * unit_scale
|
||||||
thickness *= direction
|
|
||||||
offset *= direction
|
offset *= direction
|
||||||
|
|
||||||
height = float(model_props.extrusion_depth)
|
height = float(model_props.extrusion_depth)
|
||||||
|
|||||||
@@ -200,9 +200,9 @@ class BIMModelProperties(PropertyGroup):
|
|||||||
name="Material Usage Direction Sense",
|
name="Material Usage Direction Sense",
|
||||||
default="POSITIVE",
|
default="POSITIVE",
|
||||||
)
|
)
|
||||||
offset_type: bpy.props.EnumProperty(
|
offset_type_vertical: bpy.props.EnumProperty(
|
||||||
items=[("EXTERIOR", "Exterior", ""), ("CENTER", "Center", ""), ("INTERIOR", "Interior", "")],
|
items=[("EXTERIOR", "Exterior", ""), ("CENTER", "Center", ""), ("INTERIOR", "Interior", "")],
|
||||||
name="Layer Offset Type",
|
name="Vertical Layer Offset Type",
|
||||||
default="EXTERIOR",
|
default="EXTERIOR",
|
||||||
description="It's a convention that affects the offset to reference line",
|
description="It's a convention that affects the offset to reference line",
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -422,20 +422,10 @@ class DrawPolylineWall(bpy.types.Operator, PolylineOperator):
|
|||||||
props = bpy.context.scene.BIMModelProperties
|
props = bpy.context.scene.BIMModelProperties
|
||||||
if event.value == "RELEASE" and event.type == "O":
|
if event.value == "RELEASE" and event.type == "O":
|
||||||
items = ["EXTERIOR", "CENTER", "INTERIOR"]
|
items = ["EXTERIOR", "CENTER", "INTERIOR"]
|
||||||
index = items.index(props.offset_type)
|
index = items.index(props.offset_type_vertical)
|
||||||
size = len(items)
|
size = len(items)
|
||||||
props.offset_type = items[((index + 1) % size)]
|
props.offset_type_vertical = items[((index + 1) % size)]
|
||||||
|
self.set_offset(context, self.relating_type)
|
||||||
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 = {
|
custom_instructions = {
|
||||||
'Choose Axis': {'icons':True, 'keys': ['EVENT_X', 'EVENT_Y']}
|
'Choose Axis': {'icons':True, 'keys': ['EVENT_X', 'EVENT_Y']}
|
||||||
@@ -443,7 +433,7 @@ class DrawPolylineWall(bpy.types.Operator, PolylineOperator):
|
|||||||
|
|
||||||
wall_config = [
|
wall_config = [
|
||||||
f"Direction: {props.direction_sense}",
|
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)}",
|
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)
|
ProductDecorator.install(context)
|
||||||
self.tool_state.use_default_container = True
|
self.tool_state.use_default_container = True
|
||||||
self.tool_state.plane_method = "XY"
|
self.tool_state.plane_method = "XY"
|
||||||
|
self.set_offset(context, self.relating_type)
|
||||||
return {"RUNNING_MODAL"}
|
return {"RUNNING_MODAL"}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user