Import Pose Library/Blender Asset Browser Bug

Issue #1892 duplicate
GeneralProtectionFault created an issue

System: AMD Ryzen 5, NVIDIA RTX 3060 12 GB, 96 GB RAM, Windows 10.

Blender: 4.0.2

DAZ Studio: 4.22.0.15

Dipheomorphic: 1.7.3

Generally speaking, I referenced this page: https://diffeomorphic.blogspot.com/p/posing-panel.html, which appears to be out-dated. I think a pose library is now meant to show up in the asset browser, but regardless, I did not see it show up in the armature tab.

Imported a G8 female, merged geografts and tried to import a pose library, selecting 5 .duf or matching .png files. Tried this after converting to MHX rig & kept the DAZ rig for deformations. Also tried without touching the rigging (vanilla DAX rig).

If Blender’s Asset Browser is NOT one of the windows, it appears to import the poses, but are sometimes messed up, and there is no pose library created. Here is the output when doing so:

Anime Pose 001.duf 1
Character: genesis_8_female
Auto-detected genesis8 character in duf/dsf file

Anime Pose 002.duf 2
Character: genesis_8_female
Auto-detected genesis8 character in duf/dsf file

Anime Pose 003.duf 3
Character: genesis_8_female
Auto-detected genesis8 character in duf/dsf file

Anime Pose 004.duf 4
Character: genesis_8_female
Auto-detected genesis8 character in duf/dsf file

Anime Pose 005.duf 5
Character: genesis_8_female
Auto-detected genesis8 character in duf/dsf file
File C:\Users\blahblah\Documents\DAZ 3D\Studio\My Library\people\genesis 8 female\Poses\Ensary\Anime Poses For Genesis 8 Female\Anime Pose 005.png imported in 3.623 seconds

Now, if I DO make one of the Blender windows an asset browser and try the same operation, it tries to import one pose and then fails with the following output in Blender:

Anime Pose 001.duf 1
Character: genesis_8_female
Auto-detected genesis8 character in duf/dsf file
Traceback (most recent call last):
File "C:\Users\blahblah\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\import_daz\error.py", line 223, in execute
self.run(context)
File "C:\Users\blahblah\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\import_daz\animation.py", line 1690, in run
StandardAnimation.run(self, context)
File "C:\Users\blahblah\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\import_daz\animation.py", line 1441, in run
offset,prop = self.getSingleAnimation(filepath, context, offset)
File "C:\Users\blahblah\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\import_daz\animation.py", line 821, in getSingleAnimation
result = self.animateBones(context, nanims, offset, prop, filepath)
File "C:\Users\blahblah\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\import_daz\animation.py", line 1111, in animateBones
self.addToPoseLib(rig, filepath)
File "C:\Users\blahblah\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\import_daz\animation.py", line 1640, in addToPoseLib
bpy.ops.poselib.create_pose_asset(pose_name=name, activate_new_action=True)
File "C:\blender-4.0.2-windows-x64\4.0\scripts\modules\bpy\ops.py", line 109, in call
ret = _op_call(self.idname_py(), kw)
RuntimeError: Operator bpy.ops.poselib.create_pose_asset.poll() Asset Browser must be set to the Current File library

No pose library appears, but it does seem to apply the first pose that it “tried.”

