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-01-04 21:42:10 +0300
committerVilém Duha <vilda.novak@gmail.com>2020-01-07 13:43:44 +0300
commit46fb3ac3a1990c6eaea0274c4987bf14de674a2b (patch)
tree2ea69404b372e12741cd2f4432787eed3d0a58bd /blenderkit
parent1a1fd78cd18a4e80bb53c1c580c98c8fa73522f1 (diff)
BlenderKit: replace bpy.context.active_object with bpy.context.view_layer.objects.active everywhere. This gives much less issues with context in queue.
Diffstat (limited to 'blenderkit')
-rw-r--r--blenderkit/asset_inspector.py2
-rw-r--r--blenderkit/autothumb.py6
-rw-r--r--blenderkit/download.py2
-rw-r--r--blenderkit/overrides.py6
-rw-r--r--blenderkit/paths.py1
-rw-r--r--blenderkit/search.py1
-rw-r--r--blenderkit/ui_panels.py12
-rw-r--r--blenderkit/upload.py6
-rw-r--r--blenderkit/utils.py12
9 files changed, 23 insertions, 25 deletions
diff --git a/blenderkit/asset_inspector.py b/blenderkit/asset_inspector.py
index e5d1d5cf..74f814ca 100644
--- a/blenderkit/asset_inspector.py
+++ b/blenderkit/asset_inspector.py
@@ -364,7 +364,7 @@ class AutoFillTags(bpy.types.Operator):
@classmethod
def poll(cls, context):
- return context.active_object is not None
+ return bpy.context.view_layer.objects.active is not None
def execute(self, context):
get_autotags()
diff --git a/blenderkit/autothumb.py b/blenderkit/autothumb.py
index 32dbb17b..06efd8a0 100644
--- a/blenderkit/autothumb.py
+++ b/blenderkit/autothumb.py
@@ -74,7 +74,7 @@ def update_upload_scene_preview(self, context):
def update_upload_material_preview(self, context):
if hasattr(bpy.context, 'active_object') \
- and bpy.context.active_object is not None \
+ and bpy.context.view_layer.objects.active is not None \
and bpy.context.active_object.active_material is not None:
mat = bpy.context.active_object.active_material
props = mat.blenderkit
@@ -247,7 +247,7 @@ class GenerateThumbnailOperator(bpy.types.Operator):
@classmethod
def poll(cls, context):
- return bpy.context.active_object is not None
+ return bpy.context.view_layer.objects.active is not None
def draw(self, context):
ob = bpy.context.active_object
@@ -290,7 +290,7 @@ class GenerateMaterialThumbnailOperator(bpy.types.Operator):
@classmethod
def poll(cls, context):
- return bpy.context.active_object is not None
+ return bpy.context.view_layer.objects.active is not None
def check(self, context):
return True
diff --git a/blenderkit/download.py b/blenderkit/download.py
index 6c3f8ccf..c6d22749 100644
--- a/blenderkit/download.py
+++ b/blenderkit/download.py
@@ -883,7 +883,7 @@ class BlenderkitDownloadOperator(bpy.types.Operator):
atype = asset_data['asset_type']
if bpy.context.mode != 'OBJECT' and (
- atype == 'model' or atype == 'material') and bpy.context.active_object is not None:
+ atype == 'model' or atype == 'material') and bpy.context.view_layer.objects.active is not None:
bpy.ops.object.mode_set(mode='OBJECT')
if self.replace: # cleanup first, assign later.
diff --git a/blenderkit/overrides.py b/blenderkit/overrides.py
index df9b1729..a0c76326 100644
--- a/blenderkit/overrides.py
+++ b/blenderkit/overrides.py
@@ -184,7 +184,7 @@ class BringToScene(Operator):
@classmethod
def poll(cls, context):
- return bpy.context.active_object is not None
+ return bpy.context.view_layer.objects.active is not None
def execute(self, context):
import bpy
@@ -249,7 +249,7 @@ class ModelProxy(Operator):
@classmethod
def poll(cls, context):
- return bpy.context.active_object is not None
+ return bpy.context.view_layer.objects.active is not None
def execute(self, context):
result = modelProxy()
@@ -265,7 +265,7 @@ class ColorCorrector(Operator):
@classmethod
def poll(cls, context):
- return bpy.context.active_object is not None
+ return bpy.context.view_layer.objects.active is not None
def execute(self, context):
ao = bpy.context.active_object
diff --git a/blenderkit/paths.py b/blenderkit/paths.py
index 3fc6db5e..3b0f22f9 100644
--- a/blenderkit/paths.py
+++ b/blenderkit/paths.py
@@ -33,7 +33,6 @@ BLENDERKIT_BRUSH_UPLOAD_INSTRUCTIONS_URL = "https://www.blenderkit.com/docs/uplo
BLENDERKIT_LOGIN_URL = "https://www.blenderkit.com/accounts/login"
BLENDERKIT_OAUTH_LANDING_URL = "/oauth-landing/"
BLENDERKIT_SIGNUP_URL = "https://www.blenderkit.com/accounts/register"
-BLENDERKIT_ADDON_URL = "https://www.blenderkit.com/api/v1/assets/6923b215-7df0-46f3-95ae-a2b5ff44ddd5/"
BLENDERKIT_ADDON_FILE_URL = "https://www.blenderkit.com/get-blenderkit/"
BLENDERKIT_SETTINGS_FILENAME = os.path.join(_presets, "bkit.json")
diff --git a/blenderkit/search.py b/blenderkit/search.py
index 1dd7e6c2..7fc540c6 100644
--- a/blenderkit/search.py
+++ b/blenderkit/search.py
@@ -106,7 +106,6 @@ def fetch_server_data():
''' download categories and addon version'''
if not bpy.app.background:
user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
- url = paths.BLENDERKIT_ADDON_URL
api_key = user_preferences.api_key
# Only refresh new type of tokens(by length), and only one hour before the token timeouts.
if user_preferences.enable_oauth and \
diff --git a/blenderkit/ui_panels.py b/blenderkit/ui_panels.py
index 4541de6a..fb3f944b 100644
--- a/blenderkit/ui_panels.py
+++ b/blenderkit/ui_panels.py
@@ -364,7 +364,7 @@ class VIEW3D_PT_blenderkit_model_properties(Panel):
@classmethod
def poll(cls, context):
- p = bpy.context.active_object is not None
+ p = bpy.context.view_layer.objects.active is not None
return p
def draw(self, context):
@@ -680,7 +680,7 @@ class VIEW3D_PT_blenderkit_unified(Panel):
if ui_props.asset_type == 'MODEL':
# label_multiline(layout, "Uploaded models won't be available in b2.79", icon='ERROR')
- if bpy.context.active_object is not None:
+ if bpy.context.view_layer.objects.active is not None:
draw_panel_model_upload(self, context)
else:
layout.label(text='selet object to upload')
@@ -690,7 +690,7 @@ class VIEW3D_PT_blenderkit_unified(Panel):
elif ui_props.asset_type == 'MATERIAL':
# label_multiline(layout, "Uploaded materials won't be available in b2.79", icon='ERROR')
- if bpy.context.active_object is not None and bpy.context.active_object.active_material is not None:
+ if bpy.context.view_layer.objects.active is not None and bpy.context.active_object.active_material is not None:
draw_panel_material_upload(self, context)
else:
label_multiline(layout, text='select object with material to upload materials', width=w)
@@ -705,12 +705,12 @@ class VIEW3D_PT_blenderkit_unified(Panel):
if ui_props.asset_type == 'MODEL':
# TODO improve poll here to parenting structures
- if bpy.context.active_object is not None and bpy.context.active_object.get('asset_data') != None:
+ if bpy.context.view_layer.objects.active is not None and bpy.context.active_object.get('asset_data') != None:
ad = bpy.context.active_object.get('asset_data')
layout.label(text=ad['name'])
draw_panel_model_rating(self, context)
if ui_props.asset_type == 'MATERIAL':
- if bpy.context.active_object is not None and \
+ if bpy.context.view_layer.objects.active is not None and \
bpy.context.active_object.active_material is not None and \
bpy.context.active_object.active_material.blenderkit.asset_base_id != '':
layout.label(text=bpy.context.active_object.active_material.blenderkit.name + ' :')
@@ -756,7 +756,7 @@ class OBJECT_MT_blenderkit_asset_menu(bpy.types.Menu):
op = layout.operator('view3d.blenderkit_search', text='Search Similar')
op.keywords = asset_data['name'] + ' ' + asset_data['description'] + ' ' + ' '.join(asset_data['tags'])
- if bpy.context.active_object is not None and ui_props.asset_type == 'MODEL':
+ if bpy.context.view_layer.objects.active is not None and ui_props.asset_type == 'MODEL':
aob = bpy.context.active_object
op = layout.operator('scene.blenderkit_download', text='Replace Active Models')
op.asset_type = ui_props.asset_type
diff --git a/blenderkit/upload.py b/blenderkit/upload.py
index 4b02d321..44bbb313 100644
--- a/blenderkit/upload.py
+++ b/blenderkit/upload.py
@@ -486,13 +486,13 @@ def get_upload_location(props):
scene = bpy.context.scene
ui_props = scene.blenderkitUI
if ui_props.asset_type == 'MODEL':
- if bpy.context.active_object is not None:
+ if bpy.context.view_layer.objects.active is not None:
ob = utils.get_active_model()
return ob.location
if ui_props.asset_type == 'SCENE':
return None
elif ui_props.asset_type == 'MATERIAL':
- if bpy.context.active_object is not None and bpy.context.active_object.active_material is not None:
+ if bpy.context.view_layer.objects.active is not None and bpy.context.active_object.active_material is not None:
return bpy.context.active_object.location
elif ui_props.asset_type == 'TEXTURE':
return None
@@ -740,7 +740,7 @@ class UploadOperator(Operator):
@classmethod
def poll(cls, context):
- return bpy.context.active_object is not None
+ return bpy.context.view_layer.objects.active is not None
def execute(self, context):
bpy.ops.object.blenderkit_auto_tags()
diff --git a/blenderkit/utils.py b/blenderkit/utils.py
index 3b7eac20..784fc47b 100644
--- a/blenderkit/utils.py
+++ b/blenderkit/utils.py
@@ -66,8 +66,8 @@ def selection_set(sel):
def get_active_model():
- if hasattr(bpy.context, 'active_object'):
- ob = bpy.context.active_object
+ if bpy.context.view_layer.objects.active is not None:
+ ob = bpy.context.view_layer.objects.active
while ob.parent is not None:
ob = ob.parent
return ob
@@ -130,14 +130,14 @@ def get_active_asset():
scene = bpy.context.scene
ui_props = scene.blenderkitUI
if ui_props.asset_type == 'MODEL':
- if bpy.context.active_object is not None:
+ if bpy.context.view_layer.objects.active is not None:
ob = get_active_model()
return ob
if ui_props.asset_type == 'SCENE':
return bpy.context.scene
elif ui_props.asset_type == 'MATERIAL':
- if bpy.context.active_object is not None and bpy.context.active_object.active_material is not None:
+ if bpy.context.view_layer.objects.active is not None and bpy.context.active_object.active_material is not None:
return bpy.context.active_object.active_material
elif ui_props.asset_type == 'TEXTURE':
return None
@@ -152,14 +152,14 @@ def get_upload_props():
scene = bpy.context.scene
ui_props = scene.blenderkitUI
if ui_props.asset_type == 'MODEL':
- if bpy.context.active_object is not None:
+ if bpy.context.view_layer.objects.active is not None:
ob = get_active_model()
return ob.blenderkit
if ui_props.asset_type == 'SCENE':
s = bpy.context.scene
return s.blenderkit
elif ui_props.asset_type == 'MATERIAL':
- if bpy.context.active_object is not None and bpy.context.active_object.active_material is not None:
+ if bpy.context.view_layer.objects.active is not None and bpy.context.active_object.active_material is not None:
return bpy.context.active_object.active_material.blenderkit
elif ui_props.asset_type == 'TEXTURE':
return None