diff --git a/collider_conversion/conversion_operators.py b/collider_conversion/conversion_operators.py index 124d43e..8f3bee3 100644 --- a/collider_conversion/conversion_operators.py +++ b/collider_conversion/conversion_operators.py @@ -132,12 +132,15 @@ def execute(self, context): new_collider = obj.copy() new_collider.data = obj.data.copy() - bpy.context.collection.objects.link(new_collider) - user_collections = obj.users_collection + # New collider to scene + bpy.context.collection.objects.link(new_collider) + + # store initial state for operation cancel self.original_obj_data.append(self.store_initial_obj_state(obj, user_collections)) + for collection in obj.users_collection: collection.objects.unlink(obj) diff --git a/collider_shapes/add_bounding_primitive.py b/collider_shapes/add_bounding_primitive.py index 2daccf4..ce9f12a 100644 --- a/collider_shapes/add_bounding_primitive.py +++ b/collider_shapes/add_bounding_primitive.py @@ -951,15 +951,19 @@ def get_time_elapsed(self): def cancel_cleanup(self, context): if self.is_mesh_to_collider: if self.new_colliders_list: - for collider_obj, data in zip(self.new_colliders_list, self.original_obj_data): + for collider_obj in self.new_colliders_list: # Remove previously created collisions if collider_obj: objs = bpy.data.objects objs.remove(collider_obj, do_unlink=True) + + for data in self.original_obj_data: # Assign unlinked data to user groups original_obj = data['obj'] original_user_groups = data['users_collection'] + + bpy.context.collection.objects.link(original_obj) for col in original_user_groups: self.add_to_collections(original_obj, col)