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:
authorVilem Duha <vilem.duha@gmail.com>2021-07-07 20:21:20 +0300
committerJeroen Bakker <jeroen@blender.org>2021-07-26 09:11:52 +0300
commitae7be84e2d6cc55102682793baffb415f03ab911 (patch)
tree0907c59cb74b7e0c0cbd62b6b0ec5f5aff3db816
parent29db4b5feb893fdd02cd45b12037e0e5ac3cd22c (diff)
BlenderKit: fix an error when trying to assign material to unsupported object type
-do same warning for drag-drop although that can be now further improved since it seems ray cast to other object types works already) -remove some old prints
-rw-r--r--blenderkit/__init__.py2
-rw-r--r--blenderkit/append_link.py1
-rw-r--r--blenderkit/asset_bar_op.py2
-rw-r--r--blenderkit/asset_inspector.py2
-rw-r--r--blenderkit/autothumb.py2
-rw-r--r--blenderkit/download.py2
-rw-r--r--blenderkit/ratings.py15
-rw-r--r--blenderkit/search.py10
-rw-r--r--blenderkit/ui.py18
-rw-r--r--blenderkit/utils.py4
10 files changed, 25 insertions, 33 deletions
diff --git a/blenderkit/__init__.py b/blenderkit/__init__.py
index c58e5d99..37fa907f 100644
--- a/blenderkit/__init__.py
+++ b/blenderkit/__init__.py
@@ -141,8 +141,6 @@ from bpy.types import (
@persistent
def scene_load(context):
- print('loading in background')
- print(bpy.context.window_manager)
if not bpy.app.background:
search.load_previews()
ui_props = bpy.context.scene.blenderkitUI
diff --git a/blenderkit/append_link.py b/blenderkit/append_link.py
index 28b0d24e..5b54a81b 100644
--- a/blenderkit/append_link.py
+++ b/blenderkit/append_link.py
@@ -67,7 +67,6 @@ def append_material(file_name, matname=None, link=False, fake_user=True):
# we have to find the new material , due to possible name changes
mat = None
for m in bpy.data.materials:
- print(m.name)
if m not in mats_before:
mat = m
break;
diff --git a/blenderkit/asset_bar_op.py b/blenderkit/asset_bar_op.py
index 30d94e27..0ad63a83 100644
--- a/blenderkit/asset_bar_op.py
+++ b/blenderkit/asset_bar_op.py
@@ -633,7 +633,7 @@ class BlenderKitAssetBarOperator(BL_UI_OT_draw_operator):
properties_width = r.width
tooltip_x = min(widget.x_screen + widget.width,
bpy.context.region.width - self.tooltip_panel.width - properties_width)
- print(widget.x_screen + widget.width, bpy.context.region.width - self.tooltip_panel.width)
+ # print(widget.x_screen + widget.width, bpy.context.region.width - self.tooltip_panel.width)
def register():
diff --git a/blenderkit/asset_inspector.py b/blenderkit/asset_inspector.py
index ecc2ccf1..72b9827d 100644
--- a/blenderkit/asset_inspector.py
+++ b/blenderkit/asset_inspector.py
@@ -174,7 +174,7 @@ def check_printable(props, obs):
for item in info:
passed = item[0].endswith(' 0')
if not passed:
- print(item[0])
+ # print(item[0])
printable = False
props.printable_3d = printable
diff --git a/blenderkit/autothumb.py b/blenderkit/autothumb.py
index b7f2a8d0..8eb891b0 100644
--- a/blenderkit/autothumb.py
+++ b/blenderkit/autothumb.py
@@ -68,7 +68,7 @@ def get_texture_ui(tpath, iname):
def check_thumbnail(props, imgpath):
img = utils.get_hidden_image(imgpath, 'upload_preview', force_reload=True)
- print(' check thumbnail ', img)
+ # print(' check thumbnail ', img)
if img is not None: # and img.size[0] == img.size[1] and img.size[0] >= 512 and (
# img.file_format == 'JPEG' or img.file_format == 'PNG'):
props.has_thumbnail = True
diff --git a/blenderkit/download.py b/blenderkit/download.py
index f0c101a1..a217cc83 100644
--- a/blenderkit/download.py
+++ b/blenderkit/download.py
@@ -319,7 +319,6 @@ def append_asset(asset_data, **kwargs): # downloaders=[], location=None,
if scene is not None:
props = scene.blenderkit
asset_main = scene
- # print(sprops.switch_after_append)
if sprops.switch_after_append:
bpy.context.window_manager.windows[0].scene = scene
@@ -1036,7 +1035,6 @@ def asset_in_scene(asset_data):
au = scene.get('assets used', {})
id = asset_data['assetBaseId']
- print(id)
if id in au.keys():
ad = au[id]
if ad.get('files'):
diff --git a/blenderkit/ratings.py b/blenderkit/ratings.py
index cde57893..2a3ac76b 100644
--- a/blenderkit/ratings.py
+++ b/blenderkit/ratings.py
@@ -58,21 +58,6 @@ def upload_review_thread(url, reviews, headers):
# print('reviews upload failed: %s' % str(e))
-def get_rating(asset_id):
- # this function isn't used anywhere,should probably get removed.
- user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
- api_key = user_preferences.api_key
- headers = utils.get_headers(api_key)
- rl = paths.get_api_url() + 'assets/' + asset['asset_data']['id'] + '/rating/'
- rtypes = ['quality', 'working_hours']
- for rt in rtypes:
- params = {
- 'rating_type': rt
- }
- r = rerequests.get(r1, params=data, verify=True, headers=headers)
- print(r.text)
-
-
def upload_rating(asset):
user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
api_key = user_preferences.api_key
diff --git a/blenderkit/search.py b/blenderkit/search.py
index 3683a1ed..310d1138 100644
--- a/blenderkit/search.py
+++ b/blenderkit/search.py
@@ -443,14 +443,14 @@ def search_timer():
result_field.append(asset_data)
# Get ratings from BlenderKit server
- # if utils.profile_is_validator():
user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
api_key = user_preferences.api_key
headers = utils.get_headers(api_key)
- for r in rdata['results']:
- if ratings_utils.get_rating_local(asset_data['id']) is None:
- rating_thread = threading.Thread(target=ratings_utils.get_rating, args=([r['id'], headers]), daemon=True)
- rating_thread.start()
+ if utils.profile_is_validator():
+ for r in rdata['results']:
+ if ratings_utils.get_rating_local(asset_data['id']) is None:
+ rating_thread = threading.Thread(target=ratings_utils.get_rating, args=([r['id'], headers]), daemon=True)
+ rating_thread.start()
wm[search_name] = result_field
wm['search results'] = result_field
diff --git a/blenderkit/ui.py b/blenderkit/ui.py
index 7b51eb65..580a66e5 100644
--- a/blenderkit/ui.py
+++ b/blenderkit/ui.py
@@ -767,9 +767,8 @@ def deep_ray_cast(depsgraph, ray_origin, vec):
empty_set = False, Vector((0, 0, 0)), Vector((0, 0, 1)), None, None, None
if not object:
return empty_set
-
try_object = object
-
+ print(object.type)
while try_object and (try_object.display_type == 'BOUNDS' or object_in_particle_collection(try_object)):
ray_origin = snapped_location + vec.normalized() * 0.0003
try_has_hit, try_snapped_location, try_snapped_normal, try_face_index, try_object, try_matrix = bpy.context.scene.ray_cast(
@@ -1535,7 +1534,7 @@ class AssetBarOperator(bpy.types.Operator):
else:
# first, test if object can have material applied.
# TODO add other types here if droppable.
- if object is not None and not object.is_library_indirect and object.type == 'MESH':
+ if object is not None and not object.is_library_indirect and object.type in utils.supported_material_drag:
target_object = object.name
# create final mesh to extract correct material slot
depsgraph = bpy.context.evaluated_depsgraph_get()
@@ -1549,7 +1548,11 @@ class AssetBarOperator(bpy.types.Operator):
message="Please select the model,"
"go to the 'Selected Model' panel "
"in BlenderKit and hit 'Bring to Scene' first.")
-
+ print(object.type)
+ if object.type not in utils.supported_material_drag:
+ ui_panels.ui_message(title='Unsupported object type',
+ message="Only meshes are supported for material drag-drop.\n "
+ "Use click interaction for other object types.")
self.report({'WARNING'}, "Invalid or library object as input:")
target_object = ''
target_slot = ''
@@ -1561,12 +1564,17 @@ class AssetBarOperator(bpy.types.Operator):
if ui_props.asset_type in ('MATERIAL',
'MODEL'): # this was meant for particles, commenting for now or ui_props.asset_type == 'MODEL':
ao = bpy.context.active_object
- if ao != None and not ao.is_library_indirect:
+ supported_material_click = ('MESH', 'CURVE', 'META', 'FONT', 'SURFACE', 'VOLUME', 'GPENCIL')
+ if ao != None and not ao.is_library_indirect and ao.type in supported_material_click:
target_object = bpy.context.active_object.name
target_slot = bpy.context.active_object.active_material_index
# change snapped location for placing material downloader.
ui_props.snapped_location = bpy.context.active_object.location
else:
+ if ao != None and ui_props.asset_type == 'MATERIAL' and ao.type not in supported_material_click:
+ ui_panels.ui_message(title='Unsupported object type',
+ message="Can't assign material to this object type."
+ "Please select another object.")
target_object = ''
target_slot = ''
# FIRST START SEARCH
diff --git a/blenderkit/utils.py b/blenderkit/utils.py
index 930fbd79..fd01e74b 100644
--- a/blenderkit/utils.py
+++ b/blenderkit/utils.py
@@ -38,6 +38,10 @@ IDLE_PRIORITY_CLASS = 0x00000040
NORMAL_PRIORITY_CLASS = 0x00000020
REALTIME_PRIORITY_CLASS = 0x00000100
+supported_material_click = ('MESH', 'CURVE', 'META', 'FONT', 'SURFACE', 'VOLUME', 'GPENCIL')
+# supported_material_drag = ('MESH', 'CURVE', 'META', 'FONT', 'SURFACE', 'VOLUME', 'GPENCIL')
+supported_material_drag = ('MESH')
+
def experimental_enabled():
preferences = bpy.context.preferences.addons['blenderkit'].preferences