Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVilém Duha <vilda.novak@gmail.com>2020-08-04 14:29:31 +0300
committerVilém Duha <vilda.novak@gmail.com>2020-08-04 14:35:48 +0300
commit54c325fd995edf501f2d2929f4e7584a173cf457 (patch)
tree40c4a72ec2cfeaec1ad974e1e3b72688d89eba86
parente74f7ad92d166cd087e3cab1e2ff14936215d036 (diff)
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
-rw-r--r--blenderkit/append_link.py74
-rw-r--r--blenderkit/ratings.py3
-rw-r--r--blenderkit/ui.py5
3 files changed, 46 insertions, 36 deletions
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: