Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
return;
props = scene.blenderkit_scene
query = build_query_scene()
if uiprops.asset_type == 'MATERIAL':
if not hasattr(scene, 'blenderkit_mat'):
return;
props = scene.blenderkit_mat
query = build_query_material()
if uiprops.asset_type == 'TEXTURE':
if not hasattr(scene, 'blenderkit_tex'):
return;
# props = scene.blenderkit_tex
# query = build_query_texture()
if uiprops.asset_type == 'BRUSH':
if not hasattr(scene, 'blenderkit_brush'):
return;
props = scene.blenderkit_brush
query = build_query_brush()
if props.is_searching and get_next == True:
return;
query['own'] = own
if category != '':
query['category'] = category
props.is_searching = True
params = {
'scene_uuid': bpy.context.scene.get('uuid', None),
'addon_version': version_checker.get_addon_version(),
'get_next': get_next
}
if free_only:
query['keywords'] += '+is_free:true'
add_search_process(query, params)
props.report = 'BlenderKit searching....'
def search_update(self, context):
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
if self.search_keywords != '':
search()
class SearchOperator(Operator):
"""Tooltip"""
bl_idname = "view3d.blenderkit_search"
bl_label = "BlenderKit asset search"
own: BoolProperty(name="own assets only",
description="Find all own assets",
default=False)
category: StringProperty(
name="category",
description="search only subtree of this category",
default="")
get_next: BoolProperty(name="next page",
description="get next page from previous search",
default=False)
@classmethod
def poll(cls, context):
return True
def execute(self, context):
search(own=self.own, category=self.category, get_next=self.get_next)
bpy.ops.view3d.blenderkit_asset_bar()
return {'FINISHED'}
classes = [
SearchOperator
]
def register_search():
bpy.app.handlers.load_post.append(scene_load)
for c in classes:
bpy.utils.register_class(c)
# bpy.app.timers.register(timer_update, persistent = True)
utils.load_categories()
def unregister_search():
bpy.app.handlers.load_post.remove(scene_load)
for c in classes:
bpy.utils.unregister_class(c)
# bpy.app.timers.unregister(timer_update)
'''
search -
build query
START THREAD
send query (bg allready)
get result - metadata, small thumbnails, big thumbnails paths (now genereate this?)
write metadata, possibly to
download small thumbnails first
start big thumbnails download. these don't have to be there on updates, if they aren't the Image in image editor doesn't get updated.
parse metadata, save it in json in the temp dir which gets read on each update of the search.
END THREAD
when download is triggered, get also this metadata from json. E
pass this single - item metadata in the download functions, threads.
'''