mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 18:57:17 +00:00
Fix #1588. Profiles now auto recalculate cardinal points after editing.
This commit is contained in:
@@ -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,11 +32,43 @@ 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.DumbProfile":
|
if not parametric or parametric["Engine"] != "BlenderBIM.DumbProfile":
|
||||||
return
|
return
|
||||||
IfcStore.edited_objs.add(obj)
|
if obj.mode == "EDIT":
|
||||||
bm = bmesh.from_edit_mesh(obj.data)
|
IfcStore.edited_objs.add(obj)
|
||||||
bmesh.ops.dissolve_limit(bm, angle_limit=pi / 180 * 1, verts=bm.verts, edges=bm.edges)
|
bm = bmesh.from_edit_mesh(obj.data)
|
||||||
bmesh.update_edit_mesh(obj.data)
|
bmesh.ops.dissolve_limit(bm, angle_limit=pi / 180 * 1, verts=bm.verts, edges=bm.edges)
|
||||||
bm.free()
|
bmesh.update_edit_mesh(obj.data)
|
||||||
|
bm.free()
|
||||||
|
else:
|
||||||
|
material_usage = ifcopenshell.util.element.get_material(product)
|
||||||
|
x, y = obj.dimensions[0:2]
|
||||||
|
if not material_usage.CardinalPoint:
|
||||||
|
new_origin = obj.matrix_world @ (Vector(obj.bound_box[0]) + (Vector((x, y, 0)) / 2))
|
||||||
|
elif material_usage.CardinalPoint == 1:
|
||||||
|
new_origin = obj.matrix_world @ Vector(obj.bound_box[4])
|
||||||
|
elif material_usage.CardinalPoint == 2:
|
||||||
|
new_origin = obj.matrix_world @ (Vector(obj.bound_box[0]) + (Vector((x, 0, 0)) / 2))
|
||||||
|
elif material_usage.CardinalPoint == 3:
|
||||||
|
new_origin = obj.matrix_world @ Vector(obj.bound_box[0])
|
||||||
|
elif material_usage.CardinalPoint == 4:
|
||||||
|
new_origin = obj.matrix_world @ (Vector(obj.bound_box[4]) + (Vector((0, y, 0)) / 2))
|
||||||
|
elif material_usage.CardinalPoint == 5:
|
||||||
|
new_origin = obj.matrix_world @ (Vector(obj.bound_box[0]) + (Vector((x, y, 0)) / 2))
|
||||||
|
elif material_usage.CardinalPoint == 6:
|
||||||
|
new_origin = obj.matrix_world @ (Vector(obj.bound_box[0]) + (Vector((0, y, 0)) / 2))
|
||||||
|
elif material_usage.CardinalPoint == 7:
|
||||||
|
new_origin = obj.matrix_world @ Vector(obj.bound_box[7])
|
||||||
|
elif material_usage.CardinalPoint == 8:
|
||||||
|
new_origin = obj.matrix_world @ (Vector(obj.bound_box[3]) + (Vector((x, 0, 0)) / 2))
|
||||||
|
elif material_usage.CardinalPoint == 9:
|
||||||
|
new_origin = obj.matrix_world @ Vector(obj.bound_box[3])
|
||||||
|
if (obj.matrix_world.translation - new_origin).length < 0.001:
|
||||||
|
return
|
||||||
|
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):
|
||||||
|
|||||||
Reference in New Issue
Block a user