Rigify - saving pbone custom properties to metarig #104695
@ -414,16 +414,16 @@ def write_metarig(obj: ArmatureObject, layers=False, func_name="create",
|
|||||||
code.append(" pass")
|
code.append(" pass")
|
||||||
|
|
||||||
# Custom properties
|
# Custom properties
|
||||||
custom_properties = [
|
custom_properties = {
|
||||||
custom_property for custom_property in pbone.keys()
|
property_name: value for property_name, value in pbone.items()
|
||||||
if custom_property not in pbone.bl_rna.properties.keys()
|
if property_name not in pbone.bl_rna.properties.keys()
|
||||||
and type(pbone[custom_property]) in (float, int)
|
and type(pbone[property_name]) in (float, int)
|
||||||
]
|
}
|
||||||
|
|
||||||
if custom_properties:
|
if custom_properties:
|
||||||
code.append(' # custom properties')
|
code.append(' # custom properties')
|
||||||
|
|
||||||
for custom_property in custom_properties:
|
for custom_property, current_value in custom_properties.items():
|
||||||
props_data = pbone.id_properties_ui(custom_property).as_dict()
|
props_data = pbone.id_properties_ui(custom_property).as_dict()
|
||||||
code.append(f" rna_idprop_ui_create(")
|
code.append(f" rna_idprop_ui_create(")
|
||||||
code.append(f" pbone, ")
|
code.append(f" pbone, ")
|
||||||
@ -442,6 +442,7 @@ def write_metarig(obj: ArmatureObject, layers=False, func_name="create",
|
|||||||
code.append(f" )")
|
code.append(f" )")
|
||||||
if 'precision' in props_data:
|
if 'precision' in props_data:
|
||||||
code.append(f" pbone.id_properties_ui('{custom_property}').update(precision={props_data['precision']})")
|
code.append(f" pbone.id_properties_ui('{custom_property}').update(precision={props_data['precision']})")
|
||||||
|
code.append(f" pbone[{custom_property!r}] = {current_value}")
|
||||||
|
|
||||||
# Constraints
|
# Constraints
|
||||||
for con in pbone.constraints:
|
for con in pbone.constraints:
|
||||||
|
Loading…
Reference in New Issue
Block a user