mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 02:47:48 +00:00
Refactor how offset and direction sense interact for wall and slabs.
This commit is contained in:
@@ -78,7 +78,6 @@ def get_wall_preview_data(context, relating_type):
|
||||
offset_type = model_props.offset_type_vertical
|
||||
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
||||
offset = model_props.offset * unit_scale
|
||||
offset *= direction
|
||||
|
||||
height = float(model_props.extrusion_depth)
|
||||
rl = float(model_props.rl1)
|
||||
@@ -206,7 +205,6 @@ def get_slab_preview_data(context, relating_type):
|
||||
offset_type = model_props.offset_type_horizontal
|
||||
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
||||
offset = model_props.offset * unit_scale
|
||||
offset *= direction
|
||||
|
||||
data = {}
|
||||
data["verts"] = []
|
||||
@@ -915,10 +913,13 @@ class PolylineOperator:
|
||||
|
||||
def set_offset(self, context: bpy.types.Context, relating_type: ifcopenshell.entity_instance) -> None:
|
||||
props = bpy.context.scene.BIMModelProperties
|
||||
direction_sense = props.direction_sense
|
||||
if tool.Model.get_usage_type(relating_type) == "LAYER2":
|
||||
offset_type = "offset_type_vertical"
|
||||
direction = 1 if direction_sense == "POSITIVE" else -1
|
||||
elif tool.Model.get_usage_type(relating_type) == "LAYER3":
|
||||
offset_type = "offset_type_horizontal"
|
||||
direction = 1
|
||||
else:
|
||||
return
|
||||
|
||||
@@ -926,9 +927,9 @@ class PolylineOperator:
|
||||
thickness = layers["thickness"]
|
||||
self.offset = 0
|
||||
if getattr(props, offset_type) == "CENTER":
|
||||
self.offset = -thickness / 2
|
||||
self.offset = (-thickness / 2) * direction
|
||||
elif getattr(props, offset_type) in {"INTERIOR", "TOP"}:
|
||||
self.offset = -thickness
|
||||
self.offset = -thickness * direction
|
||||
|
||||
props.offset = self.offset / self.unit_scale
|
||||
tool.Blender.update_viewport()
|
||||
|
||||
@@ -306,7 +306,6 @@ class DumbSlabPlaner:
|
||||
elif layer_params["direction_sense"] == "NEGATIVE":
|
||||
y = -abs(y) if existing_x_angle > 0 else abs(y)
|
||||
z = -abs(z)
|
||||
offset_vector = -offset_vector
|
||||
extrusion.ExtrudedDirection.DirectionRatios = (x, y, z)
|
||||
extrusion.Depth = thickness
|
||||
|
||||
|
||||
@@ -263,7 +263,6 @@ class ChangeExtrusionXAngle(bpy.types.Operator, tool.Ifc.Operator):
|
||||
if layer_params["direction_sense"] == "NEGATIVE":
|
||||
y = -abs(y) if x_angle > 0 else abs(y)
|
||||
z = -abs(z)
|
||||
offset_vector = -offset_vector
|
||||
extrusion.ExtrudedDirection.DirectionRatios = (x, y, z)
|
||||
|
||||
if offset != 0.0 and not extrusion.Position:
|
||||
@@ -418,6 +417,7 @@ class DrawPolylineWall(bpy.types.Operator, PolylineOperator):
|
||||
context.scene.BIMModelProperties.direction_sense = (
|
||||
"NEGATIVE" if direction_sense == "POSITIVE" else "POSITIVE"
|
||||
)
|
||||
self.set_offset(context, self.relating_type)
|
||||
|
||||
props = bpy.context.scene.BIMModelProperties
|
||||
if event.value == "RELEASE" and event.type == "O":
|
||||
@@ -828,6 +828,7 @@ class DumbWallGenerator:
|
||||
tool.Ifc.get(),
|
||||
context=self.body_context,
|
||||
thickness=self.layers["thickness"],
|
||||
direction_sense=self.layers["direction_sense"],
|
||||
offset=self.layers["offset"],
|
||||
length=self.length,
|
||||
height=self.height,
|
||||
@@ -1391,6 +1392,7 @@ class DumbWallJoiner:
|
||||
length=length,
|
||||
height=height,
|
||||
x_angle=x_angle,
|
||||
direction_sense=layers["direction_sense"],
|
||||
offset=layers["offset"],
|
||||
thickness=layers["thickness"],
|
||||
clippings=self.clippings,
|
||||
|
||||
@@ -536,9 +536,6 @@ class Model(bonsai.core.tool.Model):
|
||||
material = material.ForLayerSet
|
||||
if material.is_a("IfcMaterialLayerSet"):
|
||||
thickness = sum([l.LayerThickness for l in material.MaterialLayers]) * unit_scale
|
||||
if direction_sense == "NEGATIVE":
|
||||
thickness *= -1
|
||||
offset *= -1
|
||||
return {
|
||||
"layer_set_direction": layer_set_direction,
|
||||
"thickness": thickness,
|
||||
@@ -672,14 +669,15 @@ class Model(bonsai.core.tool.Model):
|
||||
max_x = max(x_values)
|
||||
axes = {}
|
||||
if layers:
|
||||
direction = 1 if layers["direction_sense"] == "POSITIVE" else -1
|
||||
axes = {
|
||||
"base": [
|
||||
(obj.matrix_world @ Vector((min_x, layers["offset"], 0.0))).to_2d(),
|
||||
(obj.matrix_world @ Vector((max_x, layers["offset"], 0.0))).to_2d(),
|
||||
],
|
||||
"side": [
|
||||
(obj.matrix_world @ Vector((min_x, layers["offset"] + layers["thickness"], 0.0))).to_2d(),
|
||||
(obj.matrix_world @ Vector((max_x, layers["offset"] + layers["thickness"], 0.0))).to_2d(),
|
||||
(obj.matrix_world @ Vector((min_x, layers["offset"] + (layers["thickness"] * direction), 0.0))).to_2d(),
|
||||
(obj.matrix_world @ Vector((max_x, layers["offset"] + (layers["thickness"] * direction), 0.0))).to_2d(),
|
||||
],
|
||||
}
|
||||
axes["reference"] = [
|
||||
|
||||
@@ -28,6 +28,7 @@ def add_wall_representation(
|
||||
context: ifcopenshell.entity_instance,
|
||||
length: float = 1.0,
|
||||
height: float = 3.0,
|
||||
direction_sense: str = "POSITIVE",
|
||||
offset: float = 0.0,
|
||||
thickness: float = 0.2,
|
||||
x_angle: float = 0.0,
|
||||
@@ -55,6 +56,7 @@ def add_wall_representation(
|
||||
"context": context,
|
||||
"length": length,
|
||||
"height": height,
|
||||
"direction_sense": direction_sense,
|
||||
"offset": offset,
|
||||
"thickness": thickness,
|
||||
"x_angle": x_angle,
|
||||
@@ -83,6 +85,8 @@ class Usecase:
|
||||
length = self.convert_si_to_unit(self.settings["length"])
|
||||
thickness = self.convert_si_to_unit(self.settings["thickness"])
|
||||
thickness *= 1 / cos(self.settings["x_angle"])
|
||||
if self.settings["direction_sense"] == "NEGATIVE":
|
||||
thickness *= -1
|
||||
points = (
|
||||
(0.0, 0.0),
|
||||
(0.0, thickness),
|
||||
|
||||
Reference in New Issue
Block a user