mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-24 10:56:57 +00:00
Walls and slabs (or any vertical or horziontal layer) now auto recalculate origins after editing
This commit is contained in:
@@ -20,10 +20,9 @@ def element_listener(element, obj):
|
|||||||
|
|
||||||
|
|
||||||
def mode_callback(obj, data):
|
def mode_callback(obj, data):
|
||||||
for obj in bpy.context.selected_objects + [bpy.context.active_object]:
|
for obj in set(bpy.context.selected_objects + [bpy.context.active_object]):
|
||||||
if (
|
if (
|
||||||
obj.mode != "EDIT"
|
not obj.data
|
||||||
or not obj.data
|
|
||||||
or not isinstance(obj.data, (bpy.types.Mesh, bpy.types.Curve, bpy.types.TextCurve))
|
or not isinstance(obj.data, (bpy.types.Mesh, bpy.types.Curve, bpy.types.TextCurve))
|
||||||
or not obj.BIMObjectProperties.ifc_definition_id
|
or not obj.BIMObjectProperties.ifc_definition_id
|
||||||
or not bpy.context.scene.BIMProjectProperties.is_authoring
|
or not bpy.context.scene.BIMProjectProperties.is_authoring
|
||||||
@@ -33,6 +32,7 @@ def mode_callback(obj, data):
|
|||||||
parametric = ifcopenshell.util.element.get_psets(product).get("EPset_Parametric")
|
parametric = ifcopenshell.util.element.get_psets(product).get("EPset_Parametric")
|
||||||
if not parametric or parametric["Engine"] != "BlenderBIM.DumbLayer3":
|
if not parametric or parametric["Engine"] != "BlenderBIM.DumbLayer3":
|
||||||
return
|
return
|
||||||
|
if obj.mode == "EDIT":
|
||||||
IfcStore.edited_objs.add(obj)
|
IfcStore.edited_objs.add(obj)
|
||||||
modifier = [m for m in obj.modifiers if m.type == "SOLIDIFY"]
|
modifier = [m for m in obj.modifiers if m.type == "SOLIDIFY"]
|
||||||
if modifier:
|
if modifier:
|
||||||
@@ -54,6 +54,14 @@ def mode_callback(obj, data):
|
|||||||
modifier.use_even_offset = True
|
modifier.use_even_offset = True
|
||||||
modifier.offset = 1
|
modifier.offset = 1
|
||||||
modifier.thickness = depth
|
modifier.thickness = depth
|
||||||
|
else:
|
||||||
|
new_origin = obj.matrix_world @ Vector(obj.bound_box[0])
|
||||||
|
obj.data.transform(
|
||||||
|
Matrix.Translation(
|
||||||
|
(obj.matrix_world.inverted().to_quaternion() @ (obj.matrix_world.translation - new_origin))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
obj.matrix_world.translation = new_origin
|
||||||
|
|
||||||
|
|
||||||
def ensure_solid(usecase_path, ifc_file, settings):
|
def ensure_solid(usecase_path, ifc_file, settings):
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ def element_listener(element, obj):
|
|||||||
def mode_callback(obj, data):
|
def mode_callback(obj, data):
|
||||||
for obj in set(bpy.context.selected_objects + [bpy.context.active_object]):
|
for obj in set(bpy.context.selected_objects + [bpy.context.active_object]):
|
||||||
if (
|
if (
|
||||||
obj.mode != "EDIT"
|
not obj.data
|
||||||
or not obj.data
|
|
||||||
or not isinstance(obj.data, (bpy.types.Mesh, bpy.types.Curve, bpy.types.TextCurve))
|
or not isinstance(obj.data, (bpy.types.Mesh, bpy.types.Curve, bpy.types.TextCurve))
|
||||||
or not obj.BIMObjectProperties.ifc_definition_id
|
or not obj.BIMObjectProperties.ifc_definition_id
|
||||||
or not bpy.context.scene.BIMProjectProperties.is_authoring
|
or not bpy.context.scene.BIMProjectProperties.is_authoring
|
||||||
@@ -33,12 +32,21 @@ def mode_callback(obj, data):
|
|||||||
parametric = ifcopenshell.util.element.get_psets(product).get("EPset_Parametric")
|
parametric = ifcopenshell.util.element.get_psets(product).get("EPset_Parametric")
|
||||||
if not parametric or parametric["Engine"] != "BlenderBIM.DumbLayer2":
|
if not parametric or parametric["Engine"] != "BlenderBIM.DumbLayer2":
|
||||||
return
|
return
|
||||||
|
if obj.mode == "EDIT":
|
||||||
bpy.ops.bim.dynamically_void_product(obj=obj.name)
|
bpy.ops.bim.dynamically_void_product(obj=obj.name)
|
||||||
IfcStore.edited_objs.add(obj)
|
IfcStore.edited_objs.add(obj)
|
||||||
bm = bmesh.from_edit_mesh(obj.data)
|
bm = bmesh.from_edit_mesh(obj.data)
|
||||||
bmesh.ops.dissolve_limit(bm, angle_limit=pi / 180 * 1, verts=bm.verts, edges=bm.edges)
|
bmesh.ops.dissolve_limit(bm, angle_limit=pi / 180 * 1, verts=bm.verts, edges=bm.edges)
|
||||||
bmesh.update_edit_mesh(obj.data)
|
bmesh.update_edit_mesh(obj.data)
|
||||||
bm.free()
|
bm.free()
|
||||||
|
else:
|
||||||
|
new_origin = obj.matrix_world @ Vector(obj.bound_box[0])
|
||||||
|
obj.data.transform(
|
||||||
|
Matrix.Translation(
|
||||||
|
(obj.matrix_world.inverted().to_quaternion() @ (obj.matrix_world.translation - new_origin))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
obj.matrix_world.translation = new_origin
|
||||||
|
|
||||||
|
|
||||||
class JoinWall(bpy.types.Operator):
|
class JoinWall(bpy.types.Operator):
|
||||||
|
|||||||
Reference in New Issue
Block a user