[Bf-extensions-cvs] [c6453b98] master: BlenderKit: fix search filters
Vilém Duha
noreply at git.blender.org
Wed Jul 1 16:13:04 CEST 2020
Commit: c6453b9803f2f945ff85a9549b80cad8c1f9600f
Author: Vilém Duha
Date: Wed Jul 1 16:11:32 2020 +0200
Branches: master
https://developer.blender.org/rBAc6453b9803f2f945ff85a9549b80cad8c1f9600f
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
===================================================================
M blenderkit/__init__.py
M blenderkit/paths.py
M blenderkit/search.py
M blenderkit/ui_panels.py
===================================================================
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
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list