Saturday, July 25, 2020

New Morph System

The naming convention for morphs has been changed in the development version. Previously the plugin stripped the standard Daz prefix from the morph name (eCTRL, pJCM, etc.) and replaced it by a different prefix, always with three letters (DzU, DzC, etc.). This made it easy to list all morphs of a certain type in a user-friendly format, by stripping off the first three letters from the morph name.

However, this system had a few drawbacks. Once one starts to delete and edit morphs, the plugin could become confused. In particular, it could add multiple prefixes, like DzUDzC to the morph names. It was also not obvious what the original morph name was, since the beginning of the Daz name had disappeared. To overcome such drawbacks, a new morph system has been introduced. In the new system, the original Daz names is kept. To keep track of the morph type (Units, Expressions, JCMs, etc.), all morph names are stored in different collection properties, together with the user-friendly print name.

The change should be almost invisible for the user, except that the new morph system has introduced some bugs that need to be fixed. However, there are a few places where you can actually see the difference.
Shapekeys keep their original Daz names. In previous versions, the two last shapekeys would be called DzMAiko8Afraid and DzMAiko8Angry.
If an old file with a Daz character is opened, the Morphs panel consists of a single button. Once we press Update Morphs For Version 1.5, all objects in the scene are updated and the Morphs panel look as it did before.
It is not necessary to do the update when a new scene is imported with the Import DAZ button.

To access the morphs of a certain type from python, use the function import_daz.getMorphs(object, type). The function returns a dict which describes the morph.

The follow script prints all custom morphs of the active object

import bpy
import import_daz

ob = bpy.context.object
morphs = import_daz.getMorphs(ob, "Custom")
for item in morphs.values():
    print("    %20s %20s" % (, item.text))

Here is the output
dict_keys(['FHMAiko8', 'eJCMAiko8Afraid', 'eCTRLAfraid', 'eJCMAiko8Angry', 'eCTRLAngry'])
                FHMAiko8             FHMAiko8
         eJCMAiko8Afraid          Aiko8Afraid
             eCTRLAfraid               Afraid
          eJCMAiko8Angry           Aiko8Angry
              eCTRLAngry                Angry

If we load four expressions, we can print them by changing "Custom" to "Expression" in the script above, viz. import_daz.getMorphs(ob, "Expression").

dict_keys(['eCTRLAfraid', 'eCTRLAngry', 'eCTRLBereft', 'eCTRLBored'])
             eCTRLAfraid               Afraid
              eCTRLAngry                Angry
             eCTRLBereft               Bereft
              eCTRLBored                Bored