Reset values of property layer, when mesh is edited (after 2.74)
Open, NormalPublic


Hi All,
when you create your own property layer using e.g.:

lay =

and you assign some values to this layer, then these values are copied to some vertexes during extruding, duplicating, etc. It is OK in some cases, but developers IMHO usually want to handle theirs values (I want). Current behaviour does not allow to distinguish between existing vertices/edges/faces/loops and new created elements. BTW: I created following Python script for testing:

I created patch that reset values in property layers of newly created vertices/edges/faces/loops. It will probably requires further modification of Python API and do not make such behaviour as default. I propose following modification:

new(layer_name, reset_new_values=False)



Not sure about this: we have a set_default callback already.

We could just have a flag on the layer that defines duplicated elements are set to their default instead of copying from the data they came from.

Julian Eisel (Severin) triaged this task as "Normal" priority.Dec 10 2014, 4:44 PM

It sound reasonably. I will change the patch. Thanks for your feedback.

Hi All,
I created new version of patch. It adds one optional parameter to function new():

new(name, copy_values=True)

I updated previous gist file: to work with this patch.


I did some tests and it seems that new layer flag: CD_FLAG_NOCOPY_ELEM is forgotten, when object goes from object mode to edit mode.

The flag was cleared in CustomData_merge(). I'm attaching new patch file.

Jiri Hnidek (jiri) added a comment.EditedFeb 13 2015, 5:08 PM

I'm attaching new patch that use attribute of layer (lay.use_force_default = True) for changing behaviour of custom-data layers in edit mode. Gist file with example is updated too.

Checked latest patch. seems good, but would tweak names a bit before going into master. (`ufd` is a bit cryptic)

Would like to do final check before going into master still.

Campbell Barton (campbellbarton) changed the title from "Reset values of property layer, when mesh is edited" to "Reset values of property layer, when mesh is edited (after 2.74)".Feb 25 2015, 12:18 PM

I extended the patch. It is also possible to get and set default value of custom-data layers using attribute, e.g.: lay.default_value = -1. Note: only int and float subtypes are supported, string subtype is not supported. When you try to get default value of other layer type (e.g.: UV), then lay.default_value returns None.

I changed some typos and fixed wrong names of functions (caused by copy-paste).

@Horus R. IceRaven (IceRaven), we're currently not redesigning our layer system and tbh I don't see that happen soon. Thanks for the idea and the effort, we'll keep it in mind, it's just not the right time&place for it ;)

I understand, as I stated in the beginning. This message may have to be redirected or scrapped. My hope is only to improve by planting a seed that may grow into the form I depict or pieces may grow in a direction that no one could have foreseen.
Thanks for you rapid response.
I think you and your teem are doing a fantastic job, so to this.
Do what you will.

What's the status of the patch?
The parameter could also be called propagate_values IMO.
Also interesting would be auto-increment as default value, so assign unique numbers (IDs) to vertices and disable value propagation...

the status of this patch is following: I wait for @Campbell Barton (campbellbarton) to approve it and merge to master. I poke him regularly at IRC chat ;-).

The name of parameter default_value is IMHO more descriptive then propagate_value. I'm not big fan of auto-increment of layer values, because it duplicates functionality. Vertices, Edges, Faces, etc. have property index and it is unique.


Fingers crossed for this to land soon!

.index is not unique in the sense that it can change at any time (can even be overwritten by script) and does not persistently identify a geometry element over its lifetime. That's what I had in mind.

An auto-incrementing value would be unique and identify a vertex even after mesh sort operator.

Why fingers crossed? @Campbell Barton (campbellbarton) approved first version of this patch (layer parameter use_force_default). Do you have anything against this patch? If so, you should clarify what is wrong.

You are right about uniqueness of index, but I'm not willing to add auto-increment functionality to this patch. May be it could be implemented in another patch.

Don't get me wrong, your patch is great! It's just that I've seen ready patches lurking around for months or even a year. So the emphasis was on "soon"!

Aha, I understand now :-). Fingers crossed gesture is not Batsu gesture.

@Horus R. IceRaven (IceRaven), your comments about layers re-design are unrelated to this patch, and off topic.

removed, pasted here, for reference.

Hi @Campbell Barton (campbellbarton),
I refactored code for setting/getting default_value it is possible to set/get default values for int, float and now string custom property layers, but there are other layer types. What other layer types should be supported? I'm adding all layer types accessible using Python API: