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-07-01 17:11:32 +0300
committerVilém Duha <vilda.novak@gmail.com>2020-07-01 17:11:56 +0300
commitc6453b9803f2f945ff85a9549b80cad8c1f9600f (patch)
tree9a176b6abca5ad36d0ea7b3ce939954ba17651d4 /blenderkit
parent1b1b58b2ab1c57171c160e0b0663acf9b1a61220 (diff)
BlenderKit: fix search filters
-procedural search wasn't working properly -displaying files size in tooltip was broken -search by files size had misleading description -small UI fixes. -fix link to plans
Diffstat (limited to 'blenderkit')
-rw-r--r--blenderkit/__init__.py12
-rw-r--r--blenderkit/paths.py2
-rw-r--r--blenderkit/search.py84
-rw-r--r--blenderkit/ui_panels.py12
4 files changed, 65 insertions, 45 deletions
diff --git a/blenderkit/__init__.py b/blenderkit/__init__.py
index de47ed86..449e65a4 100644
--- a/blenderkit/__init__.py
+++ b/blenderkit/__init__.py
@@ -255,19 +255,19 @@ def asset_type_callback(self, context):
# ui_props = s.blenderkitUI
if self.down_up == 'SEARCH':
items = (
- ('MODEL', 'Find Models', 'Find models in the BlenderKit online database', 'OBJECT_DATAMODE', 0),
+ ('MODEL', 'Models', 'Find models in the BlenderKit online database', 'OBJECT_DATAMODE', 0),
# ('SCENE', 'SCENE', 'Browse scenes', 'SCENE_DATA', 1),
- ('MATERIAL', 'Find Materials', 'Find models in the BlenderKit online database', 'MATERIAL', 2),
+ ('MATERIAL', 'Materials', 'Find models in the BlenderKit online database', 'MATERIAL', 2),
# ('TEXTURE', 'Texture', 'Browse textures', 'TEXTURE', 3),
- ('BRUSH', 'Find Brushes', 'Find models in the BlenderKit online database', 'BRUSH_DATA', 3)
+ ('BRUSH', 'Brushes', 'Find models in the BlenderKit online database', 'BRUSH_DATA', 3)
)
else:
items = (
- ('MODEL', 'Upload Model', 'Upload a model to BlenderKit', 'OBJECT_DATAMODE', 0),
+ ('MODEL', 'Model', 'Upload a model to BlenderKit', 'OBJECT_DATAMODE', 0),
# ('SCENE', 'SCENE', 'Browse scenes', 'SCENE_DATA', 1),
- ('MATERIAL', 'Upload Material', 'Upload a material to BlenderKit', 'MATERIAL', 2),
+ ('MATERIAL', 'Material', 'Upload a material to BlenderKit', 'MATERIAL', 2),
# ('TEXTURE', 'Texture', 'Browse textures', 'TEXTURE', 3),
- ('BRUSH', 'Upload Brush', 'Upload a brush to BlenderKit', 'BRUSH_DATA', 3)
+ ('BRUSH', 'Brush', 'Upload a brush to BlenderKit', 'BRUSH_DATA', 3)
)
return items
diff --git a/blenderkit/paths.py b/blenderkit/paths.py
index 8b5e7f0c..2f144268 100644
--- a/blenderkit/paths.py
+++ b/blenderkit/paths.py
@@ -25,7 +25,7 @@ BLENDERKIT_DEVEL = "https://devel.blenderkit.com"
BLENDERKIT_API = "/api/v1/"
BLENDERKIT_REPORT_URL = "usage_report/"
BLENDERKIT_USER_ASSETS = "/my-assets"
-BLENDERKIT_PLANS = "https://www.blenderkit.com/plans/pricing/"
+BLENDERKIT_PLANS = "/plans/pricing/"
BLENDERKIT_MANUAL = "https://youtu.be/1hVgcQhIAo8"
BLENDERKIT_MODEL_UPLOAD_INSTRUCTIONS_URL = "https://www.blenderkit.com/docs/upload/"
BLENDERKIT_MATERIAL_UPLOAD_INSTRUCTIONS_URL = "https://www.blenderkit.com/docs/uploading-material/"
diff --git a/blenderkit/search.py b/blenderkit/search.py
index 9dab75da..474630e6 100644
--- a/blenderkit/search.py
+++ b/blenderkit/search.py
@@ -101,7 +101,8 @@ def refresh_token_timer():
return max(3600, user_preferences.api_key_life - 3600)
-def update_assets_data():# updates assets data on scene load.
+
+def update_assets_data(): # updates assets data on scene load.
'''updates some properties that were changed on scenes with older assets.
The properties were mainly changed from snake_case to CamelCase to fit the data that is coming from the server.
'''
@@ -109,12 +110,14 @@ def update_assets_data():# updates assets data on scene load.
if ob.get('asset_data') != None:
ad = ob['asset_data']
if not ad.get('assetBaseId'):
- ad['assetBaseId'] = ad['asset_base_id'],#this should stay ONLY for compatibility with older scenes
- ad['assetType'] = ad['asset_type'],#this should stay ONLY for compatibility with older scenes
- ad['canDownload'] = ad['can_download'],#this should stay ONLY for compatibility with older scenes
- ad['verificationStatus'] = ad['verification_status'],#this should stay ONLY for compatibility with older scenes
+ ad['assetBaseId'] = ad['asset_base_id'], # this should stay ONLY for compatibility with older scenes
+ ad['assetType'] = ad['asset_type'], # this should stay ONLY for compatibility with older scenes
+ ad['canDownload'] = ad['can_download'], # this should stay ONLY for compatibility with older scenes
+ ad['verificationStatus'] = ad[
+ 'verification_status'], # this should stay ONLY for compatibility with older scenes
ad['author'] = {}
- ad['author']['id'] = ad['author_id'],#this should stay ONLY for compatibility with older scenes
+ ad['author']['id'] = ad['author_id'], # this should stay ONLY for compatibility with older scenes
+
@persistent
def scene_load(context):
@@ -173,6 +176,7 @@ def check_clipboard():
search_props.search_keywords = last_clipboard
# don't run search after this - assigning to keywords runs the search_update function.
+
def parse_result(r):
'''
needed to generate some extra data in the result(by now)
@@ -211,7 +215,7 @@ def parse_result(r):
# for some reason, the id was still int on some occurances. investigate this.
r['author']['id'] = str(r['author']['id'])
- #some helper props, but generally shouldn't be renaming/duplifiying original properties,
+ # some helper props, but generally shouldn't be renaming/duplifiying original properties,
# so blender's data is same as on server.
asset_data = {'thumbnail': tname,
'thumbnail_small': small_tname,
@@ -260,7 +264,7 @@ def parse_result(r):
if r['assetBaseId'] in scene.get('assets used', {}).keys():
asset_data['downloaded'] = 100
- #attempt to switch to use original data gradually, since the parsing as itself should become obsolete.
+ # attempt to switch to use original data gradually, since the parsing as itself should become obsolete.
asset_data.update(r)
return asset_data
@@ -287,7 +291,7 @@ def timer_update():
search()
preferences.first_run = False
- #check_clipboard()
+ # check_clipboard()
global search_threads
if len(search_threads) == 0:
@@ -341,7 +345,7 @@ def timer_update():
if asset_data != None:
result_field.append(asset_data)
- # results = rdata['results']
+ # results = rdata['results']
s[search_name] = result_field
s['search results'] = result_field
s[search_name + ' orig'] = rdata
@@ -542,6 +546,16 @@ def generate_tooltip(mdata):
if has(mparams, 'faceCount'):
t += 'face count: %s, render: %s\n' % (mparams['faceCount'], mparams['faceCountRender'])
+ # write files size - this doesn't reflect true file size, since files size is computed from all asset files, including resolutions.
+ if mdata.get('filesSize'):
+ fs = mdata['filesSize']
+ fsmb = fs // 1024
+ fskb = fs % 1024
+ if fsmb == 0:
+ t += 'files size: %iKB\n' % fskb
+ else:
+ t += 'files size: %iMB %iKB\n' % (fsmb, fskb)
+
# t = writeblockm(t, mparams, key='meshPolyType', pretext='mesh type', width = col_w)
# t = writeblockm(t, mparams, key='objectCount', pretext='nubmber of objects', width = col_w)
@@ -811,7 +825,7 @@ class Searcher(threading.Thread):
# assumes no keywords and no category, thus an empty search that is triggered on start.
# orders by last core file upload
if query.get('verification_status') == 'uploaded':
- #for validators, sort uploaded from oldest
+ # for validators, sort uploaded from oldest
requeststring += '+order:created'
else:
requeststring += '+order:-last_upload'
@@ -1003,21 +1017,7 @@ def build_query_common(query, props):
if props.search_verification_status != 'ALL':
query_common['verification_status'] = props.search_verification_status.lower()
- # if props.search_advanced:
- if props.search_texture_resolution:
- query["textureResolutionMax_gte"] = props.search_texture_resolution_min
- query["textureResolutionMax_lte"] = props.search_texture_resolution_max
-
- elif props.search_procedural == 'TEXTURE_BASED':
- # todo this procedural hack should be replaced with the parameter
- query["textureResolutionMax_gte"] = 0
- # query["procedural"] = False
-
- if props.search_procedural == "PROCEDURAL":
- # todo this procedural hack should be replaced with the parameter
- query["files_size_lte"] = 1024 * 1024
- # query["procedural"] = True
- elif props.search_file_size:
+ if props.search_file_size:
query_common["files_size_gte"] = props.search_file_size_min * 1024 * 1024
query_common["files_size_lte"] = props.search_file_size_max * 1024 * 1024
@@ -1051,6 +1051,9 @@ def build_query_model():
if props.search_polycount:
query["faceCount_gte"] = props.search_polycount_min
query["faceCount_lte"] = props.search_polycount_max
+ if props.search_texture_resolution:
+ query["textureResolutionMax_gte"] = props.search_texture_resolution_min
+ query["textureResolutionMax_lte"] = props.search_texture_resolution_max
build_query_common(query, props)
@@ -1087,6 +1090,20 @@ def build_query_material():
query["style"] = props.search_style
else:
query["style"] = props.search_style_other
+ if props.search_procedural == 'TEXTURE_BASED':
+ # todo this procedural hack should be replaced with the parameter
+ query["textureResolutionMax_gte"] = 0
+ # query["procedural"] = False
+ if props.search_texture_resolution:
+ query["textureResolutionMax_gte"] = props.search_texture_resolution_min
+ query["textureResolutionMax_lte"] = props.search_texture_resolution_max
+
+
+
+ elif props.search_procedural == "PROCEDURAL":
+ # todo this procedural hack should be replaced with the parameter
+ query["files_size_lte"] = 1024 * 1024
+ # query["procedural"] = True
build_query_common(query, props)
@@ -1165,33 +1182,34 @@ def search(category='', get_next=False, author_id=''):
search_start_time = time.time()
# mt('start')
scene = bpy.context.scene
- uiprops = scene.blenderkitUI
+ ui_props = scene.blenderkitUI
- if uiprops.asset_type == 'MODEL':
+ if ui_props.asset_type == 'MODEL':
if not hasattr(scene, 'blenderkit'):
return;
props = scene.blenderkit_models
query = build_query_model()
- if uiprops.asset_type == 'SCENE':
+ if ui_props.asset_type == 'SCENE':
if not hasattr(scene, 'blenderkit_scene'):
return;
props = scene.blenderkit_scene
query = build_query_scene()
-
- if uiprops.asset_type == 'MATERIAL':
+ if ui_props.asset_type == 'MATERIAL':
if not hasattr(scene, 'blenderkit_mat'):
return;
+
props = scene.blenderkit_mat
query = build_query_material()
+ utils.p(query)
- if uiprops.asset_type == 'TEXTURE':
+ if ui_props.asset_type == 'TEXTURE':
if not hasattr(scene, 'blenderkit_tex'):
return;
# props = scene.blenderkit_tex
# query = build_query_texture()
- if uiprops.asset_type == 'BRUSH':
+ if ui_props.asset_type == 'BRUSH':
if not hasattr(scene, 'blenderkit_brush'):
return;
props = scene.blenderkit_brush
diff --git a/blenderkit/ui_panels.py b/blenderkit/ui_panels.py
index 9ac11c54..4efe732f 100644
--- a/blenderkit/ui_panels.py
+++ b/blenderkit/ui_panels.py
@@ -684,7 +684,7 @@ class VIEW3D_PT_blenderkit_advanced_model_search(Panel):
row.prop(props, "search_texture_resolution_max", text='max')
# FILE SIZE
- layout.prop(props, "search_file_size", text='File size ( min - max )')
+ layout.prop(props, "search_file_size", text='File size ( min - max MB)')
if props.search_file_size:
row = layout.row(align=True)
row.prop(props, "search_file_size_min", text='min')
@@ -712,7 +712,7 @@ class VIEW3D_PT_blenderkit_advanced_material_search(Panel):
def draw(self, context):
s = context.scene
- props = s.blenderkit_models
+ props = s.blenderkit_mat
layout = self.layout
layout.separator()
@@ -729,7 +729,7 @@ class VIEW3D_PT_blenderkit_advanced_material_search(Panel):
row.prop(props, "search_texture_resolution_max", text='max')
# FILE SIZE
- layout.prop(props, "search_file_size", text='File size ( min - max in mb)')
+ layout.prop(props, "search_file_size", text='File size ( min - max MB)')
if props.search_file_size:
row = layout.row(align=True)
row.prop(props, "search_file_size_min", text='min')
@@ -769,6 +769,8 @@ class VIEW3D_PT_blenderkit_import_settings(Panel):
return ui_props.down_up == 'SEARCH' and ui_props.asset_type in ['MATERIAL', 'MODEL']
def draw(self, context):
+ layout = self.layout
+
s = context.scene
ui_props = s.blenderkitUI
@@ -776,7 +778,6 @@ class VIEW3D_PT_blenderkit_import_settings(Panel):
if ui_props.asset_type == 'MODEL':
# noinspection PyCallByClass
props = s.blenderkit_models
- layout = self.layout
layout.label(text='Import method:')
row = layout.row()
row.prop(props, 'append_method', expand=True, icon_only=False)
@@ -822,7 +823,7 @@ class VIEW3D_PT_blenderkit_unified(Panel):
row.scale_x = 1.6
row.scale_y = 1.6
# split = row.split(factor=.5)
- row.prop(ui_props, 'asset_type', expand=True, icon_only=True)
+ row.prop(ui_props, 'asset_type', expand=True, icon_only=False)
# row = layout.column(align = False)
# layout.prop(ui_props, 'asset_type', expand=False, text='')
@@ -1220,6 +1221,7 @@ classess = (
VIEW3D_PT_blenderkit_login,
VIEW3D_PT_blenderkit_unified,
VIEW3D_PT_blenderkit_advanced_model_search,
+ VIEW3D_PT_blenderkit_advanced_material_search,
VIEW3D_PT_blenderkit_categories,
VIEW3D_PT_blenderkit_import_settings,
VIEW3D_PT_blenderkit_model_properties,