[Bf-extensions-cvs] [54c325fd] blender-v2.90-release: BlenderKit: fix upload

Vilém Duha noreply at git.blender.org
Tue Aug 4 13:36:14 CEST 2020


Commit: 54c325fd995edf501f2d2929f4e7584a173cf457
Author: Vilém Duha
Date:   Tue Aug 4 13:29:31 2020 +0200
Branches: blender-v2.90-release
https://developer.blender.org/rBA54c325fd995edf501f2d2929f4e7584a173cf457

BlenderKit: fix upload

-upload was broken since changes in append_link - fake context wasn't possible there,reverting to old append method in such case.
-also assets inside assets could cause problem with ratings drawing check

===================================================================

M	blenderkit/append_link.py
M	blenderkit/ratings.py
M	blenderkit/ui.py

===================================================================

diff --git a/blenderkit/append_link.py b/blenderkit/append_link.py
index 5af63fe1..56b2857d 100644
--- a/blenderkit/append_link.py
+++ b/blenderkit/append_link.py
@@ -190,43 +190,45 @@ def append_particle_system(file_name, obnames=[], location=(0, 0, 0), link=False
 def append_objects(file_name, obnames=[], location=(0, 0, 0), link=False, **kwargs):
     '''append objects into scene individually'''
     #simplified version of append
-    scene = bpy.context.scene
-    sel = utils.selection_get()
-    bpy.ops.object.select_all(action='DESELECT')
-
-    path = file_name + "\\Collection\\"
-    object_name = kwargs.get('name')
-    fc = utils.get_fake_context(bpy.context, area_type='VIEW_3D')
-    bpy.ops.wm.append(fc,filename=object_name, directory=path)
-
-
-    return_obs = []
-    for ob in bpy.context.scene.objects:
-        if ob.select_get():
-            return_obs.append(ob)
-            if not ob.parent:
-                main_object = ob
-                ob.location = location
-
-    if kwargs.get('rotation'):
-        main_object.rotation_euler = kwargs['rotation']
-
-    if kwargs.get('parent') is not None:
-        main_object.parent = bpy.data.objects[kwargs['parent']]
-        main_object.matrix_world.translation = location
-
-    bpy.ops.object.select_all(action='DESELECT')
-    utils.selection_set(sel)
-
-    return main_object, return_obs
-
+    if kwargs.get('name'):
+        # by now used for appending into scene
+        scene = bpy.context.scene
+        sel = utils.selection_get()
+        bpy.ops.object.select_all(action='DESELECT')
+
+        path = file_name + "\\Collection\\"
+        object_name = kwargs.get('name')
+        fc = utils.get_fake_context(bpy.context, area_type='VIEW_3D')
+        bpy.ops.wm.append(fc, filename=object_name, directory=path)
+
+
+        return_obs = []
+        for ob in bpy.context.scene.objects:
+            if ob.select_get():
+                return_obs.append(ob)
+                if not ob.parent:
+                    main_object = ob
+                    ob.location = location
+
+        if kwargs.get('rotation'):
+            main_object.rotation_euler = kwargs['rotation']
+
+        if kwargs.get('parent') is not None:
+            main_object.parent = bpy.data.objects[kwargs['parent']]
+            main_object.matrix_world.translation = location
+
+        bpy.ops.object.select_all(action='DESELECT')
+        utils.selection_set(sel)
+
+        return main_object, return_obs
+    #this is used for uploads:
     with bpy.data.libraries.load(file_name, link=link, relative=True) as (data_from, data_to):
         sobs = []
-        for col in data_from.collections:
-            if col == kwargs.get('name'):
-                for ob in col.objects:
-                    if ob in obnames or obnames == []:
-                        sobs.append(ob)
+        # for col in data_from.collections:
+        #     if col == kwargs.get('name'):
+        for ob in data_from.objects:
+            if ob in obnames or obnames == []:
+                sobs.append(ob)
         data_to.objects = sobs
         # data_to.objects = data_from.objects#[name for name in data_from.objects if name.startswith("house")]
 
@@ -260,6 +262,8 @@ def append_objects(file_name, obnames=[], location=(0, 0, 0), link=False, **kwar
         for ob in hidden_objects:
             ob.hide_viewport = True
 
+    print(return_obs)
+    print(main_object)
     if kwargs.get('rotation') is not None:
         main_object.rotation_euler = kwargs['rotation']
 
diff --git a/blenderkit/ratings.py b/blenderkit/ratings.py
index 800749c8..7d246a9f 100644
--- a/blenderkit/ratings.py
+++ b/blenderkit/ratings.py
@@ -349,6 +349,9 @@ class FastRateMenu(Operator):
                                               ('20', '20', ''),
                                               ('50', '50', ''),
                                               ('100', '100', ''),
+                                              ('150', '100', ''),
+                                              ('200', '100', ''),
+                                              ('250', '100', ''),
                                               ],
                                        default='0', update=update_ratings_work_hours_ui
                                        )
diff --git a/blenderkit/ui.py b/blenderkit/ui.py
index 2822b826..5333b65e 100644
--- a/blenderkit/ui.py
+++ b/blenderkit/ui.py
@@ -1019,9 +1019,12 @@ def is_rating_possible():
             # crawl parents to reach active asset. there could have been parenting so we need to find the first onw
             ao_check = ao
             while ad is None or (ad is None and ao_check.parent is not None):
+                s = bpy.context.scene
                 ad = ao_check.get('asset_data')
                 if ad is not None:
-                    rated = bpy.context.scene['assets rated'].get(ad['assetBaseId'])
+
+                    s['assets rated'] = s.get('assets rated',{})
+                    rated = s['assets rated'].get(ad['assetBaseId'])
                     # originally hidden for already rated assets
                     return True, rated, ao_check, ad
                 elif ao_check.parent is not None:



More information about the Bf-extensions-cvs mailing list