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}")
|
||||||
|
|
||||||
Alexander Gavrilov
commented
This is still not using repr. Also, step and precision should now be supported directly by This is still not using repr. Also, step and precision should now be supported directly by `rna_idprop_ui_create`, I fixed that recently.
Andrej
commented
Resolved in Resolved in ca78100418069ed45b340504ffcb55a03327627e
|
|||||||
# Constraints
|
# Constraints
|
||||||
Alexander Gavrilov
commented
If current_value is actually equal to default, this would be redundant. If current_value is actually equal to default, this would be redundant.
Andrej
commented
resolved in resolved in 076763507e82ff209f546aba4b2ab03061254d9d
|
|||||||
for con in pbone.constraints:
|
for con in pbone.constraints:
|
||||||
|
Loading…
Reference in New Issue
Block a user
Iterate over
items()
to get both key and value.resolved in
3677cc4549