# Attributes and Default Values ## Problem Description Generic algorithms like `join_geometries` and `realize_instances` create attribute data when merging geometries where one part has an attribute and the other doesn't. Example: copying a default Grease Pencil stroke with no explicit "hardness" attribute into another curves geometry. The "hardness" gets initialized to 0 but should be 1. https://projects.blender.org/blender/blender/issues/120297 ## Workaround Least intrusive solution for now: check attributes with known non-zero default values and initialize them before the join. This avoid the initialization to zero as the default attribute value. __Problem__: This recreates much of the recursion logic for realizing instances, defeating the purpose of a generic function and adding lots of opportunity for error. ## General Solution Define attribute defaults as an optional part of the attribute declaration. - `AttributeMetaData` gets a `GPointer default_value`. Null for most attributes, meaning zero initialization. - Only _existing_ attributes have meta-data, so for creating common GP attributes like "hardness" the current utility functions to create attributes, like "opacities_for_write", are still needed. _This is good!_ Makes the system usable for custom attributes as well: creating an attribute also defines its default value. Merging custom attributes works the same as "special" attributes like hardness. - Meta-data is typically created on-the-fly by attribute providers, based on a fixed provider type (for built-in attributes) or the layer type in `CustomData`. Default values don't have storage there yet. Doesn't have to be added for every customized provider, behavior stays the same as current if no default value is provided.