Preview images etc. for Asset Browser poses

Issue #961 resolved
Uwe Schmidt created an issue

I expanded the functionality of the pose library installer a bit.

There is an option to import preview images with the poses, also it’s possible to add a description, the author and some tags (comma seperated). I included the three image name systems I know (<file>.png,<file>.tip.png or <file>.<ext>.png). I prefer .tip.png, because when these are present, there are also smaller images which I found too small for my taste. When no preview image can be loaded, it will be generated.

I don’t really know how to handle catalogs yet. But since the tags work, it’s not really a problem to select a bunch of assets and move them to the right catalog manually.

diff --git a/animation.py b/animation.py
index da32dc1..f3d22f1 100644
--- a/animation.py
+++ b/animation.py
@@ -455,6 +455,28 @@ class PoseLibOptions:
         name = "Asset Browser",
         description = "Create asset browser library",
         default = True)
+
+    importPreviewImages : BoolProperty(
+        name = "Import Previews",
+        description = "Import preview images for imported poses",
+        default = False)
+
+    AssetTags : StringProperty(
+        name = "Tags",
+        description = "List of tags to add to the imported Poses",
+        default = "")
+
+    AssetAuthor : StringProperty(
+        name = "Author",
+        description = "Name of the Author",
+        default = "")
+
+    AssetDescription : StringProperty(
+        name = "Description",
+        description = "Description to add to all Poses",
+        default = "")
+
+


 class AnimatorBase(MultiFile, FrameConverter, ConvertOptions, AffectOptions, IsMeshArmature):
@@ -1215,7 +1237,12 @@ class PoselibBase(PoseLibOptions, AnimatorBase):
             self.layout.prop(self, "poseLibName")
         if bpy.app.version >= (3,0,0):
             self.layout.prop(self, "useAssetBrowser")
-
+            self.layout.prop(self, "importPreviewImages")
+            self.layout.prop(self, "AssetTags")
+            self.layout.prop(self, "AssetAuthor")
+            self.layout.prop(self, "AssetDescription")
+
+

     def clearAnimation(self, ob):
         if self.makeNewPoseLib:
@@ -1239,7 +1266,39 @@ class PoselibBase(PoseLibOptions, AnimatorBase):
         if bpy.app.version >= (3,0,0) and self.useAssetBrowser:
             bpy.ops.poselib.create_pose_asset(pose_name=name, activate_new_action=True)
             act = rig.animation_data.action
-            act.asset_generate_preview()
+            if self.importPreviewImages:
+                basename3,ext3 = os.path.splitext(filepath)
+                test1="%s.tip.png" % basename3
+                test2="%s.png" % filepath
+                test3="%s.png" % basename3
+                if os.path.exists(test1):
+                    previewFile=test1
+                elif os.path.exists(test2):
+                    previewFile=test2
+                elif os.path.exists(test3):
+                    previewFile=test3
+                else:
+                    previewFile=""
+                    print("No preview file found for %s" % name)
+
+                if os.path.exists(previewFile):
+                    bpy.ops.ed.lib_id_load_custom_preview({"id": act}, filepath=previewFile)
+                else:
+                    act.asset_generate_preview()
+            else:
+                act.asset_generate_preview()
+
+            if self.AssetTags:
+                tagList=self.AssetTags.split(",")
+                for newTag in tagList:
+                    act.id_data.asset_data.tags.new(newTag)
+
+            if self.AssetAuthor:
+                act.id_data.asset_data.author=self.AssetAuthor
+
+            if self.AssetDescription:
+                act.id_data.asset_data.description=self.AssetDescription
+
             #name = rig.animation_data.action.name
             #bpy.data.actions[name].asset_generate_preview()
         else:

Comments (5)

  1. Thomas Larsson repo owner

    Added in last commit, thank you for this. I have not really started to use the asset browser myself and didn’t find where the tags and author info went, but at least I can confirm that the preview images are loaded. Very nice.

  2. Uwe Schmidt reporter

    When you open the N-Panel in the Asset Browser and select an asset, you will find the metadata for the selected asset in the N-Panel.

    It’s possible to search for tags, but I did not see an easy way to filter by tag quickly. Still, using the search function, it’s possible to use them.

    Author and description are also there. Files with a lot of pose assets are still not recommended since generating the cached thumbnails can take very long, and even fail in some cases.

    Would you like me to write an article about the current state of the pose library in the asset browser for your blog?

  3. Thomas Larsson repo owner

    Hello Uwe, it would be great if you wrote a guest post on the asset browser. I would read it myself, since I haven’t had much time to study it. You could leave the material as an attachment here, I suppose.

  4. Log in to comment