mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-24 10:06:57 +00:00
Fixed bug with slab editing decorator breaking on undo
Because of jumping between modes "bim.set_arc_index" doesn't remove newly created vertex groups on undo which resulted in error in decorator.
File "\blenderbim\bim\module\model\decorator.py", line 134, in __call__
if group_index in vertex[deform_layer]:
AttributeError: BMElem[key]: invalid key, must be a BMLayerItem
This commit is contained in:
@@ -38,6 +38,15 @@ faces_color = (0.494, 0.540, 0.593, 1)
|
|||||||
preview_edges_color = (0.130, 0.141, 0.371, 1)
|
preview_edges_color = (0.130, 0.141, 0.371, 1)
|
||||||
|
|
||||||
|
|
||||||
|
def bm_check_vertex_in_groups(vertex, deform_layer, groups):
|
||||||
|
"""returns tuple boolean (whether vertex is in any of the groups)
|
||||||
|
and related group index"""
|
||||||
|
for group_index in vertex[deform_layer].keys():
|
||||||
|
if group_index in groups:
|
||||||
|
return True, group_index
|
||||||
|
return False, None
|
||||||
|
|
||||||
|
|
||||||
class ProfileDecorator:
|
class ProfileDecorator:
|
||||||
installed = None
|
installed = None
|
||||||
|
|
||||||
@@ -146,25 +155,19 @@ class ProfileDecorator:
|
|||||||
if vertex.hide:
|
if vertex.hide:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# TODO: iterate over deform layers instead of all vertex groups?
|
is_arc, is_circle = False, False
|
||||||
# move to separate function `bm_check_vertex_in_groups`
|
# deform_layer is None if there are no verts assigned to vertex groups
|
||||||
is_arc = False
|
# even if there are vertex groups in the obj.vertex_groups
|
||||||
for group_index in arc_groups:
|
if deform_layer:
|
||||||
if group_index in vertex[deform_layer]:
|
is_arc, group_index = bm_check_vertex_in_groups(vertex, deform_layer, arc_groups)
|
||||||
is_arc = True
|
if is_arc:
|
||||||
break
|
arcs.setdefault(group_index, []).append(vertex)
|
||||||
if is_arc:
|
special_vertex_indices[vertex.index] = group_index
|
||||||
arcs.setdefault(group_index, []).append(vertex)
|
|
||||||
special_vertex_indices[vertex.index] = group_index
|
|
||||||
|
|
||||||
is_circle = False
|
is_circle, group_index = bm_check_vertex_in_groups(vertex, deform_layer, circle_groups)
|
||||||
for group_index in circle_groups:
|
if is_circle:
|
||||||
if group_index in vertex[deform_layer]:
|
circles.setdefault(group_index, []).append(vertex)
|
||||||
is_circle = True
|
special_vertex_indices[vertex.index] = group_index
|
||||||
break
|
|
||||||
if is_circle:
|
|
||||||
circles.setdefault(group_index, []).append(vertex)
|
|
||||||
special_vertex_indices[vertex.index] = group_index
|
|
||||||
|
|
||||||
if vertex.select:
|
if vertex.select:
|
||||||
selected_vertices.append(co)
|
selected_vertices.append(co)
|
||||||
|
|||||||
@@ -702,6 +702,7 @@ class EditExtrusionProfile(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
class ResetVertex(bpy.types.Operator):
|
class ResetVertex(bpy.types.Operator):
|
||||||
bl_idname = "bim.reset_vertex"
|
bl_idname = "bim.reset_vertex"
|
||||||
bl_label = "Reset Vertex"
|
bl_label = "Reset Vertex"
|
||||||
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
@@ -725,6 +726,7 @@ class ResetVertex(bpy.types.Operator):
|
|||||||
class SetArcIndex(bpy.types.Operator):
|
class SetArcIndex(bpy.types.Operator):
|
||||||
bl_idname = "bim.set_arc_index"
|
bl_idname = "bim.set_arc_index"
|
||||||
bl_label = "Set Arc Index"
|
bl_label = "Set Arc Index"
|
||||||
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
@@ -736,6 +738,8 @@ class SetArcIndex(bpy.types.Operator):
|
|||||||
return {"CANCELLED"}
|
return {"CANCELLED"}
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
|
# NOTE: undo won't remove new verex group
|
||||||
|
# because of jumping between modes
|
||||||
obj = context.active_object
|
obj = context.active_object
|
||||||
bpy.ops.object.mode_set(mode="OBJECT")
|
bpy.ops.object.mode_set(mode="OBJECT")
|
||||||
selected_vertices = [v.index for v in obj.data.vertices if v.select]
|
selected_vertices = [v.index for v in obj.data.vertices if v.select]
|
||||||
|
|||||||
Reference in New Issue
Block a user