GPencil Tools: Fix T90976 Timeline-scrub toggle
[blender-addons.git] / blenderkit / __init__.py
blobd22f383b7a8abff7efeabb24e27a51a3f12f0831
1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
19 bl_info = {
20 "name": "BlenderKit Online Asset Library",
21 "author": "Vilem Duha, Petr Dlouhy",
22 "version": (3, 0, 0),
23 "blender": (2, 93, 0),
24 "location": "View3D > Properties > BlenderKit",
25 "description": "Online BlenderKit library (materials, models, brushes and more). Connects to the internet.",
26 "warning": "",
27 "doc_url": "{BLENDER_MANUAL_URL}/addons/3d_view/blenderkit.html",
28 "category": "3D View",
31 if "bpy" in locals():
32 from importlib import reload
34 # alphabetically sorted all add-on modules since reload only happens from __init__.
35 # modules with _bg are used for background computations in separate blender instance and that's why they don't need reload.
37 append_link = reload(append_link)
38 asset_bar_op = reload(asset_bar_op)
39 asset_inspector = reload(asset_inspector)
40 autothumb = reload(autothumb)
41 bg_blender = reload(bg_blender)
42 bkit_oauth = reload(bkit_oauth)
43 categories = reload(categories)
44 colors = reload(colors)
45 download = reload(download)
46 icons = reload(icons)
47 image_utils = reload(image_utils)
48 oauth = reload(oauth)
49 overrides = reload(overrides)
50 paths = reload(paths)
51 ratings = reload(ratings)
52 ratings_utils = reload(ratings_utils)
53 resolutions = reload(resolutions)
54 search = reload(search)
55 tasks_queue = reload(tasks_queue)
56 ui = reload(ui)
57 ui_bgl = reload(ui_bgl)
58 ui_panels = reload(ui_panels)
59 upload = reload(upload)
60 upload_bg = reload(upload_bg)
61 utils = reload(utils)
63 bl_ui_label = reload(bl_ui_label)
64 bl_ui_button = reload(bl_ui_button)
65 # bl_ui_checkbox = reload(bl_ui_checkbox)
66 # bl_ui_slider = reload(bl_ui_slider)
67 # bl_ui_up_down = reload(bl_ui_up_down)
68 bl_ui_drag_panel = reload(bl_ui_drag_panel)
69 bl_ui_draw_op = reload(bl_ui_draw_op)
70 # bl_ui_textbox = reload(bl_ui_textbox)
72 else:
73 from blenderkit import append_link
74 from blenderkit import asset_bar_op
75 from blenderkit import asset_inspector
76 from blenderkit import autothumb
77 from blenderkit import bg_blender
78 from blenderkit import bkit_oauth
79 from blenderkit import categories
80 from blenderkit import colors
81 from blenderkit import download
82 from blenderkit import icons
83 from blenderkit import image_utils
84 from blenderkit import oauth
85 from blenderkit import overrides
86 from blenderkit import paths
87 from blenderkit import ratings
88 from blenderkit import ratings_utils
89 from blenderkit import resolutions
90 from blenderkit import search
91 from blenderkit import tasks_queue
92 from blenderkit import ui
93 from blenderkit import ui_bgl
94 from blenderkit import ui_panels
95 from blenderkit import upload
96 from blenderkit import upload_bg
97 from blenderkit import utils
99 from blenderkit.bl_ui_widgets import bl_ui_label
100 from blenderkit.bl_ui_widgets import bl_ui_button
101 # from blenderkit.bl_ui_widgets import bl_ui_checkbox
102 # from blenderkit.bl_ui_widgets import bl_ui_slider
103 # from blenderkit.bl_ui_widgets import bl_ui_up_down
104 from blenderkit.bl_ui_widgets import bl_ui_drag_panel
105 from blenderkit.bl_ui_widgets import bl_ui_draw_op
106 # from blenderkit.bl_ui_widgets import bl_ui_textbox
108 import os
109 import math
110 import time
111 import logging
112 import bpy
113 import pathlib
115 log = logging.getLogger(__name__)
117 from bpy.app.handlers import persistent
118 import bpy.utils.previews
119 import mathutils
120 from mathutils import Vector
121 from bpy.props import (
122 IntProperty,
123 FloatProperty,
124 FloatVectorProperty,
125 StringProperty,
126 EnumProperty,
127 BoolProperty,
128 PointerProperty,
130 from bpy.types import (
131 Operator,
132 Panel,
133 AddonPreferences,
134 PropertyGroup,
138 # logging.basicConfig(filename = 'blenderkit.log', level = logging.INFO,
139 # format = ' %(asctime)s:%(filename)s:%(funcName)s:%(lineno)d:%(message)s')
142 @persistent
143 def scene_load(context):
144 ui_props = bpy.context.scene.blenderkitUI
145 ui_props.assetbar_on = False
146 ui_props.turn_off = False
147 preferences = bpy.context.preferences.addons['blenderkit'].preferences
148 preferences.login_attempt = False
151 @bpy.app.handlers.persistent
152 def check_timers_timer():
153 ''' checks if all timers are registered regularly. Prevents possible bugs from stopping the addon.'''
154 if not bpy.app.timers.is_registered(search.search_timer):
155 bpy.app.timers.register(search.search_timer)
156 if not bpy.app.timers.is_registered(download.download_timer):
157 bpy.app.timers.register(download.download_timer)
158 if not (bpy.app.timers.is_registered(tasks_queue.queue_worker)):
159 bpy.app.timers.register(tasks_queue.queue_worker)
160 if not bpy.app.timers.is_registered(bg_blender.bg_update):
161 bpy.app.timers.register(bg_blender.bg_update)
162 return 5.0
165 conditions = (
166 ('UNSPECIFIED', 'Unspecified', ""),
167 ('NEW', 'New', 'Shiny new item'),
168 ('USED', 'Used', 'Casually used item'),
169 ('OLD', 'Old', 'Old item'),
170 ('DESOLATE', 'Desolate', 'Desolate item - dusty & rusty'),
172 model_styles = (
173 ('REALISTIC', 'Realistic', "Photo realistic model"),
174 ('PAINTERLY', 'Painterly', 'Hand painted with visible strokes'),
175 ('LOWPOLY', 'Lowpoly', "Lowpoly art -don't mix up with polycount!"),
176 ('ANIME', 'Anime', 'Anime style'),
177 ('2D_VECTOR', '2D Vector', '2D vector'),
178 ('3D_GRAPHICS', '3D Graphics', '3D graphics'),
179 ('OTHER', 'Other', 'Other styles'),
181 search_model_styles = (
182 ('REALISTIC', 'Realistic', "Photo realistic model"),
183 ('PAINTERLY', 'Painterly', 'Hand painted with visible strokes'),
184 ('LOWPOLY', 'Lowpoly', "Lowpoly art -don't mix up with polycount!"),
185 ('ANIME', 'Anime', 'Anime style'),
186 ('2D_VECTOR', '2D Vector', '2D vector'),
187 ('3D_GRAPHICS', '3D Graphics', '3D graphics'),
188 ('OTHER', 'Other', 'Other Style'),
189 ('ANY', 'Any', 'Any Style'),
191 material_styles = (
192 ('REALISTIC', 'Realistic', "Photo realistic model"),
193 ('NPR', 'Non photorealistic', 'Hand painted with visible strokes'),
194 ('OTHER', 'Other', 'Other style'),
196 search_material_styles = (
197 ('REALISTIC', 'Realistic', "Photo realistic model"),
198 ('NPR', 'Non photorealistic', 'Hand painted with visible strokes'),
199 ('ANY', 'Any', 'Any'),
201 engines = (
202 ('CYCLES', 'Cycles', 'Blender Cycles'),
203 ('EEVEE', 'Eevee', 'Blender eevee renderer'),
204 ('OCTANE', 'Octane', 'Octane render enginge'),
205 ('ARNOLD', 'Arnold', 'Arnold render engine'),
206 ('V-RAY', 'V-Ray', 'V-Ray renderer'),
207 ('UNREAL', 'Unreal', 'Unreal engine'),
208 ('UNITY', 'Unity', 'Unity engine'),
209 ('GODOT', 'Godot', 'Godot engine'),
210 ('3D-PRINT', '3D printer', 'object can be 3D printed'),
211 ('OTHER', 'Other', 'any other engine'),
212 ('NONE', 'None', 'no more engine block'),
214 pbr_types = (
215 ('METALLIC', 'Metallic-Roughness', 'Metallic/Roughness PBR material type'),
216 ('SPECULAR', 'Specular Glossy', ''),
219 mesh_poly_types = (
220 ('QUAD', 'quad', ''),
221 ('QUAD_DOMINANT', 'quad_dominant', ''),
222 ('TRI_DOMINANT', 'tri_dominant', ''),
223 ('TRI', 'tri', ''),
224 ('NGON', 'ngon_dominant', ''),
225 ('OTHER', 'other', ''),
234 def udate_down_up(self, context):
235 """Perform a search if results are empty."""
236 s = context.scene
237 wm = bpy.context.window_manager
238 props = s.blenderkitUI
239 if wm.get('search results') == None and props.down_up == 'SEARCH':
240 search.search()
243 def switch_search_results(self, context):
244 s = bpy.context.scene
245 wm = bpy.context.window_manager
246 props = s.blenderkitUI
247 if props.asset_type == 'MODEL':
248 wm['search results'] = wm.get('bkit model search')
249 wm['search results orig'] = wm.get('bkit model search orig')
250 elif props.asset_type == 'SCENE':
251 wm['search results'] = wm.get('bkit scene search')
252 wm['search results orig'] = wm.get('bkit scene search orig')
253 elif props.asset_type == 'HDR':
254 wm['search results'] = wm.get('bkit hdr search')
255 wm['search results orig'] = wm.get('bkit hdr search orig')
256 elif props.asset_type == 'MATERIAL':
257 wm['search results'] = wm.get('bkit material search')
258 wm['search results orig'] = wm.get('bkit material search orig')
259 elif props.asset_type == 'TEXTURE':
260 wm['search results'] = wm.get('bkit texture search')
261 wm['search results orig'] = wm.get('bkit texture search orig')
262 elif props.asset_type == 'BRUSH':
263 wm['search results'] = wm.get('bkit brush search')
264 wm['search results orig'] = wm.get('bkit brush search orig')
265 if not (context.sculpt_object or context.image_paint_object):
266 ui.add_report(
267 'Switch to paint or sculpt mode to search in BlenderKit brushes.')
269 search.load_previews()
270 if wm['search results'] == None and props.down_up == 'SEARCH':
271 search.search()
274 def asset_type_callback(self, context):
276 Returns
277 items for Enum property, depending on the down_up property - BlenderKit is either in search or in upload mode.
280 user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
282 if self.down_up == 'SEARCH':
283 items = (
284 ('MODEL', 'Models', 'Find models', 'OBJECT_DATAMODE', 0),
285 ('MATERIAL', 'Materials', 'Find materials', 'MATERIAL', 2),
286 # ('TEXTURE', 'Texture', 'Browse textures', 'TEXTURE', 3),
287 ('SCENE', 'Scenes', 'Find scenes', 'SCENE_DATA', 3),
288 ('HDR', 'HDRs', 'Find HDRs', 'WORLD', 4),
289 ('BRUSH', 'Brushes', 'Find brushes', 'BRUSH_DATA', 5)
291 else:
292 items = (
293 ('MODEL', 'Model', 'Upload a model', 'OBJECT_DATAMODE', 0),
294 # ('SCENE', 'SCENE', 'Browse scenes', 'SCENE_DATA', 1),
295 ('MATERIAL', 'Material', 'Upload a material', 'MATERIAL', 2),
296 # ('TEXTURE', 'Texture', 'Browse textures', 'TEXTURE', 3),
297 ('SCENE', 'Scene', 'Upload a scene', 'SCENE_DATA', 3),
298 ('HDR', 'HDR', 'Upload a HDR', 'WORLD', 4),
299 ('BRUSH', 'Brush', 'Upload a brush', 'BRUSH_DATA', 5)
302 return items
305 def run_drag_drop_update(self, context):
306 if self.drag_init_button:
307 ui_props = bpy.context.scene.blenderkitUI
308 # ctx = utils.get_fake_context(bpy.context)
310 bpy.ops.view3d.close_popup_button('INVOKE_DEFAULT')
311 bpy.ops.view3d.asset_drag_drop('INVOKE_DEFAULT', asset_search_index=ui_props.active_index + ui_props.scrolloffset)
313 self.drag_init_button = False
316 class BlenderKitUIProps(PropertyGroup):
318 down_up: EnumProperty(
319 name="Download vs Upload",
320 items=(
321 ('SEARCH', 'Search', 'Activate searching', 'VIEWZOOM', 0),
322 ('UPLOAD', 'Upload', 'Activate uploading', 'COPYDOWN', 1),
323 # ('RATING', 'Rating', 'Activate rating', 'SOLO_ON', 2)
325 description="BlenderKit",
326 default="SEARCH",
327 update=udate_down_up
329 asset_type: EnumProperty(
330 name=" ",
331 items=asset_type_callback,
332 description="",
333 default=None,
334 update=switch_search_results
337 asset_type_fold: BoolProperty(name="Expand asset types", default=False)
338 # these aren't actually used ( by now, seems to better use globals in UI module:
339 draw_tooltip: BoolProperty(name="Draw Tooltip", default=False)
340 addon_update: BoolProperty(name="Should Update Addon", default=False)
341 tooltip: StringProperty(
342 name="Tooltip",
343 description="asset preview info",
344 default="")
346 ui_scale = 1
348 thumb_size_def = 96
349 margin_def = 0
351 thumb_size: IntProperty(name="Thumbnail Size", default=thumb_size_def, min=-1, max=256)
353 margin: IntProperty(name="Margin", default=margin_def, min=-1, max=256)
354 highlight_margin: IntProperty(name="Highlight Margin", default=int(margin_def / 2), min=-10, max=256)
356 bar_height: IntProperty(name="Bar Height", default=thumb_size_def + 2 * margin_def, min=-1, max=2048)
357 bar_x_offset: IntProperty(name="Bar X Offset", default=20, min=0, max=5000)
358 bar_y_offset: IntProperty(name="Bar Y Offset", default=80, min=0, max=5000)
360 bar_x: IntProperty(name="Bar X", default=100, min=0, max=5000)
361 bar_y: IntProperty(name="Bar Y", default=100, min=50, max=5000)
362 bar_end: IntProperty(name="Bar End", default=100, min=0, max=5000)
363 bar_width: IntProperty(name="Bar Width", default=100, min=0, max=5000)
365 wcount: IntProperty(name="Width Count", default=10, min=0, max=5000)
366 hcount: IntProperty(name="Rows", default=5, min=0, max=5000)
368 reports_y: IntProperty(name="Reports Y", default=5, min=0, max=5000)
369 reports_x: IntProperty(name="Reports X", default=5, min=0, max=5000)
371 assetbar_on: BoolProperty(name="Assetbar On", default=False)
372 turn_off: BoolProperty(name="Turn Off", default=False)
374 mouse_x: IntProperty(name="Mouse X", default=0)
375 mouse_y: IntProperty(name="Mouse Y", default=0)
377 active_index: IntProperty(name="Active Index", default=-3)
378 scrolloffset: IntProperty(name="Scroll Offset", default=0)
379 drawoffset: IntProperty(name="Draw Offset", default=0)
381 dragging: BoolProperty(name="Dragging", default=False)
382 drag_init: BoolProperty(name="Drag Initialisation", default=False)
383 drag_init_button: BoolProperty(name="Drag Initialisation from button",
384 default=False,
385 description="Click or drag into scene for download",
386 update = run_drag_drop_update)
387 drag_length: IntProperty(name="Drag length", default=0)
388 draw_drag_image: BoolProperty(name="Draw Drag Image", default=False)
389 draw_snapped_bounds: BoolProperty(name="Draw Snapped Bounds", default=False)
391 snapped_location: FloatVectorProperty(name="Snapped Location", default=(0, 0, 0))
392 snapped_bbox_min: FloatVectorProperty(name="Snapped Bbox Min", default=(0, 0, 0))
393 snapped_bbox_max: FloatVectorProperty(name="Snapped Bbox Max", default=(0, 0, 0))
394 snapped_normal: FloatVectorProperty(name="Snapped Normal", default=(0, 0, 0))
396 snapped_rotation: FloatVectorProperty(name="Snapped Rotation", default=(0, 0, 0), subtype='QUATERNION')
398 has_hit: BoolProperty(name="has_hit", default=False)
399 thumbnail_image = StringProperty(
400 name="Thumbnail Image",
401 description="",
402 default=paths.get_addon_thumbnail_path('thumbnail_notready.jpg'))
404 #### rating UI props
405 rating_ui_scale = ui_scale
407 rating_button_on: BoolProperty(name="Rating Button On", default=True)
408 rating_menu_on: BoolProperty(name="Rating Menu On", default=False)
409 rating_on: BoolProperty(name="Rating on", default=True)
411 rating_button_width: IntProperty(name="Rating Button Width", default=50 * ui_scale)
412 rating_button_height: IntProperty(name="Rating Button Height", default=50 * ui_scale)
414 rating_x: IntProperty(name="Rating UI X", default=10)
415 rating_y: IntProperty(name="Rating UI Y", default=10)
417 rating_ui_width: IntProperty(name="Rating UI Width", default=rating_ui_scale * 600)
418 rating_ui_height: IntProperty(name="Rating UI Heightt", default=rating_ui_scale * 256)
420 quality_stars_x: IntProperty(name="Rating UI Stars X", default=rating_ui_scale * 90)
421 quality_stars_y: IntProperty(name="Rating UI Stars Y", default=rating_ui_scale * 190)
423 star_size: IntProperty(name="Star Size", default=rating_ui_scale * 50)
425 workhours_bar_slider_size: IntProperty(name="Workhours Bar Slider Size", default=rating_ui_scale * 30)
427 workhours_bar_x: IntProperty(name="Workhours Bar X", default=rating_ui_scale * (100 - 15))
428 workhours_bar_y: IntProperty(name="Workhours Bar Y", default=rating_ui_scale * (45 - 15))
430 workhours_bar_x_max: IntProperty(name="Workhours Bar X Max", default=rating_ui_scale * (480 - 15))
432 dragging_rating: BoolProperty(name="Dragging Rating", default=False)
433 dragging_rating_quality: BoolProperty(name="Dragging Rating Quality", default=False)
434 dragging_rating_work_hours: BoolProperty(name="Dragging Rating Work Hours", default=False)
435 last_rating_time: FloatProperty(name="Last Rating Time", default=0.0)
437 hdr_upload_image: PointerProperty(name='Upload HDR',
438 type=bpy.types.Image,
439 description='Pick an image to upload')
441 # StringProperty(
442 # name="Upload HDR",
443 # description="Active HDR image to upload",
444 # default="")
447 def search_procedural_update(self, context):
448 if self.search_procedural in ('PROCEDURAL', 'BOTH'):
449 self.search_texture_resolution = False
450 search.search_update(self, context)
453 class BlenderKitCommonSearchProps(object):
454 # STATES
455 is_searching: BoolProperty(name="Searching", description="search is currently running (internal)", default=False)
456 is_downloading: BoolProperty(name="Downloading", description="download is currently running (internal)",
457 default=False)
458 search_done: BoolProperty(name="Search Completed", description="at least one search did run (internal)",
459 default=False)
460 own_only: BoolProperty(name="My Assets Only", description="Search only for your assets",
461 default=False, update=search.search_update)
462 use_filters: BoolProperty(name="Filters are on", description="some filters are used",
463 default=False)
465 search_error: BoolProperty(name="Search Error", description="last search had an error", default=False)
466 report: StringProperty(
467 name="Report",
468 description="errors and messages",
469 default="")
471 # TEXTURE RESOLUTION
472 search_texture_resolution: BoolProperty(name="Texture Resolution",
473 description="Limit texture resolutions",
474 default=False,
475 update=search.search_update,
477 search_texture_resolution_min: IntProperty(name="Min Texture Resolution",
478 description="Minimum texture resolution",
479 default=256,
480 min=0,
481 max=32768,
482 update=search.search_update,
485 search_texture_resolution_max: IntProperty(name="Max Texture Resolution",
486 description="Maximum texture resolution",
487 default=4096,
488 min=0,
489 max=32768,
490 update=search.search_update,
493 # file_size
494 search_file_size: BoolProperty(name="File Size",
495 description="Limit file sizes",
496 default=False,
497 update=search.search_update,
499 search_file_size_min: IntProperty(name="Min File Size",
500 description="Minimum file size",
501 default=0,
502 min=0,
503 max=2000,
504 update=search.search_update,
507 search_file_size_max: IntProperty(name="Max File Size",
508 description="Maximum file size",
509 default=500,
510 min=0,
511 max=2000,
512 update=search.search_update,
515 search_procedural: EnumProperty(
516 items=(
517 ('BOTH', 'Both', ''),
518 ('PROCEDURAL', 'Procedural', ''),
519 ('TEXTURE_BASED', 'Texture based', ''),
522 default='BOTH',
523 description='Search only procedural/texture based assets',
524 update=search_procedural_update
527 search_verification_status: EnumProperty(
528 name="Verification status",
529 description="Search by verification status",
530 items=
532 ('ALL', 'All', 'All'),
533 ('UPLOADING', 'Uploading', 'Uploading'),
534 ('UPLOADED', 'Uploaded', 'Uploaded'),
535 ('READY', 'Ready for V.', 'Ready for validation (deprecated since 2.8)'),
536 ('VALIDATED', 'Validated', 'Validated'),
537 ('ON_HOLD', 'On Hold', 'On Hold'),
538 ('REJECTED', 'Rejected', 'Rejected'),
539 ('DELETED', 'Deleted', 'Deleted'),
541 default='ALL',
542 update=search.search_update,
545 # resolution download/import settings
546 resolution: EnumProperty(
547 name="Max resolution",
548 description="Cap texture sizes in the file to this resolution",
549 items=
551 # ('256', '256x256', ''),
552 ('512', '512x512', ''),
553 ('1024', '1024x1024', ''),
554 ('2048', '2048x2048', ''),
555 ('4096', '4096x4096', ''),
556 ('8192', '8192x8192', ''),
557 ('ORIGINAL', 'ORIGINAL FILE', ''),
560 default='1024',
562 free_only: BoolProperty(name="Free first", description="Show free models first",
563 default=False, update=search.search_update)
565 unpack_files: BoolProperty(name="Unpack Files",
566 description="Unpack files after download",
567 default=True
570 unrated_only: BoolProperty(name="Unrated only", description="Show only unrated models",
571 default=False, update=search.search_update)
572 quality_limit: IntProperty(name="Quality limit",
573 description = 'Only show assets with a higher quality',
574 default=0, min=0, max=10, update=search.search_update)
578 def name_update(self, context):
579 ''' checks for name change, because it decides if whole asset has to be re-uploaded. Name is stored in the blend file
580 and that's the reason.'''
581 utils.name_update(self)
584 def update_free(self, context):
585 if self.is_free == 'FULL':
586 self.is_free = 'FREE'
587 ui_panels.ui_message(title="All BlenderKit materials are free",
588 message="Any material uploaded to BlenderKit is free." \
589 " However, it can still earn money for the author," \
590 " based on our fair share system. " \
591 "Part of subscription is sent to artists based on usage by paying users.\n")
593 # common_upload_props = [
595 # 'identifier':'id',
596 # 'name':"Asset Version Id",
597 # 'type':'StringProperty',
598 # 'description':'Unique name of the asset version(hidden)',
599 # 'default':''
602 # 'identifier':'id',
603 # 'name':"Asset Version Id",
604 # 'type':'StringProperty',
605 # 'description':'Unique name of the asset version(hidden)',
606 # 'default':''
613 class BlenderKitCommonUploadProps(object):
614 # for p in common_upload_props:
615 # exec(f"{p['identifier']}: {p['type']}(name='{p['name']}',description='{p['description']}',default='{p['default']}')")
617 id: StringProperty(
618 name="Asset Version Id",
619 description="Unique name of the asset version(hidden)",
620 default="")
621 asset_base_id: StringProperty(
622 name="Asset Base Id",
623 description="Unique name of the asset (hidden)",
624 default="")
625 name: StringProperty(
626 name="Name",
627 description="Main name of the asset",
628 default="",
629 update=name_update
631 # this is to store name for purpose of checking if name has changed.
632 name_old: StringProperty(
633 name="Old Name",
634 description="Old name of the asset",
635 default="",
638 description: StringProperty(
639 name="Description",
640 description="Description of the asset",
641 default="")
642 tags: StringProperty(
643 name="Tags",
644 description="List of tags, separated by commas (optional)",
645 default="",
646 update=utils.update_tags
649 name_changed: BoolProperty(name="Name Changed",
650 description="Name has changed, the asset has to be re-uploaded with all data",
651 default=False)
653 pbr: BoolProperty(name="Pure PBR Compatible",
654 description="Is compatible with PBR standard. This means only image textures are used with no"
655 " procedurals and no color correction, only principled shader is used",
656 default=False)
658 pbr_type: EnumProperty(
659 name="PBR Type",
660 items=pbr_types,
661 description="PBR type",
662 default="METALLIC",
664 license: EnumProperty(
665 items=upload.licenses,
666 default='royalty_free',
667 description='License. Please read our help for choosing the right licenses',
670 is_private: EnumProperty(
671 name="Thumbnail Style",
672 items=(
673 ('PRIVATE', 'Private', ""),
674 ('PUBLIC', 'Public', "")
676 description="Public assets go into the validation process. \n"
677 "Validated assets are visible to all users.\n"
678 "Private assets are limited by your plan quota\n"
679 "State",
680 default="PUBLIC",
683 is_procedural: BoolProperty(name="Procedural",
684 description="Asset is procedural - has no texture",
685 default=True
687 node_count: IntProperty(name="Node count", description="Total nodes in the asset", default=0)
688 texture_count: IntProperty(name="Texture count", description="Total texture count in asset", default=0)
689 total_megapixels: IntProperty(name="Megapixels", description="Total megapixels of texture", default=0)
691 # is_private: BoolProperty(name="Asset is Private",
692 # description="If not marked private, your asset will go into the validation process automatically\n"
693 # "Private assets are limited by quota",
694 # default=False)
696 is_free: EnumProperty(
697 name="Thumbnail Style",
698 items=(
699 ('FULL', 'Full', "Your asset will be only available for subscribers"),
700 ('FREE', 'Free', "You consent you want to release this asset as free for everyone")
702 description="Assets can be in Free or in Full plan. Also free assets generate credits",
703 default="FULL",
706 uploading: BoolProperty(name="Uploading",
707 description="True when background process is running",
708 default=False,
709 update=autothumb.update_upload_material_preview)
710 upload_state: StringProperty(
711 name="State Of Upload",
712 description="bg process reports for upload",
713 default='')
715 has_thumbnail: BoolProperty(name="Has Thumbnail", description="True when thumbnail was checked and loaded",
716 default=False)
718 thumbnail_generating_state: StringProperty(
719 name="Thumbnail Generating State",
720 description="bg process reports for thumbnail generation",
721 default='Please add thumbnail(jpg or png, at least 512x512)')
723 report: StringProperty(
724 name="Missing Upload Properties",
725 description="used to write down what's missing",
726 default='')
728 category: EnumProperty(
729 name="Category",
730 description="main category to put into",
731 items=categories.get_category_enums,
732 update=categories.update_category_enums
734 subcategory: EnumProperty(
735 name="Subcategory",
736 description="Subcategory to put into",
737 items=categories.get_subcategory_enums,
738 update=categories.update_subcategory_enums
740 subcategory1: EnumProperty(
741 name="Subcategory lvl2",
742 description="Subcategory to put into",
743 items=categories.get_subcategory1_enums
747 class BlenderKitRatingProps(PropertyGroup):
748 rating_quality: IntProperty(name="Quality",
749 description="quality of the material",
750 default=0,
751 min=-1, max=10,
752 update=ratings_utils.update_ratings_quality)
754 # the following enum is only to ease interaction - enums support 'drag over' and enable to draw the stars easily.
755 rating_quality_ui: EnumProperty(name='rating_quality_ui',
756 items=ratings_utils.stars_enum_callback,
757 description='Rating stars 0 - 10',
758 default=None,
759 update=ratings_utils.update_quality_ui,
762 rating_work_hours: FloatProperty(name="Work Hours",
763 description="How many hours did this work take?",
764 default=0.00,
765 min=0.0, max=150, update=ratings_utils.update_ratings_work_hours
768 # rating_complexity: IntProperty(name="Complexity",
769 # description="Complexity is a number estimating how much work was spent on the asset.aaa",
770 # default=0, min=0, max=10)
771 # rating_virtual_price: FloatProperty(name="Virtual Price",
772 # description="How much would you pay for this object if buing it?",
773 # default=0, min=0, max=10000)
774 rating_problems: StringProperty(
775 name="Problems",
776 description="Problems found/ why did you take points down - this will be available for the author"
777 " As short as possible",
778 default="",
780 rating_compliments: StringProperty(
781 name="Compliments",
782 description="Comliments - let the author know you like his work! "
783 " As short as possible",
784 default="",
788 class BlenderKitMaterialSearchProps(PropertyGroup, BlenderKitCommonSearchProps):
789 search_keywords: StringProperty(
790 name="Search",
791 description="Search for these keywords",
792 default="",
793 update=search.search_update
795 search_style: EnumProperty(
796 name="Style",
797 items=search_material_styles,
798 description="Style of material",
799 default="ANY",
800 update=search.search_update,
802 search_style_other: StringProperty(
803 name="Style Other",
804 description="Style not in the list",
805 default="",
806 update=search.search_update,
808 search_engine: EnumProperty(
809 name='Engine',
810 items=engines,
811 default='NONE',
812 description='Output engine',
813 update=search.search_update,
815 search_engine_other: StringProperty(
816 name="Engine",
817 description="engine not specified by addon",
818 default="",
819 update=search.search_update,
821 append_method: EnumProperty(
822 name="Import Method",
823 items=(
824 ('LINK', 'Link', "Link Material - will be in external file and can't be directly edited"),
825 ('APPEND', 'Append', 'Append if you need to edit the material'),
827 description="Appended materials are editable in your scene. Linked assets are saved in original files, "
828 "aren't editable directly, but also don't increase your file size",
829 default="APPEND"
831 automap: BoolProperty(name="Auto-Map",
832 description="reset object texture space and also add automatically a cube mapped UV "
833 "to the object. \n this allows most materials to apply instantly to any mesh",
834 default=True)
837 class BlenderKitMaterialUploadProps(PropertyGroup, BlenderKitCommonUploadProps):
838 style: EnumProperty(
839 name="Style",
840 items=material_styles,
841 description="Style of material",
842 default="REALISTIC",
844 style_other: StringProperty(
845 name="Style Other",
846 description="Style not in the list",
847 default="",
849 engine: EnumProperty(
850 name='Engine',
851 items=engines,
852 default='CYCLES',
853 description='Output engine',
855 engine_other: StringProperty(
856 name="Engine Other",
857 description="engine not specified by addon",
858 default="",
861 shaders: StringProperty(
862 name="Shaders Used",
863 description="shaders used in asset, autofilled",
864 default="",
867 is_free: EnumProperty(
868 name="Thumbnail Style",
869 items=(
870 ('FULL', 'Full', "Your asset will be only available for subscribers."),
871 ('FREE', 'Free', "You consent you want to release this asset as free for everyone.")
873 description="Assets can be in Free or in Full plan. Also free assets generate credits. \n"
874 "All BlenderKit materials are free",
875 default="FREE",
876 update=update_free
881 uv: BoolProperty(name="Needs UV", description="needs an UV set", default=False)
882 # printable_3d : BoolProperty( name = "3d printable", description = "can be 3d printed", default = False)
883 animated: BoolProperty(name="Animated", description="is animated", default=False)
884 texture_resolution_min: IntProperty(name="Texture Resolution Min", description="texture resolution minimum",
885 default=0)
886 texture_resolution_max: IntProperty(name="Texture Resolution Max", description="texture resolution maximum",
887 default=0)
889 texture_size_meters: FloatProperty(name="Texture Size in Meters", description="Size of texture in real world units",
890 default=1.0, min=0)
892 thumbnail_scale: FloatProperty(name="Thumbnail Object Size",
893 description="Size of material preview object in meters."
894 "Change for materials that look better at sizes different than 1m",
895 default=1, min=0.00001, max=10)
896 thumbnail_background: BoolProperty(name="Thumbnail Background (for Glass only)",
897 description="For refractive materials, you might need a background.\n"
898 "Don't use for other types of materials.\n"
899 "Transparent background is preferred",
900 default=False)
901 thumbnail_background_lightness: FloatProperty(name="Thumbnail Background Lightness",
902 description="Set to make your material stand out with enough contrast",
903 default=.9,
904 min=0.00001, max=1)
905 thumbnail_samples: IntProperty(name="Cycles Samples",
906 description="Cycles samples", default=100,
907 min=5, max=5000)
908 thumbnail_denoising: BoolProperty(name="Use Denoising",
909 description="Use denoising", default=True)
910 adaptive_subdivision: BoolProperty(name="Adaptive Subdivide",
911 description="Use adaptive displacement subdivision", default=False)
913 thumbnail_resolution: EnumProperty(
914 name="Resolution",
915 items=autothumb.thumbnail_resolutions,
916 description="Thumbnail resolution",
917 default="1024",
920 thumbnail_generator_type: EnumProperty(
921 name="Thumbnail Style",
922 items=(
923 ('BALL', 'Ball', ""),
924 ('BALL_COMPLEX', 'Ball complex', 'Complex ball to highlight edgewear or material thickness'),
925 ('FLUID', 'Fluid', 'Fluid'),
926 ('CLOTH', 'Cloth', 'Cloth'),
927 ('HAIR', 'Hair', 'Hair ')
929 description="Style of asset",
930 default="BALL",
933 thumbnail: StringProperty(
934 name="Thumbnail",
935 description="Thumbnail path - 512x512 .jpg image, rendered with cycles.\n"
936 "Only standard BlenderKit previews will be accepted.\n"
937 "Only exception are special effects like fire or similar",
938 subtype='FILE_PATH',
939 default="",
940 update=autothumb.update_upload_material_preview)
942 is_generating_thumbnail: BoolProperty(name="Generating Thumbnail",
943 description="True when background process is running", default=False,
944 update=autothumb.update_upload_material_preview)
947 class BlenderKitTextureUploadProps(PropertyGroup, BlenderKitCommonUploadProps):
948 style: EnumProperty(
949 name="Style",
950 items=material_styles,
951 description="Style of texture",
952 default="REALISTIC",
954 style_other: StringProperty(
955 name="Style Other",
956 description="Style not in the list",
957 default="",
960 pbr: BoolProperty(name="PBR Compatible", description="Is compatible with PBR standard", default=False)
962 # printable_3d : BoolProperty( name = "3d printable", description = "can be 3d printed", default = False)
963 animated: BoolProperty(name="Animated", description="is animated", default=False)
964 resolution: IntProperty(name="Texture Resolution", description="texture resolution", default=0)
967 class BlenderKitBrushSearchProps(PropertyGroup, BlenderKitCommonSearchProps):
968 search_keywords: StringProperty(
969 name="Search",
970 description="Search for these keywords",
971 default="",
972 update=search.search_update
976 class BlenderKitHDRUploadProps(PropertyGroup, BlenderKitCommonUploadProps):
977 texture_resolution_max: IntProperty(name="Texture Resolution Max", description="texture resolution maximum",
978 default=0)
979 evs_cap: IntProperty(name="EV cap", description="EVs dynamic range",
980 default=0)
981 true_hdr: BoolProperty(name="Real HDR", description="Image has High dynamic range.",default=False)
984 class BlenderKitBrushUploadProps(PropertyGroup, BlenderKitCommonUploadProps):
985 mode: EnumProperty(
986 name="Mode",
987 items=(
988 ("IMAGE", "Texture paint", "Texture brush"),
989 ("SCULPT", "Sculpt", "Sculpt brush"),
990 ("VERTEX", "Vertex paint", "Vertex paint brush"),
991 ("WEIGHT", "Weight paint", "Weight paint brush"),
993 description="Mode where the brush works",
994 default="SCULPT",
998 # upload properties
999 class BlenderKitModelUploadProps(PropertyGroup, BlenderKitCommonUploadProps):
1000 style: EnumProperty(
1001 name="Style",
1002 items=model_styles,
1003 description="Style of asset",
1004 default="REALISTIC",
1006 style_other: StringProperty(
1007 name="Style Other",
1008 description="Style not in the list",
1009 default="",
1011 engine: EnumProperty(
1012 name='Engine',
1013 items=engines,
1014 default='CYCLES',
1015 description='Output engine',
1018 production_level: EnumProperty(
1019 name='Production Level',
1020 items=(
1021 ('FINISHED', 'Finished', 'Render or animation ready asset'),
1022 ('TEMPLATE', 'Template', 'Asset intended to help in creation of something else'),
1024 default='FINISHED',
1025 description='Production state of the asset. \n'
1026 'Templates should be tools to finish certain tasks, like a thumbnailer scene, \n '
1027 'finished mesh topology as start for modelling or others',
1030 engine_other: StringProperty(
1031 name="Engine",
1032 description="engine not specified by addon",
1033 default="",
1036 engine1: EnumProperty(
1037 name='2nd Engine',
1038 items=engines,
1039 default='NONE',
1040 description='Output engine',
1042 engine2: EnumProperty(
1043 name='3rd Engine',
1044 items=engines,
1045 default='NONE',
1046 description='Output engine',
1048 engine3: EnumProperty(
1049 name='4th Engine',
1050 items=engines,
1051 default='NONE',
1052 description='Output engine',
1055 manufacturer: StringProperty(
1056 name="Manufacturer",
1057 description="Manufacturer, company making a design piece or product. Not you",
1058 default="",
1061 designer: StringProperty(
1062 name="Designer",
1063 description="Author of the original design piece depicted. Usually not you",
1064 default="",
1067 design_collection: StringProperty(
1068 name="Design Collection",
1069 description="Fill if this piece is part of a real world design collection",
1070 default="",
1073 design_variant: StringProperty(
1074 name="Variant",
1075 description="Colour or material variant of the product",
1076 default="",
1079 thumbnail: StringProperty(
1080 name="Thumbnail",
1081 description="Thumbnail path - 512x512 .jpg\n"
1082 "Rendered with cycles",
1084 subtype='FILE_PATH',
1085 default="",
1086 update=autothumb.update_upload_model_preview)
1088 thumbnail_background_lightness: FloatProperty(name="Thumbnail Background Lightness",
1089 description="set to make your material stand out", default=1.0,
1090 min=0.01, max=10)
1092 thumbnail_angle: EnumProperty(
1093 name='Thumbnail Angle',
1094 items=autothumb.thumbnail_angles,
1095 default='DEFAULT',
1096 description='thumbnailer angle',
1099 thumbnail_snap_to: EnumProperty(
1100 name='Model Snaps To:',
1101 items=autothumb.thumbnail_snap,
1102 default='GROUND',
1103 description='typical placing of the interior. Leave on ground for most objects that respect gravity :)',
1106 thumbnail_resolution: EnumProperty(
1107 name="Resolution",
1108 items=autothumb.thumbnail_resolutions,
1109 description="Thumbnail resolution",
1110 default="1024",
1113 thumbnail_samples: IntProperty(name="Cycles Samples",
1114 description="cycles samples setting", default=100,
1115 min=5, max=5000)
1116 thumbnail_denoising: BoolProperty(name="Use Denoising",
1117 description="Use denoising", default=True)
1119 use_design_year: BoolProperty(name="Use Design Year",
1120 description="When this thing came into world for the first time\n"
1121 " e.g. for dinosaur, you set -240 million years ;) ",
1122 default=False)
1123 design_year: IntProperty(name="Design Year", description="when was this item designed", default=1960)
1124 # use_age : BoolProperty( name = "use item age", description = "use item age", default = False)
1125 condition: EnumProperty(
1126 items=conditions,
1127 default='UNSPECIFIED',
1128 description='age of the object',
1131 adult: BoolProperty(name="Adult Content", description="adult content", default=False)
1133 work_hours: FloatProperty(name="Work Hours", description="How long did it take you to finish the asset?",
1134 default=0.0, min=0.0, max=8760)
1136 modifiers: StringProperty(
1137 name="Modifiers Used",
1138 description="if you need specific modifiers, autofilled",
1139 default="",
1142 materials: StringProperty(
1143 name="Material Names",
1144 description="names of materials in the file, autofilled",
1145 default="",
1147 shaders: StringProperty(
1148 name="Shaders Used",
1149 description="shaders used in asset, autofilled",
1150 default="",
1153 dimensions: FloatVectorProperty(
1154 name="Dimensions",
1155 description="dimensions of the whole asset hierarchy",
1156 default=(0, 0, 0),
1158 bbox_min: FloatVectorProperty(
1159 name="Bbox Min",
1160 description="dimensions of the whole asset hierarchy",
1161 default=(-.25, -.25, 0),
1163 bbox_max: FloatVectorProperty(
1164 name="Bbox Max",
1165 description="dimensions of the whole asset hierarchy",
1166 default=(.25, .25, .5),
1169 texture_resolution_min: IntProperty(name="Texture Resolution Min",
1170 description="texture resolution min, autofilled", default=0)
1171 texture_resolution_max: IntProperty(name="Texture Resolution Max",
1172 description="texture resolution max, autofilled", default=0)
1174 pbr: BoolProperty(name="PBR Compatible", description="Is compatible with PBR standard", default=False)
1176 uv: BoolProperty(name="Has UV", description="has an UV set", default=False)
1177 # printable_3d : BoolProperty( name = "3d printable", description = "can be 3d printed", default = False)
1178 animated: BoolProperty(name="Animated", description="is animated", default=False)
1179 face_count: IntProperty(name="Face count", description="face count, autofilled", default=0)
1180 face_count_render: IntProperty(name="Render Face Count", description="render face count, autofilled", default=0)
1182 object_count: IntProperty(name="Number of Objects", description="how many objects are in the asset, autofilled",
1183 default=0)
1184 mesh_poly_type: EnumProperty(
1185 name='Dominant Poly Type',
1186 items=mesh_poly_types,
1187 default='OTHER',
1188 description='',
1191 manifold: BoolProperty(name="Manifold", description="asset is manifold, autofilled", default=False)
1193 rig: BoolProperty(name="Rig", description="asset is rigged, autofilled", default=False)
1194 simulation: BoolProperty(name="Simulation", description="asset uses simulation, autofilled", default=False)
1196 filepath : StringProperty(
1197 name="Filepath",
1198 description="file path",
1199 default="",
1203 # THUMBNAIL STATES
1204 is_generating_thumbnail: BoolProperty(name="Generating Thumbnail",
1205 description="True when background process is running", default=False,
1206 update=autothumb.update_upload_model_preview)
1208 has_autotags: BoolProperty(name="Has Autotagging Done", description="True when autotagging done", default=False)
1211 class BlenderKitSceneUploadProps(PropertyGroup, BlenderKitCommonUploadProps):
1212 style: EnumProperty(
1213 name="Style",
1214 items=model_styles,
1215 description="Style of asset",
1216 default="REALISTIC",
1218 style_other: StringProperty(
1219 name="Style Other",
1220 description="Style not in the list",
1221 default="",
1223 engine: EnumProperty(
1224 name='Engine',
1225 items=engines,
1226 default='CYCLES',
1227 description='Output engine',
1230 production_level: EnumProperty(
1231 name='Production Level',
1232 items=(
1233 ('FINISHED', 'Finished', 'Render or animation ready asset'),
1234 ('TEMPLATE', 'Template', 'Asset intended to help in creation of something else'),
1236 default='FINISHED',
1237 description='Production state of the asset, \n also template should be actually finished, \n'
1238 'just the nature of it can be a template, like a thumbnailer scene, \n '
1239 'finished mesh topology as start for modelling or similar',
1242 engine_other: StringProperty(
1243 name="Engine",
1244 description="engine not specified by addon",
1245 default="",
1248 engine1: EnumProperty(
1249 name='2nd Engine',
1250 items=engines,
1251 default='NONE',
1252 description='Output engine',
1254 engine2: EnumProperty(
1255 name='3rd Engine',
1256 items=engines,
1257 default='NONE',
1258 description='Output engine',
1260 engine3: EnumProperty(
1261 name='4th Engine',
1262 items=engines,
1263 default='NONE',
1264 description='Output engine',
1267 thumbnail: StringProperty(
1268 name="Thumbnail",
1269 description="Thumbnail path - 512x512 .jpg\n"
1270 "Rendered with cycles",
1271 subtype='FILE_PATH',
1272 default="",
1273 update=autothumb.update_upload_scene_preview)
1275 use_design_year: BoolProperty(name="Use Design Year",
1276 description="When this thing came into world for the first time\n"
1277 " e.g. for dinosaur, you set -240 million years ;) ",
1278 default=False)
1279 design_year: IntProperty(name="Design Year", description="when was this item designed", default=1960)
1280 # use_age : BoolProperty( name = "use item age", description = "use item age", default = False)
1281 condition: EnumProperty(
1282 items=conditions,
1283 default='UNSPECIFIED',
1284 description='age of the object',
1287 adult: BoolProperty(name="Adult Content", description="adult content", default=False)
1289 work_hours: FloatProperty(name="Work Hours", description="How long did it take you to finish the asset?",
1290 default=0.0, min=0.0, max=8760)
1292 modifiers: StringProperty(
1293 name="Modifiers Used",
1294 description="if you need specific modifiers, autofilled",
1295 default="",
1298 materials: StringProperty(
1299 name="Material Names",
1300 description="names of materials in the file, autofilled",
1301 default="",
1303 shaders: StringProperty(
1304 name="Shaders Used",
1305 description="shaders used in asset, autofilled",
1306 default="",
1309 dimensions: FloatVectorProperty(
1310 name="Dimensions",
1311 description="dimensions of the whole asset hierarchy",
1312 default=(0, 0, 0),
1314 bbox_min: FloatVectorProperty(
1315 name="Dimensions",
1316 description="dimensions of the whole asset hierarchy",
1317 default=(-.25, -.25, 0),
1319 bbox_max: FloatVectorProperty(
1320 name="Dimensions",
1321 description="dimensions of the whole asset hierarchy",
1322 default=(.25, .25, .5),
1325 texture_resolution_min: IntProperty(name="Texture Resolution Min",
1326 description="texture resolution min, autofilled", default=0)
1327 texture_resolution_max: IntProperty(name="Texture Resolution Max",
1328 description="texture resolution max, autofilled", default=0)
1330 pbr: BoolProperty(name="PBR Compatible", description="Is compatible with PBR standard", default=False)
1332 uv: BoolProperty(name="Has UV", description="has an UV set", default=False)
1333 # printable_3d : BoolProperty( name = "3d printable", description = "can be 3d printed", default = False)
1334 animated: BoolProperty(name="Animated", description="is animated", default=False)
1335 face_count: IntProperty(name="Face Count", description="face count, autofilled", default=0)
1336 face_count_render: IntProperty(name="Render Face Count", description="render face count, autofilled", default=0)
1338 object_count: IntProperty(name="Number of Objects", description="how many objects are in the asset, autofilled",
1339 default=0)
1340 mesh_poly_type: EnumProperty(
1341 name='Dominant Poly Type',
1342 items=mesh_poly_types,
1343 default='OTHER',
1344 description='',
1347 rig: BoolProperty(name="Rig", description="asset is rigged, autofilled", default=False)
1348 simulation: BoolProperty(name="Simulation", description="asset uses simulation, autofilled", default=False)
1350 # THUMBNAIL STATES
1351 is_generating_thumbnail: BoolProperty(name="Generating Thumbnail",
1352 description="True when background process is running", default=False,
1353 update=autothumb.update_upload_model_preview)
1355 has_autotags: BoolProperty(name="Has Autotagging Done", description="True when autotagging done", default=False)
1358 class BlenderKitModelSearchProps(PropertyGroup, BlenderKitCommonSearchProps):
1359 search_keywords: StringProperty(
1360 name="Search",
1361 description="Search for these keywords",
1362 default="",
1363 update=search.search_update
1365 search_style: EnumProperty(
1366 name="Style",
1367 items=search_model_styles,
1368 description="Keywords defining style (realistic, painted, polygonal, other)",
1369 default="ANY",
1370 update=search.search_update
1372 search_style_other: StringProperty(
1373 name="Style",
1374 description="Search style - other",
1375 default="",
1376 update=search.search_update
1378 search_engine: EnumProperty(
1379 items=engines,
1380 default='CYCLES',
1381 description='Output engine',
1382 update=search.search_update
1384 search_engine_other: StringProperty(
1385 name="Engine",
1386 description="Engine not specified by addon",
1387 default="",
1388 update=search.search_update
1391 # CONDITION
1392 search_condition: EnumProperty(
1393 items=conditions,
1394 default='UNSPECIFIED',
1395 description='Condition of the object',
1396 update=search.search_update
1399 search_adult: BoolProperty(
1400 name="Adult Content",
1401 description="You're adult and agree with searching adult content",
1402 default=False,
1403 update=search.search_update
1406 # DESIGN YEAR
1407 search_design_year: BoolProperty(name="Sesigned in Year",
1408 description="When the object was approximately designed. \n"
1409 "Useful for search of historical or future objects",
1410 default=False,
1411 update=search.search_update,
1414 search_design_year_min: IntProperty(name="Minimum Design Year",
1415 description="Minimum design year",
1416 default=1950, min=-100000000, max=1000000000,
1417 update=search.search_update,
1420 search_design_year_max: IntProperty(name="Maximum Design Year",
1421 description="Maximum design year",
1422 default=2017,
1423 min=0,
1424 max=10000000,
1425 update=search.search_update,
1428 # POLYCOUNT
1429 search_polycount: BoolProperty(name="Use Polycount",
1430 description="Limit polycount",
1431 default=False,
1432 update=search.search_update, )
1434 search_polycount_min: IntProperty(name="Min Polycount",
1435 description="Minimum poly count",
1436 default=0,
1437 min=0,
1438 max=100000000,
1439 update=search.search_update, )
1441 search_polycount_max: IntProperty(name="Max Polycount",
1442 description="Maximum poly count",
1443 default=100000000,
1444 min=0,
1445 max=100000000,
1446 update=search.search_update,
1449 append_method: EnumProperty(
1450 name="Import Method",
1451 items=(
1452 ('LINK_COLLECTION', 'Link', 'Link Collection'),
1453 ('APPEND_OBJECTS', 'Append', 'Append as Objects'),
1455 description="Appended objects are editable in your scene. Linked assets are saved in original files, "
1456 "aren't editable but also don't increase your file size",
1457 default="APPEND_OBJECTS"
1459 append_link: EnumProperty(
1460 name="How to Attach",
1461 items=(
1462 ('LINK', 'Link', ''),
1463 ('APPEND', 'Append', ''),
1465 description="choose if the assets will be linked or appended",
1466 default="LINK"
1468 import_as: EnumProperty(
1469 name="Import as",
1470 items=(
1471 ('GROUP', 'group', ''),
1472 ('INDIVIDUAL', 'objects', ''),
1475 description="choose if the assets will be linked or appended",
1476 default="GROUP"
1478 randomize_rotation: BoolProperty(name='Randomize Rotation',
1479 description="randomize rotation at placement",
1480 default=False)
1481 randomize_rotation_amount: FloatProperty(name="Randomization Max Angle",
1482 description="maximum angle for random rotation",
1483 default=math.pi / 36,
1484 min=0,
1485 max=2 * math.pi,
1486 subtype='ANGLE')
1487 offset_rotation_amount: FloatProperty(name="Offset Rotation",
1488 description="offset rotation, hidden prop",
1489 default=0,
1490 min=0,
1491 max=360,
1492 subtype='ANGLE')
1493 offset_rotation_step: FloatProperty(name="Offset Rotation Step",
1494 description="offset rotation, hidden prop",
1495 default=math.pi / 2,
1496 min=0,
1497 max=180,
1498 subtype='ANGLE')
1500 perpendicular_snap: BoolProperty(name='Perpendicular snap',
1501 description="Limit snapping that is close to perpendicular angles to be perpendicular",
1502 default=True)
1504 perpendicular_snap_threshold: FloatProperty(name="Threshold",
1505 description="Limit perpendicular snap to be below these values",
1506 default=.25,
1507 min=0,
1508 max=.5,
1512 class BlenderKitHDRSearchProps(PropertyGroup, BlenderKitCommonSearchProps):
1513 search_keywords: StringProperty(
1514 name="Search",
1515 description="Search for these keywords",
1516 default="",
1517 update=search.search_update
1520 true_hdr: BoolProperty(
1521 name='Real HDRs only',
1522 description='Search only for real HDRs, this means images that have a range higher than 0-1 in their pixels.',
1523 default=True,
1524 update=search.search_update
1528 class BlenderKitSceneSearchProps(PropertyGroup, BlenderKitCommonSearchProps):
1529 search_keywords: StringProperty(
1530 name="Search",
1531 description="Search for these keywords",
1532 default="",
1533 update=search.search_update
1535 search_style: EnumProperty(
1536 name="Style",
1537 items=search_model_styles,
1538 description="Restrict search for style",
1539 default="ANY",
1540 update=search.search_update
1542 search_style_other: StringProperty(
1543 name="Style",
1544 description="Search style - other",
1545 default="",
1546 update=search.search_update
1548 search_engine: EnumProperty(
1549 items=engines,
1550 default='CYCLES',
1551 description='Output engine',
1552 update=search.search_update
1554 search_engine_other: StringProperty(
1555 name="Engine",
1556 description="Engine not specified by addon",
1557 default="",
1558 update=search.search_update
1560 append_link: EnumProperty(
1561 name="Append or link",
1562 items=(
1563 ('LINK', 'Link', ''),
1564 ('APPEND', 'Append', ''),
1566 description="choose if the scene will be linked or appended",
1567 default="APPEND"
1569 switch_after_append: BoolProperty(
1570 name='Switch to scene after download',
1571 default=True
1575 def fix_subdir(self, context):
1576 '''Fixes project subdicrectory settings if people input invalid path.'''
1578 # pp = pathlib.PurePath(self.project_subdir)
1579 pp = self.project_subdir[:]
1580 pp = pp.replace('\\', '')
1581 pp = pp.replace('/', '')
1582 pp = pp.replace(':', '')
1583 pp = '//' + pp
1584 if self.project_subdir != pp:
1585 self.project_subdir = pp
1587 ui_panels.ui_message(title="Fixed to relative path",
1588 message="This path should be always realative.\n" \
1589 " It's a directory BlenderKit creates where your .blend is \n " \
1590 "and uses it for storing assets.")
1593 class BlenderKitAddonPreferences(AddonPreferences):
1594 # this must match the addon name, use '__package__'
1595 # when defining this in a submodule of a python package.
1596 bl_idname = __name__
1598 default_global_dict = paths.default_global_dict()
1600 enable_oauth = True
1602 api_key: StringProperty(
1603 name="BlenderKit API Key",
1604 description="Your blenderkit API Key. Get it from your page on the website",
1605 default="",
1606 subtype="PASSWORD",
1607 update=utils.save_prefs
1610 api_key_refresh: StringProperty(
1611 name="BlenderKit refresh API Key",
1612 description="API key used to refresh the token regularly",
1613 default="",
1614 subtype="PASSWORD",
1617 api_key_timeout: IntProperty(
1618 name='api key timeout',
1619 description='time where the api key will need to be refreshed',
1620 default=0,
1623 api_key_life: IntProperty(
1624 name='api key life time',
1625 description='maximum lifetime of the api key, in seconds',
1626 default=0,
1629 refresh_in_progress: BoolProperty(
1630 name="Api key refresh in progress",
1631 description="Api key is currently being refreshed. Don't refresh it again",
1632 default=False
1635 login_attempt: BoolProperty(
1636 name="Login/Signup attempt",
1637 description="When this is on, BlenderKit is trying to connect and login",
1638 default=False
1641 show_on_start: BoolProperty(
1642 name="Show assetbar when starting blender",
1643 description="Show assetbar when starting blender",
1644 default=False
1647 tips_on_start: BoolProperty(
1648 name="Show tips when starting blender",
1649 description="Show tips when starting blender",
1650 default=False
1653 search_in_header: BoolProperty(
1654 name="Show BlenderKit search in 3D view header",
1655 description="Show BlenderKit search in 3D view header",
1656 default=True
1659 global_dir: StringProperty(
1660 name="Global Files Directory",
1661 description="Global storage for your assets, will use subdirectories for the contents",
1662 subtype='DIR_PATH',
1663 default=default_global_dict,
1664 update=utils.save_prefs
1667 project_subdir: StringProperty(
1668 name="Project Assets Subdirectory",
1669 description="where data will be stored for individual projects",
1670 # subtype='DIR_PATH',
1671 default="//assets",
1672 update=fix_subdir
1675 directory_behaviour: EnumProperty(
1676 name="Use Directories",
1677 items=(
1678 ('BOTH', 'Global and subdir',
1679 'store files both in global lib and subdirectory of current project. '
1680 'Warning - each file can be many times on your harddrive, but helps you keep your projects in one piece'),
1681 ('GLOBAL', 'Global',
1682 "store downloaded files only in global directory. \n "
1683 "This can bring problems when moving your projects, \n"
1684 "since assets won't be in subdirectory of current project"),
1685 ('LOCAL', 'Local',
1686 'store downloaded files only in local directory.\n'
1687 ' This can use more bandwidth when you reuse assets in different projects. ')
1690 description="Which directories will be used for storing downloaded data",
1691 default="BOTH",
1693 thumbnail_use_gpu: BoolProperty(
1694 name="Use GPU for Thumbnails Rendering (For assets upload)",
1695 description="By default this is off so you can continue your work without any lag",
1696 default=False
1699 panel_behaviour: EnumProperty(
1700 name="Panels Locations",
1701 items=(
1702 ('BOTH', 'Both Types',
1703 ''),
1704 ('UNIFIED', 'Unified 3D View Panel',
1705 ""),
1706 ('LOCAL', 'Relative to Data',
1710 description="Which directories will be used for storing downloaded data",
1711 default="UNIFIED",
1714 max_assetbar_rows: IntProperty(name="Max Assetbar Rows",
1715 description="max rows of assetbar in the 3D view",
1716 default=1,
1717 min=1,
1718 max=20)
1720 thumb_size: IntProperty(name="Assetbar thumbnail Size", default=96, min=-1, max=256)
1722 asset_counter: IntProperty(name="Usage Counter",
1723 description="Counts usages so it asks for registration only after reaching a limit",
1724 default=0,
1725 min=0,
1726 max=20000)
1728 # this is now made obsolete by the new popup upon registration -ensures the user knows about the first search.
1729 # first_run: BoolProperty(
1730 # name="First run",
1731 # description="Detects if addon was already registered/run.",
1732 # default=True,
1733 # update=utils.save_prefs
1736 use_timers: BoolProperty(
1737 name="Use timers",
1738 description="Use timers for BlenderKit. Usefull for debugging since timers seem to be unstable",
1739 default=True,
1740 update=utils.save_prefs
1743 # single_timer: BoolProperty(
1744 # name="Use timers",
1745 # description="Use timers for BlenderKit. Usefull for debugging since timers seem to be unstable",
1746 # default=True,
1747 # update=utils.save_prefs
1750 experimental_features: BoolProperty(
1751 name="Enable experimental features",
1752 description="Enable all experimental features of BlenderKit. Use at your own risk",
1753 default=False,
1754 update=utils.save_prefs
1757 categories_fix: BoolProperty(
1758 name="Enable category fixing mode",
1759 description="Enable category fixing mode",
1760 default=False,
1761 update=utils.save_prefs
1764 # allow_proximity : BoolProperty(
1765 # name="allow proximity data reports",
1766 # description="This sends anonymized proximity data \n \
1767 # and allows us to make relations between database objects \n \
1768 # without user interaction",
1769 # default=False
1772 def draw(self, context):
1773 layout = self.layout
1774 layout.prop(self, "show_on_start")
1776 if self.api_key.strip() == '':
1777 if self.enable_oauth:
1778 ui_panels.draw_login_buttons(layout)
1779 else:
1780 op = layout.operator("wm.url_open", text="Register online and get your API Key",
1781 icon='QUESTION')
1782 op.url = paths.BLENDERKIT_SIGNUP_URL
1783 else:
1784 if self.enable_oauth:
1785 layout.operator("wm.blenderkit_logout", text="Logout",
1786 icon='URL')
1788 # if not self.enable_oauth:
1789 layout.prop(self, "api_key", text='Your API Key')
1790 # layout.label(text='After you paste API Key, categories are downloaded, so blender will freeze for a few seconds.')
1791 layout.prop(self, "global_dir")
1792 layout.prop(self, "project_subdir")
1793 # layout.prop(self, "temp_dir")
1794 layout.prop(self, "directory_behaviour")
1795 # layout.prop(self, "allow_proximity")
1796 # layout.prop(self, "panel_behaviour")
1797 layout.prop(self, "thumb_size")
1798 layout.prop(self, "max_assetbar_rows")
1799 layout.prop(self, "tips_on_start")
1800 layout.prop(self, "search_in_header")
1801 layout.prop(self, "thumbnail_use_gpu")
1803 if bpy.context.preferences.view.show_developer_ui:
1804 layout.prop(self, "use_timers")
1805 layout.prop(self, "experimental_features")
1806 layout.prop(self, "categories_fix")
1809 # # @bpy.app.handlers.persistent
1810 # def blenderkit_timer():
1813 # if not user_preferences.use_timers:
1814 # search.search_timer()
1815 # download.download_timer()
1816 # tasks_queue.queue_worker()
1817 # bg_blender.bg_update()
1818 # registration
1819 classes = (
1821 BlenderKitAddonPreferences,
1822 BlenderKitUIProps,
1824 BlenderKitModelSearchProps,
1825 BlenderKitModelUploadProps,
1827 BlenderKitSceneSearchProps,
1828 BlenderKitSceneUploadProps,
1830 BlenderKitHDRSearchProps,
1831 BlenderKitHDRUploadProps,
1833 BlenderKitMaterialUploadProps,
1834 BlenderKitMaterialSearchProps,
1836 BlenderKitTextureUploadProps,
1838 BlenderKitBrushSearchProps,
1839 BlenderKitBrushUploadProps,
1841 BlenderKitRatingProps,
1846 def register():
1847 for cls in classes:
1848 bpy.utils.register_class(cls)
1850 bpy.types.Scene.blenderkitUI = PointerProperty(
1851 type=BlenderKitUIProps)
1853 # MODELS
1854 bpy.types.WindowManager.blenderkit_models = PointerProperty(
1855 type=BlenderKitModelSearchProps)
1856 bpy.types.Object.blenderkit = PointerProperty( # for uploads, not now...
1857 type=BlenderKitModelUploadProps)
1858 bpy.types.Object.bkit_ratings = PointerProperty( # for uploads, not now...
1859 type=BlenderKitRatingProps)
1861 # SCENES
1862 bpy.types.WindowManager.blenderkit_scene = PointerProperty(
1863 type=BlenderKitSceneSearchProps)
1864 bpy.types.Scene.blenderkit = PointerProperty( # for uploads, not now...
1865 type=BlenderKitSceneUploadProps)
1866 bpy.types.Scene.bkit_ratings = PointerProperty( # for uploads, not now...
1867 type=BlenderKitRatingProps)
1869 # HDRs
1870 bpy.types.WindowManager.blenderkit_HDR = PointerProperty(
1871 type=BlenderKitHDRSearchProps)
1872 bpy.types.Image.blenderkit = PointerProperty( # for uploads, not now...
1873 type=BlenderKitHDRUploadProps)
1874 bpy.types.Image.bkit_ratings = PointerProperty( # for uploads, not now...
1875 type=BlenderKitRatingProps)
1877 # MATERIALS
1878 bpy.types.WindowManager.blenderkit_mat = PointerProperty(
1879 type=BlenderKitMaterialSearchProps)
1880 bpy.types.Material.blenderkit = PointerProperty( # for uploads, not now...
1881 type=BlenderKitMaterialUploadProps)
1882 bpy.types.Material.bkit_ratings = PointerProperty( # for uploads, not now...
1883 type=BlenderKitRatingProps)
1885 # BRUSHES
1886 bpy.types.WindowManager.blenderkit_brush = PointerProperty(
1887 type=BlenderKitBrushSearchProps)
1888 bpy.types.Brush.blenderkit = PointerProperty( # for uploads, not now...
1889 type=BlenderKitBrushUploadProps)
1890 bpy.types.Brush.bkit_ratings = PointerProperty( # for uploads, not now...
1891 type=BlenderKitRatingProps)
1893 search.register_search()
1894 asset_inspector.register_asset_inspector()
1895 download.register_download()
1896 upload.register_upload()
1897 ratings.register_ratings()
1898 autothumb.register_thumbnailer()
1899 ui.register_ui()
1900 icons.register_icons()
1901 ui_panels.register_ui_panels()
1902 bg_blender.register()
1903 utils.load_prefs()
1904 overrides.register_overrides()
1905 bkit_oauth.register()
1906 tasks_queue.register()
1907 asset_bar_op.register()
1909 user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
1910 if user_preferences.use_timers:
1911 bpy.app.timers.register(check_timers_timer, persistent=True)
1913 bpy.app.handlers.load_post.append(scene_load)
1914 # detect if the user just enabled the addon in preferences, thus enable to run
1915 for w in bpy.context.window_manager.windows:
1916 for a in w.screen.areas:
1917 if a.type == 'PREFERENCES':
1918 tasks_queue.add_task((bpy.ops.wm.blenderkit_welcome, ('INVOKE_DEFAULT',)), fake_context=True,
1919 fake_context_area='PREFERENCES')
1920 #save preferences after manually enabling the addon
1921 tasks_queue.add_task((bpy.ops.wm.save_userpref, ()), fake_context=False,)
1924 def unregister():
1925 if bpy.app.timers.is_registered(check_timers_timer):
1926 bpy.app.timers.unregister(check_timers_timer)
1927 ui_panels.unregister_ui_panels()
1928 ui.unregister_ui()
1930 icons.unregister_icons()
1931 search.unregister_search()
1932 asset_inspector.unregister_asset_inspector()
1933 download.unregister_download()
1934 upload.unregister_upload()
1935 ratings.unregister_ratings()
1936 autothumb.unregister_thumbnailer()
1937 bg_blender.unregister()
1938 overrides.unregister_overrides()
1939 bkit_oauth.unregister()
1940 tasks_queue.unregister()
1941 asset_bar_op.unregister()
1943 del bpy.types.WindowManager.blenderkit_models
1944 del bpy.types.WindowManager.blenderkit_scene
1945 del bpy.types.WindowManager.blenderkit_HDR
1946 del bpy.types.WindowManager.blenderkit_brush
1947 del bpy.types.WindowManager.blenderkit_mat
1949 del bpy.types.Scene.blenderkit
1950 del bpy.types.Object.blenderkit
1951 del bpy.types.Image.blenderkit
1952 del bpy.types.Material.blenderkit
1953 del bpy.types.Brush.blenderkit
1955 for cls in classes:
1956 bpy.utils.unregister_class(cls)
1958 bpy.app.handlers.load_post.remove(scene_load)