Comments (18)

  1. GeneralProtectionFault reporter

    UPDATE: It looks like it is possible to work around this. So, following that error message, it actually is quite literal. If you have an asset browser open, it works if you select Current File from the dropdown:

    However, it still does not create the pose “library.” It just goes into “unassigned.” You can make your own “catalog” and drag them in, at least.

    So, I’m not sure what the best solution is, but I am guessing this goes back to 3.whatever--I recall there being a change like this where the asset browser became the intended way to organize stuff like this. It might be a terminology shift too, i.e. library => catalog or whatever.

    Another thing is that while the poses import, the preview images do not show up in the asset browser, just what I’m assuming are Blender’s automatic tiny representation of the pose.

    I suppose the fix would be something like programatically opening an asset browser and selecting Current File, and creating a new catalog with the name typed in by the user. Not sure how easy Blender makes that, but if nothing else, maybe an instruction pop-up that explains that you need to do this first if nothing else 😅

  2. Alessandro Padovani

    daz studio 4.21.0.5, blender 3.6.7 or 4.0.2, diffeomorphic 1.7.3.1937

    bug. current file (blender 3 and 4). I can confirm the python crash if the asset browser is not in current file. This affects both blender 3 and 4.

    steps:

    1. import G8F
    2. open the asset browser and don’t set as “current file”
    3. import a pose library

    bug. new catalog (blender 3 and 4). I can confirm that the addon doesn’t create a new catalog with the imported poses, they are unassigned, must be assigned to a new catalog by hand. Steps as above but setting current file.

    bug. import previews (blender 4 only). In blender 4 python crashes if “import previews” is enabled, if not the poses are imported but previews are not generated because the camera is not found, even if there’s a camera in the scene.

    steps:

    1. import a daz scene with G8F and a camera
    2. open the asset browser and set as “current file” to avoid a python crash
    3. import a pose library with “import previews“

  3. Thomas Larsson repo owner

    The crashes are avoided in last commit, even if the basic problems are not solved. I searched a bit but didn’t find a good way to handle catalogs or to change the asset library from python.

  4. Alessandro Padovani

    Commit 2f5493f

    Thank you for looking into this. The commit is good in that python doesn't crash anymore but reports an error instead. In blender 4 the daz thumbnails are not copied, while blender 3 works fine. If it can help, by reading the info panel it seems as below:

    # set asset browser to current file
    bpy.context.space_data.params.asset_library_reference = 'LOCAL'
    

    We now prepare for the party tonight, happy new year !

  5. GeneralProtectionFault reporter

    I’m taking a look at this, I’ll help if I can. I’m not that experienced, but I know Blender is annoying/sketch on documenting messing with the context, you can’t just set it like any ol' property. However, looking at their example code, I got this far:

    import bpy
    from bpy import context
    import logging
    
    
    file_browser_exists = False
    
    for window in context.window_manager.windows:
        screen = window.screen
        for area in screen.areas:
            if area.type == 'FILE_BROWSER':
                file_browser_exists = True
    
                if file_browser_exists:
                    with context.temp_override(window=window, area=area):
                        # bpy.ops.screen.screen_full_area()
                        context.space_data.params.asset_library_reference = 'LOCAL'
                        print(context)
                        catalog = bpy.ops.asset.catalog_new()
                        print(catalog)
                    break
    

    First, that assumes there is an Asset Browser ( FILE_BROWSER :-| ) window, worrying about adding one later. So that successfully adds a catalog named “Catalog” :-P, EXCEPT if you’re on “ALL”. It looks like “ALL” is the only one that throws an error. Current File, Essentials & User Library appear to be ok. This also works to switch the context, but w/ a race condition, it switches it after it tries to add the catalog. Gonna fiddle with it some more.

  6. GeneralProtectionFault reporter

    I essentially tried plugging the code above into the plugin and it worked, but that FILE_BROWSER applies to the actual file browser & the asset browser. ASSET_BROWSER is not in the enum (why this is, I have no idea), so I’m not sure how you check explicitly for an asset browser. If there is an actual file browser in there it’ll break. My thought is if that little hump can be surmounted, it’d be best just to show a pop-up asking the user to create an asset browser. Otherwise, it’d be necessary to muck with their setup/windows and nobody’s crazy about that. On the other hand, it’s probably possible to do store the user’s current layout, change it, add the library, change it back. Blender’s API documentation is mediocre though, so not fun.

  7. GeneralProtectionFault reporter
      <div class="preview-container wiki-content"><!-- loaded via ajax --></div>
      <div class="mask"></div>
    </div>
    

    </div> </form>

  8. GeneralProtectionFault reporter

    Ugh, this Bitbucket interface really leaves something to be desired… Uploaded a file and it took away my existing comments… Anyway…

    The file I attached ^^^^^ is a beginning to a fix:

    • Import Pose Library

      • If there is an asset browser, and ‘ALL’ is not selected, it will successfully create a catalog, called “Catalog”

        • I don’t see how to rename this, which is kinda bananas 😩
      • If there is no asset browser, a pop-up message will display asking the user to create one and not to select ‘ALL’

      • If they DO have an asset browser and ALL IS selected, it will throw an error as before.

        • This is only because of the race condition I mentioned above, don’t know right off the top of my head how best to deal with that in Blender’s context soup.
      • Preview images will now load, fix for that buried here, epic SEO Fail 😠 : https://wiki.blender.org/wiki/Source/Architecture/Asset_System/FAQ#How_do_I_load_custom_previews.3F

      • *** Something odd *** I notice a few of the properties, including usePreviewImages do not show up in the Blender UI when selecting Import Pose Library. In any case, the property was defaulted to False before, but I changed this to True in order to get the preview images in. Apparently, the variable is there, just not showing up for some reason (at least for me), while most of them do.

    Import Pose still works as before, which does set the pose on the model, but it doesn’t save it anywhere. Don’t know what the intent is there, but I’m not sure how y’all wired that up, but I figure with the changes here it can be easily woven in if desired.

  9. Alessandro Padovani

    Thank you for looking into this. If it is too much complicated to deal with it, I guess it is fair to just catch the error and warn the user, that’s essentially what the actual code is doing. Fixing the thumbnails in blender 4 would be good though.

    Again happy new year !

  10. GeneralProtectionFault reporter

    No problem. The file I attached does fix the thumbnails. Also, I see why the Use Preview Images option is not there, it’s commented out. So just uncommenting that will fix it.

    I don’t think the problem is too complicated, it’s basically fixed as long as the user has an Asset Browser window and it’s not on “ALL.” I am sure it’s possible to fix the race condition too, so “ALL” does not have to be avoided, I just hadn’t gotten that far yet.

    I have a feeling it’s “probably” doable to manipulate the workspace too, I’m just not very good at Blender’s API yet😅. However, I think that’s also a design question… Like if you would want to impose on the user’s workspace, etc….

  11. Thomas Larsson repo owner

    When I looked for a solution online I only found similar examples, using screen areas to find an asset browser. That seems quite awkward to me. I would prefer to have a way to create catalogs and assigning assets to it, without having to know about screen areas and preferably not using context-dependent operators at all. The Blender API doesn’t seem finished in this respect, and I think I will wait until it is.

    Then I don’t use the asset browser myself to store poses, nor did I ever use the old pose library. There are alternatives for daz assets:

    1. Poses can be loaded from pose presets (duf files that other people have written). That’s often a great starting point for posing.
    2. If auto keying is enabled, an action is created with the pose (or poses, if several pose presets were selected). That action can be use in other blend files.
    3. Poses can be stored with the Save Pose Preset tool for use in DS or Blender. Although I don’t use that either.

    Btw, Import Preview was commented away due to the crash the Alessandro reported above.

  12. GeneralProtectionFault reporter

    I hear ya. I might fork y’all and play with it on my own, the pose library feature is handy for me if you have a lot of DAZ poses and can just double click between a lot of them (though I’m admittedly still figuring out all this stuff in general, like dealing with custom morphs, etc… 😅 ).

    I agree the Blender API might not be up to snuff, but not sure if there’s a guarantee it will be by simply waiting. I looked at the source and I “think” the new catalog is hard-coded to be named “Catalog” which is plain silly LOL. Also, their documentation seems to sort of point to the necessity of that temp_override (context) and it seems to come up a lot.

    Anyhoo, if going that route, my 2 cents would be at least keep the pop-up functionality and just alter the text to indicate that it’s not implemented until Blender gets its act together, instead of throwing up the error. That way, when someone runs into it, they won’t think it’s a bug and re-hash this.

    Also, the preview fix works straight up and removes the necessity to comment out the option. Indeed, that is also a context override, but it seems to work pretty smoothly without janky work-arounds.

    Anyhoo, thanks for all the awesome work on this 👏

  13. Alessandro Padovani

    @Thomas, that doesn’t fix the missing preview icons in blender 4. If the code by General can fix it then would be nice to have, otherwise it’s a missing feature, that is, we can only do preview icons in blender 3. Let us know.

  14. GeneralProtectionFault reporter

    If y’all decide you do want to use any of it, I did go ahead and fork this so I could use the workaround if I needed to. Here’s the commit on my fork, so feel free to look at the diff:

    https://bitbucket.org/gpf-gamedev/import_daz/commits/751e2c2afd0da8a337b4c3e3fd96e194804a1eda

    Scroll all the way down to the stuff around line 1700+, that’s the change that would affect previews. To be clear, I only tested it on the latest blender.

    Of course, if not implementing the Import Pose Library feature, then the preview images would never have a purpose anyway 😅 , but maybe that is useful elsewhere too, I don’t know the plugin nearly as well as you two.

  15. Log in to comment