"Save favorite morph" is missing some morphs.

Issue #988 resolved
Suttisak Denduangchai created an issue

I edited morphing.py to be better handling my use case. I create many objects (ex. for using with hair particle modifier) sharing the same genesis meshes (by pressing ALT+D). When I save my favorite morphs, the save json file will miss some morphes, this is because the old code overwrote struct[url]. (Because they are all have same DAZURL)

So, I propose a fix.

    def addMorphUrls(self, ob, struct):
        if len(ob.DazMorphUrls) == 0:
            return
        else:
            print(ob.name)
        from urllib.parse import quote
        from .finger import getFingerPrint
        url = quote(ob.DazUrl)
        if url not in struct.keys():
            struct[url] = {}
        ostruct = struct[url]
        if ob.type == 'MESH':
            if ob.data.DazFingerPrint:
                ostruct["finger_print"] = ob.data.DazFingerPrint
            else:
                ostruct["finger_print"] = getFingerPrint(ob)
        if "morphs" not in ostruct.keys():
            ostruct["morphs"] = {}
        mstruct = ostruct["morphs"]
        for item in ob.DazMorphUrls:
            if item.morphset == "Custom":
                key = "Custom/%s" % item.category
            else:
                key = item.morphset
            if key not in mstruct.keys():
                mstruct[key] = []
            name = (quote(item.name), item.text, item.bodypart)
            if name not in mstruct[key]:
                mstruct[key].append(name)

Comments (2)

  1. Log in to comment