Thursday, July 13, 2023

MHX Properties are now ID Properties

If you open an old MHX rig in the latest MHX version, all panels contain only a single button named "Update MHX Drivers". What is going on?

In Blender there are two types of custom properties, often called ID properties and RNA properties. RNA properties are defined by Blender or by add-ons for all instances of a certain datatype, whereas ID properties are created on the fly and only affects a single instance. 
 
MHX has been using RNA properties for its internal functioning, because it makes the UI more attractive. In particular, Boolean ID properties are displayed as integers rather than checkboxes. However, I recently realized that RNA properties have a major drawback: they are not defined if the MHX add-on is disabled. This could happen if we redistribute the blend file to somebody who does not have the MHX add-on installed, e.g. a render farm.
Here we have posed Aiko in version 1.7.0 of the DAZ Importer and MHX RTS add-ons. We are using IK for both arms and legs.
IK for the left and right arms are controlled by custom properties called MhaArmIk_L and MhaArmIk_R, respectively. We see in the Custom Properties list that IK is enabled and that they are RNA properties, because "API Defined" is written to the right of the properties.

The IK property drives the influence of a Copy Transforms constraint for the upper_arm.L bone, which is located on the hidden layer 15. The driver value is 1.0 which is the value of the RNA property MhaArmIk_L.
Save the file and disable the MHX RTS add-on. Then close and restart Blender, so the definition of the RNA properties disappear.
Now open the file that we just saved in the new Blender session. The IK pose is gone! The IK bones are posed as they were before, but the mesh no longer follows suit.

When we inspect the custom properties, we see that the custom properties have turned into ID properties. There is a cogwheel and an X to the right of the properties rather than the text "API Defined".
If we look at the driver for the Copy Transforms constraint, we see that the path has turned red and that the driver value is 0.0. The driver looks for an RNA property called MhaArmIk_L, but that does not exist because the MHX RTS add-on is disabled.

To fix the file, we have to enable the MHX add-on again. The mesh now jumps into place because the RNA properties are defined again, but this is not a permanent solution.

All panels in the MHX tab contain the single button "Update MHX Drivers", so we have to press that.
The path to the driving property has been changed. Instead of MhaArmIk_L which is the path to the RNA property, it becomes ["MhaArmIk_L"] refers to the corresponding ID property.

Now save the blend file, disable the MHX add-on, restart Blender and open the file. The IK pose is still there, even though the MHX tab is absent.