@@ -405,6 +405,8 @@ def remove_controller(controller_node, frame_start, frame_end):
405405 # Store the selection in advance
406406 copy_keys_node = controller_node
407407
408+ has_extra_parents = False
409+
408410 is_node_controller_rig = False
409411 attr_list = cmds .listAttr (controller_node )
410412 if ATTRIBUTE_IDENTIFIER_NAME in attr_list :
@@ -431,25 +433,36 @@ def remove_controller(controller_node, frame_start, frame_end):
431433 destination = False , source = True ) or []
432434
433435 if driven_nodes and len (driven_nodes ) > 0 :
436+ # Make delete items list
437+ if is_node_controller_rig is True :
438+ delete_list = []
439+ parent_nodes = cmds .pickWalk (controller_node , direction = "Up" , recurse = True )
440+ cmds .select (clear = True )
441+ for parent_node in parent_nodes :
442+ parent_node_attr_list = cmds .listAttr (parent_node )
443+ if ATTRIBUTE_IDENTIFIER_NAME in parent_node_attr_list :
444+ parent_node_attr_value = cmds .getAttr (parent_node + "." + ATTRIBUTE_IDENTIFIER_NAME )
445+ if parent_node_attr_value == custom_attr_value :
446+ delete_list .append (parent_node )
447+ else :
448+ has_extra_parents = True
449+
434450 # Bake attributes
435451 if is_node_controller_rig is True :
436452 for driven_node in driven_nodes :
437- _copy_parent_keys_to_child (copy_keys_node , driven_node , frame_start , frame_end )
453+ if has_extra_parents is False :
454+ _copy_parent_keys_to_child (copy_keys_node , driven_node , frame_start , frame_end )
455+ else :
456+ fastbake_lib .bake_attributes (
457+ [driven_node ], attrs , frame_start , frame_end , smart_bake = True )
438458 else :
439459 fastbake_lib .bake_attributes (
440460 driven_nodes , attrs , frame_start , frame_end , smart_bake = True )
441461 cmds .delete (constraints )
442- _remove_constraint_blend_attr_from_nodes (driven_nodes )
462+ _remove_constraint_blend_attr_from_nodes (driven_nodes )
443463
444464 # Delete controller node and its parents
445465 if is_node_controller_rig is True :
446- delete_list = []
447- parent_nodes = cmds .pickWalk (controller_node , direction = "Up" , recurse = True )
448- cmds .select (clear = True )
449- for parent_node in parent_nodes :
450- parent_node_attr_value = cmds .getAttr (parent_node + "." + ATTRIBUTE_IDENTIFIER_NAME )
451- if parent_node_attr_value == custom_attr_value :
452- delete_list .append (parent_node )
453466 cmds .delete (delete_list )
454467
455468 if cmds .objExists (controller_node ):
0 commit comments