Some new error for scandatabase when return None

Issue #1126 resolved
engetudouiti created an issue

When character is G3 (or G2 may cause same issue), there are a few error which can not check correctly.

Traceback (most recent call last):
  File "C:\Users\TAKE\AppData\Roaming\Blender Foundation\Blender\3.2\scripts\addons\import_daz\error.py", line 207, in execute
    self.run(context)
  File "C:\Users\TAKE\AppData\Roaming\Blender Foundation\Blender\3.2\scripts\addons\import_daz\animation.py", line 1521, in run
    StandardAnimation.run(self, context)
  File "C:\Users\TAKE\AppData\Roaming\Blender Foundation\Blender\3.2\scripts\addons\import_daz\animation.py", line 1226, in run
    needs = checkNeedUpdates(name, relpath)
  File "C:\Users\TAKE\AppData\Roaming\Blender Foundation\Blender\3.2\scripts\addons\import_daz\scan.py", line 435, in checkNeedUpdates
    name2,relpath2 = AltNames.get(name)
TypeError: cannot unpack non-iterable NoneType object

The reason was,, when you call AltNames.get(name), if name = Genesis 3 (or Genesis2 etc)

it will return None. about this case, it not return set as (name, relpath) but simply return none. so it cause error.

There were 2 function which use AltNames.get(name) in scan.py

One is 296 def loadScannedInfo(self, name)

def loadScannedInfo(self, name):
    def loadScanned(name, scanpath):
        defins = formulas = minmax = {}
        struct = getScannedFile(name, scanpath, True)
        if struct:
            defins = struct["definitions"]
            formulas = struct["formulas"]
            if "minmax" in struct.keys():
                minmax = struct["minmax"]
        return defins, formulas, minmax

    scanpath = getScanPath(name)
    if not os.path.exists(scanpath):
        raise DazError("Scanned morphs for %s do not exist" % name)
    self.defins, self.formulas, self.minmax = loadScanned(name, scanpath)
    altname = AltNames.get(name)
    if altname:
        name2,relpath2 = AltNames.get(name)
        scanpath2 = getScanPath(name2)
        self.defins2, self.formulas2, self.minmax2 = loadScanned(name2, scanpath2)

abobe code is I already correct, to avoid , name2,relpath2 = AltNames.get(name) when it return none.

Then second was

def checkNeedUpdates(name, relpath):
    needs = checkNeedUpdate(name, relpath)
    altname = AltNames.get(name)
    if altname and checkNeedUpdate(name2, relpath2):
        name2,relpath2 = altname
        needs.append(name2)
    return needs

Above code is I already corrected it too. (I use new altname variable and confirm it not return none. then set name2,relpath2 = AltNames.get(name)

though It worked for me, (not show error anymore), but anyway compare my edit version, and check it please.

I think if you may remain same problem ,when get None but try to use A of (A, B)

I attach my edit version .

===
above code, def checkNeedUpdates(name, relpath) may not work for G8, ^^: I correct and re attach my edit version, anyway Thomas check please. you may easy understand what is problem.

Comments (5)

  1. engetudouiti reporter

    I think if you use it it may not work for G8, now I correct it ^^;

    def checkNeedUpdates(name, relpath):
        needs = checkNeedUpdate(name, relpath)
        altname = AltNames.get(name)
        if altname:
            name2,relpath2 = altname
            needupdate = checkNeedUpdate(name2, relpath2)
            if needupdate:
                needs.append(name2)
        return needs
    

  2. Log in to comment