How to prevent custom properties from being copied when the object is duplicated?

I don’t want some of my custom properties to be copied when the user duplicates an object.

Hmm :thinking: …but… isn’t that the meaning of making a duplicate (using some copy() function when programming… ) ?

Iin fact when enableing Python Tooltips it shows bpy.ops.object.duplicate_move(..)) ? I’m not sure if some driver/observer exists to add some extra functionality… maybe not only by adding some custom properties to soem object but subclassing the whole object and so extending the functionality (wiping the custom properties on a copy) ?? Never tried that in blender.

1 Like

You can’t do that, copy makes a copy of the datablock and everything is duplicated. There is no way to filter data in the process (materials, modifiers, animation, custom props…)

You need to create a custom python operator / addon that duplicates and get rid of the data you don’t want.

Thanks for the answer <3.
When I asked an LLM about it, it was one of the solutions it gave, but it was too hacky for me. So, I came up with a different, slightly less hacky solution that fit my needs.
I wanted to store some tags on bones specifically, so I created a collection property on bpy.types.Armature that stores bone name and tags as its items.
Wrote setters and getters that iterate on that collection and find the bone; if a bone is not found, they create a new item.