diff --git a/tools/blenvy/add_ons/bevy_components/components/operators.py b/tools/blenvy/add_ons/bevy_components/components/operators.py index 07fb9ee..165a7b3 100644 --- a/tools/blenvy/add_ons/bevy_components/components/operators.py +++ b/tools/blenvy/add_ons/bevy_components/components/operators.py @@ -152,12 +152,21 @@ class BLENVY_OT_component_remove(Operator): print("removing component ", self.component_name, "from object '"+target.name+"'") - if target is not None and 'bevy_components' in target : - component_value = get_bevy_component_value_by_long_name(target, self.component_name) - if component_value is not None: - remove_component_from_item(target, self.component_name) - else : - self.report({"ERROR"}, "The component to remove ("+ self.component_name +") does not exist") + + if target is not None: + if 'bevy_components' in target: + component_value = get_bevy_component_value_by_long_name(target, self.component_name) + if component_value is not None: + remove_component_from_item(target, self.component_name) + else : + self.report({"ERROR"}, "The component to remove ("+ self.component_name +") does not exist") + else: + # for the classic "custom properties" + if self.component_name in target: + del target[self.component_name] + else: + self.report({"ERROR"}, "The component to remove ("+ self.component_name +") does not exist") + else: self.report({"ERROR"}, "The target to remove ("+ self.component_name +") from does not exist") return {'FINISHED'} diff --git a/tools/blenvy/add_ons/bevy_components/components/ui.py b/tools/blenvy/add_ons/bevy_components/components/ui.py index 3e73ab2..aa9fb3d 100644 --- a/tools/blenvy/add_ons/bevy_components/components/ui.py +++ b/tools/blenvy/add_ons/bevy_components/components/ui.py @@ -372,7 +372,7 @@ class BLENVY_PT_component_tools_panel(bpy.types.Panel): operator.target_name = target_component_name col.enabled = internal and registry_has_type_infos and component_name != "" and target_component_name != "" and component_name != target_component_name - + #print("target", target, target.name, "component_name", component_name, "item type", get_selection_type(target)) col = row.column() operator = col.operator("blenvy.component_remove", text="", icon="X") operator.item_name = target.name