Merge branch 'blender-v2.92-release'
[blender-addons.git] / blenderkit / __init__.py
blob98671f4c20e0d37d389ca1d97f19cdedab6b75cf
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": (1, 0, 40),
23 "blender": (2, 92, 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/add_mesh/blenderkit.html",
28 "category": "3D View",
31 if "bpy" in locals():
32 from importlib import reload
33 #alphabetically sorted all add-on modules since reload only happens from __init__.
34 # modules with _bg are used for background computations in separate blender instance and that's why they don't need reload.
36 append_link = reload(append_link)
37 asset_bar_op = reload(asset_bar_op)
38 asset_inspector = reload(asset_inspector)
39 autothumb = reload(autothumb)
40 bg_blender = reload(bg_blender)
41 bkit_oauth = reload(bkit_oauth)
42 categories = reload(categories)
43 colors = reload(colors)
44 download = reload(download)
45 icons = reload(icons)
46 image_utils = reload(image_utils)
47 oauth = reload(oauth)
48 overrides = reload(overrides)
49 paths = reload(paths)
50 ratings = reload(ratings)
51 resolutions = reload(resolutions)
52 search = reload(search)
53 tasks_queue = reload(tasks_queue)
54 ui = reload(ui)
55 ui_bgl = reload(ui_bgl)
56 ui_panels = reload(ui_panels)
57 upload = reload(upload)
58 utils = reload(utils)
60 bl_ui_label = reload(bl_ui_label)
61 bl_ui_button = reload(bl_ui_button)
62 # bl_ui_checkbox = reload(bl_ui_checkbox)
63 # bl_ui_slider = reload(bl_ui_slider)
64 # bl_ui_up_down = reload(bl_ui_up_down)
65 bl_ui_drag_panel = reload(bl_ui_drag_panel)
66 bl_ui_draw_op = reload(bl_ui_draw_op)
67 # bl_ui_textbox = reload(bl_ui_textbox)
69 else:
70 from blenderkit import append_link
71 from blenderkit import asset_bar_op
72 from blenderkit import asset_inspector
73 from blenderkit import autothumb
74 from blenderkit import bg_blender
75 from blenderkit import bkit_oauth
76 from blenderkit import categories
77 from blenderkit import colors
78 from blenderkit import download
79 from blenderkit import icons
80 from blenderkit import image_utils
81 from blenderkit import oauth
82 from blenderkit import overrides
83 from blenderkit import paths
84 from blenderkit import ratings
85 from blenderkit import resolutions
86 from blenderkit import search
87 from blenderkit import tasks_queue
88 from blenderkit import ui
89 from blenderkit import ui_bgl
90 from blenderkit import ui_panels
91 from blenderkit import upload
92 from blenderkit import utils
94 from blenderkit.bl_ui_widgets import bl_ui_label
95 from blenderkit.bl_ui_widgets import bl_ui_button
96 # from blenderkit.bl_ui_widgets import bl_ui_checkbox
97 # from blenderkit.bl_ui_widgets import bl_ui_slider
98 # from blenderkit.bl_ui_widgets import bl_ui_up_down
99 from blenderkit.bl_ui_widgets import bl_ui_drag_panel
100 from blenderkit.bl_ui_widgets import bl_ui_draw_op
101 # from blenderkit.bl_ui_widgets import bl_ui_textbox
104 import os
105 import math
106 import time
107 import logging
108 import bpy
109 import pathlib
111 log = logging.getLogger(__name__)
114 from bpy.app.handlers import persistent
115 import bpy.utils.previews
116 import mathutils
117 from mathutils import Vector
118 from bpy.props import (
119 IntProperty,
120 FloatProperty,
121 FloatVectorProperty,
122 StringProperty,
123 EnumProperty,
124 BoolProperty,
125 PointerProperty,
127 from bpy.types import (
128 Operator,
129 Panel,
130 AddonPreferences,
131 PropertyGroup,
135 # logging.basicConfig(filename = 'blenderkit.log', level = logging.INFO,
136 # format = ' %(asctime)s:%(filename)s:%(funcName)s:%(lineno)d:%(message)s')
139 @persistent
140 def scene_load(context):
141 if not bpy.app.background:
142 search.load_previews()
143 ui_props = bpy.context.scene.blenderkitUI
144 ui_props.assetbar_on = False
145 ui_props.turn_off = False
146 preferences = bpy.context.preferences.addons['blenderkit'].preferences
147 preferences.login_attempt = False
150 @bpy.app.handlers.persistent
151 def check_timers_timer():
152 ''' checks if all timers are registered regularly. Prevents possible bugs from stopping the addon.'''
153 if not bpy.app.timers.is_registered(search.timer_update):
154 bpy.app.timers.register(search.timer_update)
155 if not bpy.app.timers.is_registered(download.timer_update):
156 bpy.app.timers.register(download.timer_update)
157 if not (bpy.app.timers.is_registered(tasks_queue.queue_worker)):
158 bpy.app.timers.register(tasks_queue.queue_worker)
159 if not bpy.app.timers.is_registered(bg_blender.bg_update):
160 bpy.app.timers.register(bg_blender.bg_update)
161 return 5.0
165 conditions = (
166 ('UNSPECIFIED', 'Unspecified', "Don't use this in search"),
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, mostly for games'),
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 style'),
181 search_model_styles = (
182 ('REALISTIC', 'Realistic', "photo realistic model"),
183 ('PAINTERLY', 'Painterly', 'hand painted with visible strokes, mostly for games'),
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, mostly for games'),
194 ('OTHER', 'Other', 'Other style'),
196 search_material_styles = (
197 ('REALISTIC', 'Realistic', "photo realistic model"),
198 ('NPR', 'Non photorealistic', 'hand painted with visible strokes, mostly for games'),
199 ('ANY', 'Any', 'Any'),
201 engines = (
202 ('CYCLES', 'Cycles', 'blender cycles pathtracer'),
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', ''),
228 thumbnail_angles = (
229 ('DEFAULT', 'default', ''),
230 ('FRONT', 'front', ''),
231 ('SIDE', 'side', ''),
232 ('TOP', 'top', ''),
235 thumbnail_snap = (
236 ('GROUND', 'ground', ''),
237 ('WALL', 'wall', ''),
238 ('CEILING', 'ceiling', ''),
239 ('FLOAT', 'floating', ''),
242 thumbnail_resolutions = (
243 ('256', '256', ''),
244 ('512', '512 - minimum for public', ''),
245 ('1024', '1024', ''),
246 ('2048', '2048', ''),
249 def udate_down_up(self, context):
250 """Perform a search if results are empty."""
251 s = context.scene
252 props = s.blenderkitUI
253 if s['search results'] == None and props.down_up == 'SEARCH':
254 search.search()
256 def switch_search_results(self, context):
257 s = bpy.context.scene
258 props = s.blenderkitUI
259 if props.asset_type == 'MODEL':
260 s['search results'] = s.get('bkit model search')
261 s['search results orig'] = s.get('bkit model search orig')
262 elif props.asset_type == 'SCENE':
263 s['search results'] = s.get('bkit scene search')
264 s['search results orig'] = s.get('bkit scene search orig')
265 elif props.asset_type == 'HDR':
266 s['search results'] = s.get('bkit hdr search')
267 s['search results orig'] = s.get('bkit hdr search orig')
268 elif props.asset_type == 'MATERIAL':
269 s['search results'] = s.get('bkit material search')
270 s['search results orig'] = s.get('bkit material search orig')
271 elif props.asset_type == 'TEXTURE':
272 s['search results'] = s.get('bkit texture search')
273 s['search results orig'] = s.get('bkit texture search orig')
274 elif props.asset_type == 'BRUSH':
275 s['search results'] = s.get('bkit brush search')
276 s['search results orig'] = s.get('bkit brush search orig')
277 if not(context.sculpt_object or context.image_paint_object):
278 ui.add_report(
279 'Switch to paint or sculpt mode to search in BlenderKit brushes.')
281 search.load_previews()
282 if s['search results'] == None and props.down_up == 'SEARCH':
283 search.search()
287 def asset_type_callback(self, context):
289 Returns
290 items for Enum property, depending on the down_up property - BlenderKit is either in search or in upload mode.
293 user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
295 if self.down_up == 'SEARCH':
296 items = (
297 ('MODEL', 'Models', 'Find models in the BlenderKit online database', 'OBJECT_DATAMODE', 0),
298 ('MATERIAL', 'Materials', 'Find materials in the BlenderKit online database', 'MATERIAL', 2),
299 # ('TEXTURE', 'Texture', 'Browse textures', 'TEXTURE', 3),
300 ('SCENE', 'Scenes', 'Browse scenes', 'SCENE_DATA', 3),
301 ('HDR', 'Hdrs', 'Browse hdrs', 'WORLD', 4),
302 ('BRUSH', 'Brushes', 'Find brushes in the BlenderKit online database', 'BRUSH_DATA', 5)
304 else:
305 items = (
306 ('MODEL', 'Model', 'Upload a model to BlenderKit', 'OBJECT_DATAMODE', 0),
307 # ('SCENE', 'SCENE', 'Browse scenes', 'SCENE_DATA', 1),
308 ('MATERIAL', 'Material', 'Upload a material to BlenderKit', 'MATERIAL', 2),
309 # ('TEXTURE', 'Texture', 'Browse textures', 'TEXTURE', 3),
310 ('SCENE', 'Scenes', 'Browse scenes', 'SCENE_DATA', 3),
311 ('HDR', 'Hdrs', 'Browse hdrs', 'WORLD', 4),
312 ('BRUSH', 'Brush', 'Upload a brush to BlenderKit', 'BRUSH_DATA', 5)
315 return items
318 class BlenderKitUIProps(PropertyGroup):
319 down_up: EnumProperty(
320 name="Download vs Upload",
321 items=(
322 ('SEARCH', 'Search', 'Sctivate searching', 'VIEWZOOM', 0),
323 ('UPLOAD', 'Upload', 'Activate uploading', 'COPYDOWN', 1),
324 # ('RATING', 'Rating', 'Activate rating', 'SOLO_ON', 2)
326 description="BLenderKit",
327 default="SEARCH",
328 update = udate_down_up
330 asset_type: EnumProperty(
331 name="BlenderKit Active Asset Type",
332 items=asset_type_callback,
333 description="Activate asset in UI",
334 default=None,
335 update=switch_search_results
337 # these aren't actually used ( by now, seems to better use globals in UI module:
338 draw_tooltip: BoolProperty(name="Draw Tooltip", default=False)
339 addon_update: BoolProperty(name="Should Update Addon", default=False)
340 tooltip: StringProperty(
341 name="Tooltip",
342 description="asset preview info",
343 default="")
345 ui_scale = 1
347 thumb_size_def = 96
348 margin_def = 0
350 thumb_size: IntProperty(name="Thumbnail Size", default=thumb_size_def, min=-1, max=256)
352 margin: IntProperty(name="Margin", default=margin_def, min=-1, max=256)
353 highlight_margin: IntProperty(name="Highlight Margin", default=int(margin_def / 2), min=-10, max=256)
355 bar_height: IntProperty(name="Bar Height", default=thumb_size_def + 2 * margin_def, min=-1, max=2048)
356 bar_x_offset: IntProperty(name="Bar X Offset", default=20, min=0, max=5000)
357 bar_y_offset: IntProperty(name="Bar Y Offset", default=80, min=0, max=5000)
359 bar_x: IntProperty(name="Bar X", default=100, min=0, max=5000)
360 bar_y: IntProperty(name="Bar Y", default=100, min=50, max=5000)
361 bar_end: IntProperty(name="Bar End", default=100, min=0, max=5000)
362 bar_width: IntProperty(name="Bar Width", default=100, min=0, max=5000)
364 wcount: IntProperty(name="Width Count", default=10, min=0, max=5000)
365 hcount: IntProperty(name="Rows", default=5, min=0, max=5000)
367 reports_y: IntProperty(name="Reports Y", default=5, min=0, max=5000)
368 reports_x: IntProperty(name="Reports X", default=5, min=0, max=5000)
370 assetbar_on: BoolProperty(name="Assetbar On", default=False)
371 turn_off: BoolProperty(name="Turn Off", default=False)
373 mouse_x: IntProperty(name="Mouse X", default=0)
374 mouse_y: IntProperty(name="Mouse Y", default=0)
376 active_index: IntProperty(name="Active Index", default=-3)
377 scrolloffset: IntProperty(name="Scroll Offset", default=0)
378 drawoffset: IntProperty(name="Draw Offset", default=0)
380 dragging: BoolProperty(name="Dragging", default=False)
381 drag_init: BoolProperty(name="Drag Initialisation", default=False)
382 drag_length: IntProperty(name="Drag length", default=0)
383 draw_drag_image: BoolProperty(name="Draw Drag Image", default=False)
384 draw_snapped_bounds: BoolProperty(name="Draw Snapped Bounds", default=False)
386 snapped_location: FloatVectorProperty(name="Snapped Location", default=(0, 0, 0))
387 snapped_bbox_min: FloatVectorProperty(name="Snapped Bbox Min", default=(0, 0, 0))
388 snapped_bbox_max: FloatVectorProperty(name="Snapped Bbox Max", default=(0, 0, 0))
389 snapped_normal: FloatVectorProperty(name="Snapped Normal", default=(0, 0, 0))
391 snapped_rotation: FloatVectorProperty(name="Snapped Rotation", default=(0, 0, 0), subtype='QUATERNION')
393 has_hit: BoolProperty(name="has_hit", default=False)
394 thumbnail_image = StringProperty(
395 name="Thumbnail Image",
396 description="",
397 default=paths.get_addon_thumbnail_path('thumbnail_notready.jpg'))
399 #### rating UI props
400 rating_ui_scale = ui_scale
402 rating_button_on: BoolProperty(name="Rating Button On", default=True)
403 rating_menu_on: BoolProperty(name="Rating Menu On", default=False)
404 rating_on: BoolProperty(name="Rating on", default=True)
406 rating_button_width: IntProperty(name="Rating Button Width", default=50 * ui_scale)
407 rating_button_height: IntProperty(name="Rating Button Height", default=50 * ui_scale)
409 rating_x: IntProperty(name="Rating UI X", default=10)
410 rating_y: IntProperty(name="Rating UI Y", default=10)
412 rating_ui_width: IntProperty(name="Rating UI Width", default=rating_ui_scale * 600)
413 rating_ui_height: IntProperty(name="Rating UI Heightt", default=rating_ui_scale * 256)
415 quality_stars_x: IntProperty(name="Rating UI Stars X", default=rating_ui_scale * 90)
416 quality_stars_y: IntProperty(name="Rating UI Stars Y", default=rating_ui_scale * 190)
418 star_size: IntProperty(name="Star Size", default=rating_ui_scale * 50)
420 workhours_bar_slider_size: IntProperty(name="Workhours Bar Slider Size", default=rating_ui_scale * 30)
422 workhours_bar_x: IntProperty(name="Workhours Bar X", default=rating_ui_scale * (100 - 15))
423 workhours_bar_y: IntProperty(name="Workhours Bar Y", default=rating_ui_scale * (45 - 15))
425 workhours_bar_x_max: IntProperty(name="Workhours Bar X Max", default=rating_ui_scale * (480 - 15))
427 dragging_rating: BoolProperty(name="Dragging Rating", default=False)
428 dragging_rating_quality: BoolProperty(name="Dragging Rating Quality", default=False)
429 dragging_rating_work_hours: BoolProperty(name="Dragging Rating Work Hours", default=False)
430 last_rating_time: FloatProperty(name="Last Rating Time", default=0.0)
432 hdr_upload_image: PointerProperty(name='Upload HDR',
433 type=bpy.types.Image,
434 description='Pick an image to upload')
436 # StringProperty(
437 # name="Upload HDR",
438 # description="Active HDR image to upload",
439 # default="")
442 def search_procedural_update(self, context):
443 if self.search_procedural in ('PROCEDURAL', 'BOTH'):
444 self.search_texture_resolution = False
445 search.search_update(self, context)
448 class BlenderKitCommonSearchProps(object):
449 # STATES
450 is_searching: BoolProperty(name="Searching", description="search is currently running (internal)", default=False)
451 is_downloading: BoolProperty(name="Downloading", description="download is currently running (internal)",
452 default=False)
453 search_done: BoolProperty(name="Search Completed", description="at least one search did run (internal)",
454 default=False)
455 own_only: BoolProperty(name="My Assets", description="Search only for your assets",
456 default=False, update=search.search_update)
457 search_advanced: BoolProperty(name="Advanced Search Options", description="use advanced search properties",
458 default=False, update=search.search_update)
460 search_error: BoolProperty(name="Search Error", description="last search had an error", default=False)
461 report: StringProperty(
462 name="Report",
463 description="errors and messages",
464 default="")
466 # TEXTURE RESOLUTION
467 search_texture_resolution: BoolProperty(name="Texture Resolution",
468 description="Span of the texture resolutions",
469 default=False,
470 update=search.search_update,
472 search_texture_resolution_min: IntProperty(name="Min Texture Resolution",
473 description="Minimum texture resolution",
474 default=256,
475 min=0,
476 max=32768,
477 update=search.search_update,
480 search_texture_resolution_max: IntProperty(name="Max Texture Resolution",
481 description="Maximum texture resolution",
482 default=4096,
483 min=0,
484 max=32768,
485 update=search.search_update,
488 # file_size
489 search_file_size: BoolProperty(name="File Size",
490 description="Span of the file sizes",
491 default=False,
492 update=search.search_update,
494 search_file_size_min: IntProperty(name="Min File Size",
495 description="Minimum file size",
496 default=0,
497 min=0,
498 max=2000,
499 update=search.search_update,
502 search_file_size_max: IntProperty(name="Max File Size",
503 description="Maximum file size",
504 default=500,
505 min=0,
506 max=2000,
507 update=search.search_update,
510 search_procedural: EnumProperty(
511 items=(
512 ('BOTH', 'Both', ''),
513 ('PROCEDURAL', 'Procedural', ''),
514 ('TEXTURE_BASED', 'Texture based', ''),
517 default='BOTH',
518 description='Search only procedural/texture based assets',
519 update=search_procedural_update
522 search_verification_status: EnumProperty(
523 name="Verification status",
524 description="Search by verification status",
525 items=
527 ('ALL', 'All', 'All'),
528 ('UPLOADING', 'Uploading', 'Uploading'),
529 ('UPLOADED', 'Uploaded', 'Uploaded'),
530 ('READY', 'Ready for V.', 'Ready for validation (deprecated since 2.8)'),
531 ('VALIDATED', 'Validated', 'Calidated'),
532 ('ON_HOLD', 'On Hold', 'On Hold'),
533 ('REJECTED', 'Rejected', 'Rejected'),
534 ('DELETED', 'Deleted', 'Deleted'),
536 default='ALL',
537 update=search.search_update,
540 # resolution download/import settings
541 resolution: EnumProperty(
542 name="Max resolution",
543 description="Cap texture sizes in the file to this resolution",
544 items=
546 # ('256', '256x256', ''),
547 ('512', '512x512', ''),
548 ('1024', '1024x1024', ''),
549 ('2048', '2048x2048', ''),
550 ('4096', '4096x4096', ''),
551 ('8192', '8192x8192', ''),
552 ('ORIGINAL', 'ORIGINAL FILE', ''),
555 default='1024',
557 free_only: BoolProperty(name="Free first", description="Show free models first",
558 default=False, update=search.search_update)
560 unpack_files: BoolProperty(name="Unpack Files",
561 description="Unpack files after download",
562 default=True
565 unrated_only: BoolProperty(name="Unrated only", description="Show only unrated models",
566 default=False, update=search.search_update)
569 def name_update(self, context):
570 ''' checks for name change, because it decides if whole asset has to be re-uploaded. Name is stored in the blend file
571 and that's the reason.'''
572 utils.name_update()
577 def update_free(self, context):
578 if self.is_free == False:
579 self.is_free = True
580 title = "All BlenderKit materials are free"
581 message = "Any material uploaded to BlenderKit is free." \
582 " However, it can still earn money for the author," \
583 " based on our fair share system. " \
584 "Part of subscription is sent to artists based on usage by paying users."
586 def draw_message(self, context):
587 utils.label_multiline(self.layout, text=message, icon='NONE', width=-1)
589 bpy.context.window_manager.popup_menu(draw_message, title=title, icon='INFO')
592 class BlenderKitCommonUploadProps(object):
593 id: StringProperty(
594 name="Asset Version Id",
595 description="Unique name of the asset version(hidden)",
596 default="")
597 asset_base_id: StringProperty(
598 name="Asset Base Id",
599 description="Unique name of the asset (hidden)",
600 default="")
601 name: StringProperty(
602 name="Name",
603 description="Main name of the asset",
604 default="",
605 update=name_update
607 # this is to store name for purpose of checking if name has changed.
608 name_old: StringProperty(
609 name="Old Name",
610 description="Old name of the asset",
611 default="",
614 description: StringProperty(
615 name="Description",
616 description="Description of the asset",
617 default="")
618 tags: StringProperty(
619 name="Tags",
620 description="List of tags, separated by commas (optional)",
621 default="",
622 update=utils.update_tags
625 name_changed: BoolProperty(name="Name Changed",
626 description="Name has changed, the asset has to be re-uploaded with all data",
627 default=False)
629 pbr: BoolProperty(name="Pure PBR Compatible",
630 description="Is compatible with PBR standard. This means only image textures are used with no"
631 " procedurals and no color correction, only pbr shader is used",
632 default=False)
634 pbr_type: EnumProperty(
635 name="PBR Type",
636 items=pbr_types,
637 description="PBR type",
638 default="METALLIC",
640 license: EnumProperty(
641 items=upload.licenses,
642 default='royalty_free',
643 description='License. Please read our help for choosing the right licenses',
646 is_private: EnumProperty(
647 name="Thumbnail Style",
648 items=(
649 ('PRIVATE', 'Private', "You asset will be hidden to public. The private assets are limited by a quota."),
650 ('PUBLIC', 'Public', '"Your asset will go into the validation process automatically')
652 description="If not marked private, your asset will go into the validation process automatically\n"
653 "Private assets are limited by quota.",
654 default="PUBLIC",
657 is_procedural: BoolProperty(name="Procedural",
658 description="Asset is procedural - has no texture.",
659 default=True
661 node_count: IntProperty(name="Node count", description="Total nodes in the asset", default=0)
662 texture_count: IntProperty(name="Texture count", description="Total texture count in asset", default=0)
663 total_megapixels: IntProperty(name="Megapixels", description="Total megapixels of texture", default=0)
665 # is_private: BoolProperty(name="Asset is Private",
666 # description="If not marked private, your asset will go into the validation process automatically\n"
667 # "Private assets are limited by quota.",
668 # default=False)
670 is_free: BoolProperty(name="Free for Everyone",
671 description="You consent you want to release this asset as free for everyone",
672 default=False)
674 uploading: BoolProperty(name="Uploading",
675 description="True when background process is running",
676 default=False,
677 update=autothumb.update_upload_material_preview)
678 upload_state: StringProperty(
679 name="State Of Upload",
680 description="bg process reports for upload",
681 default='')
683 has_thumbnail: BoolProperty(name="Has Thumbnail", description="True when thumbnail was checked and loaded",
684 default=False)
686 thumbnail_generating_state: StringProperty(
687 name="Thumbnail Generating State",
688 description="bg process reports for thumbnail generation",
689 default='Please add thumbnail(jpg, at least 512x512)')
691 report: StringProperty(
692 name="Missing Upload Properties",
693 description="used to write down what's missing",
694 default='')
696 category: EnumProperty(
697 name="Category",
698 description="main category to put into",
699 items=categories.get_category_enums,
700 update=categories.update_category_enums
702 subcategory: EnumProperty(
703 name="Subcategory",
704 description="Subcategory to put into",
705 items=categories.get_subcategory_enums,
706 update=categories.update_subcategory_enums
708 subcategory1: EnumProperty(
709 name="Subcategory lvl2",
710 description="Subcategory to put into",
711 items=categories.get_subcategory1_enums
715 class BlenderKitRatingProps(PropertyGroup):
716 rating_quality: IntProperty(name="Quality",
717 description="quality of the material",
718 default=0,
719 min=-1, max=10,
720 update=ratings.update_ratings_quality)
722 # the following enum is only to ease interaction - enums support 'drag over' and enable to draw the stars easily.
723 rating_quality_ui: EnumProperty(name='rating_quality_ui',
724 items=ratings.stars_enum_callback,
725 description='Rating stars 0 - 10',
726 default=None,
727 update=ratings.update_quality_ui,
730 rating_work_hours: FloatProperty(name="Work Hours",
731 description="How many hours did this work take?",
732 default=0.00,
733 min=0.0, max=150, update=ratings.update_ratings_work_hours
736 # rating_complexity: IntProperty(name="Complexity",
737 # description="Complexity is a number estimating how much work was spent on the asset.aaa",
738 # default=0, min=0, max=10)
739 # rating_virtual_price: FloatProperty(name="Virtual Price",
740 # description="How much would you pay for this object if buing it?",
741 # default=0, min=0, max=10000)
742 rating_problems: StringProperty(
743 name="Problems",
744 description="Problems found/ why did you take points down - this will be available for the author"
745 " As short as possible",
746 default="",
748 rating_compliments: StringProperty(
749 name="Compliments",
750 description="Comliments - let the author know you like his work! "
751 " As short as possible",
752 default="",
756 class BlenderKitMaterialSearchProps(PropertyGroup, BlenderKitCommonSearchProps):
757 search_keywords: StringProperty(
758 name="Search",
759 description="Search for these keywords",
760 default="",
761 update=search.search_update
763 search_style: EnumProperty(
764 name="Style",
765 items=search_material_styles,
766 description="Style of material",
767 default="ANY",
768 update=search.search_update,
770 search_style_other: StringProperty(
771 name="Style Other",
772 description="Style not in the list",
773 default="",
774 update=search.search_update,
776 search_engine: EnumProperty(
777 name='Engine',
778 items=engines,
779 default='NONE',
780 description='Output engine',
781 update=search.search_update,
783 search_engine_other: StringProperty(
784 name="Engine",
785 description="engine not specified by addon",
786 default="",
787 update=search.search_update,
789 append_method: EnumProperty(
790 name="Import Method",
791 items=(
792 ('LINK', 'Link', "Link Material - will be in external file and can't be directly edited"),
793 ('APPEND', 'Append', 'Append if you need to edit the material'),
795 description="Appended materials are editable in your scene. Linked assets are saved in original files, "
796 "aren't editable directly, but also don't increase your file size",
797 default="APPEND"
799 automap: BoolProperty(name="Auto-Map",
800 description="reset object texture space and also add automatically a cube mapped UV "
801 "to the object. \n this allows most materials to apply instantly to any mesh",
802 default=True)
805 class BlenderKitMaterialUploadProps(PropertyGroup, BlenderKitCommonUploadProps):
806 style: EnumProperty(
807 name="Style",
808 items=material_styles,
809 description="Style of material",
810 default="REALISTIC",
812 style_other: StringProperty(
813 name="Style Other",
814 description="Style not in the list",
815 default="",
817 engine: EnumProperty(
818 name='Engine',
819 items=engines,
820 default='CYCLES',
821 description='Output engine',
823 engine_other: StringProperty(
824 name="Engine Other",
825 description="engine not specified by addon",
826 default="",
829 shaders: StringProperty(
830 name="Shaders Used",
831 description="shaders used in asset, autofilled",
832 default="",
835 is_free: BoolProperty(name="Free for Everyone",
836 description="You consent you want to release this asset as free for everyone",
837 default=True, update=update_free
840 uv: BoolProperty(name="Needs UV", description="needs an UV set", default=False)
841 # printable_3d : BoolProperty( name = "3d printable", description = "can be 3d printed", default = False)
842 animated: BoolProperty(name="Animated", description="is animated", default=False)
843 texture_resolution_min: IntProperty(name="Texture Resolution Min", description="texture resolution minimum",
844 default=0)
845 texture_resolution_max: IntProperty(name="Texture Resolution Max", description="texture resolution maximum",
846 default=0)
848 texture_size_meters: FloatProperty(name="Texture Size in Meters", description="face count, autofilled",
849 default=1.0, min=0)
851 thumbnail_scale: FloatProperty(name="Thumbnail Object Size",
852 description="size of material preview object in meters "
853 "- change for materials that look better at sizes different than 1m",
854 default=1, min=0.00001, max=10)
855 thumbnail_background: BoolProperty(name="Thumbnail Background (for Glass only)",
856 description="For refractive materials, you might need a background. "
857 "Don't use if thumbnail looks good without it!",
858 default=False)
859 thumbnail_background_lightness: FloatProperty(name="Thumbnail Background Lightness",
860 description="set to make your material stand out", default=.9,
861 min=0.00001, max=1)
862 thumbnail_samples: IntProperty(name="Cycles Samples",
863 description="cycles samples setting", default=150,
864 min=5, max=5000)
865 thumbnail_denoising: BoolProperty(name="Use Denoising",
866 description="Use denoising", default=True)
867 adaptive_subdivision: BoolProperty(name="Adaptive Subdivide",
868 description="Use adaptive displacement subdivision", default=False)
870 thumbnail_resolution: EnumProperty(
871 name="Resolution",
872 items=thumbnail_resolutions,
873 description="Thumbnail resolution.",
874 default="512",
877 thumbnail_generator_type: EnumProperty(
878 name="Thumbnail Style",
879 items=(
880 ('BALL', 'Ball', ""),
881 ('BALL_COMPLEX', 'Ball complex', 'Complex ball to highlight edgewear or material thickness'),
882 ('FLUID', 'Fluid', 'Fluid'),
883 ('CLOTH', 'Cloth', 'Cloth'),
884 ('HAIR', 'Hair', 'Hair ')
886 description="Style of asset",
887 default="BALL",
890 thumbnail: StringProperty(
891 name="Thumbnail",
892 description="Path to the thumbnail - 512x512 .jpg image",
893 subtype='FILE_PATH',
894 default="",
895 update=autothumb.update_upload_material_preview)
897 is_generating_thumbnail: BoolProperty(name="Generating Thumbnail",
898 description="True when background process is running", default=False,
899 update=autothumb.update_upload_material_preview)
902 class BlenderKitTextureUploadProps(PropertyGroup, BlenderKitCommonUploadProps):
903 style: EnumProperty(
904 name="Style",
905 items=material_styles,
906 description="Style of texture",
907 default="REALISTIC",
909 style_other: StringProperty(
910 name="Style Other",
911 description="Style not in the list",
912 default="",
915 pbr: BoolProperty(name="PBR Compatible", description="Is compatible with PBR standard", default=False)
917 # printable_3d : BoolProperty( name = "3d printable", description = "can be 3d printed", default = False)
918 animated: BoolProperty(name="Animated", description="is animated", default=False)
919 resolution: IntProperty(name="Texture Resolution", description="texture resolution", default=0)
922 class BlenderKitBrushSearchProps(PropertyGroup, BlenderKitCommonSearchProps):
923 search_keywords: StringProperty(
924 name="Search",
925 description="Search for these keywords",
926 default="",
927 update=search.search_update
931 class BlenderKitHDRUploadProps(PropertyGroup, BlenderKitCommonUploadProps):
932 texture_resolution_max: IntProperty(name="Texture Resolution Max", description="texture resolution maximum",
933 default=0)
935 class BlenderKitBrushUploadProps(PropertyGroup, BlenderKitCommonUploadProps):
936 mode: EnumProperty(
937 name="Mode",
938 items=(
939 ('IMAGE', 'Texture paint', "Texture brush"),
940 ('SCULPT', 'Sculpt', 'Sculpt brush'),
941 ('VERTEX', 'Vertex paint', 'Vertex paint brush'),
942 ('WEIGHT', 'Weight paint', 'Weight paint brush'),
944 description="Mode where the brush works",
945 default="SCULPT",
949 # upload properties
950 class BlenderKitModelUploadProps(PropertyGroup, BlenderKitCommonUploadProps):
951 style: EnumProperty(
952 name="Style",
953 items=model_styles,
954 description="Style of asset",
955 default="REALISTIC",
957 style_other: StringProperty(
958 name="Style Other",
959 description="Style not in the list",
960 default="",
962 engine: EnumProperty(
963 name='Engine',
964 items=engines,
965 default='CYCLES',
966 description='Output engine',
969 production_level: EnumProperty(
970 name='Production Level',
971 items=(
972 ('FINISHED', 'Finished', 'Render or animation ready asset'),
973 ('TEMPLATE', 'Template', 'Asset intended to help in creation of something else'),
975 default='FINISHED',
976 description='Production state of the asset, \n also template should be actually finished, \n'
977 'just the nature of it can be a template, like a thumbnailer scene, \n '
978 'finished mesh topology as start for modelling or similar',
981 engine_other: StringProperty(
982 name="Engine",
983 description="engine not specified by addon",
984 default="",
987 engine1: EnumProperty(
988 name='2nd Engine',
989 items=engines,
990 default='NONE',
991 description='Output engine',
993 engine2: EnumProperty(
994 name='3rd Engine',
995 items=engines,
996 default='NONE',
997 description='Output engine',
999 engine3: EnumProperty(
1000 name='4th Engine',
1001 items=engines,
1002 default='NONE',
1003 description='Output engine',
1006 manufacturer: StringProperty(
1007 name="Manufacturer",
1008 description="Manufacturer, company making a design peace or product. Not you",
1009 default="",
1012 designer: StringProperty(
1013 name="Designer",
1014 description="Author of the original design piece depicted. Usually not you",
1015 default="",
1018 design_collection: StringProperty(
1019 name="Design Collection",
1020 description="Fill if this piece is part of a real world design collection",
1021 default="",
1024 design_variant: StringProperty(
1025 name="Variant",
1026 description="Colour or material variant of the product",
1027 default="",
1030 thumbnail: StringProperty(
1031 name="Thumbnail",
1032 description="Path to the thumbnail - 512x512 .jpg image",
1033 subtype='FILE_PATH',
1034 default="",
1035 update=autothumb.update_upload_model_preview)
1037 thumbnail_background_lightness: FloatProperty(name="Thumbnail Background Lightness",
1038 description="set to make your material stand out", default=1.0,
1039 min=0.01, max=10)
1041 thumbnail_angle: EnumProperty(
1042 name='Thumbnail Angle',
1043 items=thumbnail_angles,
1044 default='DEFAULT',
1045 description='thumbnailer angle',
1048 thumbnail_snap_to: EnumProperty(
1049 name='Model Snaps To:',
1050 items=thumbnail_snap,
1051 default='GROUND',
1052 description='typical placing of the interior. Leave on ground for most objects that respect gravity :)',
1055 thumbnail_resolution: EnumProperty(
1056 name="Resolution",
1057 items=thumbnail_resolutions,
1058 description="Thumbnail resolution.",
1059 default="512",
1062 thumbnail_samples: IntProperty(name="Cycles Samples",
1063 description="cycles samples setting", default=200,
1064 min=5, max=5000)
1065 thumbnail_denoising: BoolProperty(name="Use Denoising",
1066 description="Use denoising", default=True)
1068 use_design_year: BoolProperty(name="Use Design Year",
1069 description="When this thing came into world for the first time\n"
1070 " e.g. for dinosaur, you set -240 million years ;) ",
1071 default=False)
1072 design_year: IntProperty(name="Design Year", description="when was this item designed", default=1960)
1073 # use_age : BoolProperty( name = "use item age", description = "use item age", default = False)
1074 condition: EnumProperty(
1075 items=conditions,
1076 default='UNSPECIFIED',
1077 description='age of the object',
1080 adult: BoolProperty(name="Adult Content", description="adult content", default=False)
1082 work_hours: FloatProperty(name="Work Hours", description="How long did it take you to finish the asset?",
1083 default=0.0, min=0.0, max=8760)
1085 modifiers: StringProperty(
1086 name="Modifiers Used",
1087 description="if you need specific modifiers, autofilled",
1088 default="",
1091 materials: StringProperty(
1092 name="Material Names",
1093 description="names of materials in the file, autofilled",
1094 default="",
1096 shaders: StringProperty(
1097 name="Shaders Used",
1098 description="shaders used in asset, autofilled",
1099 default="",
1102 dimensions: FloatVectorProperty(
1103 name="Dimensions",
1104 description="dimensions of the whole asset hierarchy",
1105 default=(0, 0, 0),
1107 bbox_min: FloatVectorProperty(
1108 name="Bbox Min",
1109 description="dimensions of the whole asset hierarchy",
1110 default=(-.25, -.25, 0),
1112 bbox_max: FloatVectorProperty(
1113 name="Bbox Max",
1114 description="dimensions of the whole asset hierarchy",
1115 default=(.25, .25, .5),
1118 texture_resolution_min: IntProperty(name="Texture Resolution Min",
1119 description="texture resolution min, autofilled", default=0)
1120 texture_resolution_max: IntProperty(name="Texture Resolution Max",
1121 description="texture resolution max, autofilled", default=0)
1123 pbr: BoolProperty(name="PBR Compatible", description="Is compatible with PBR standard", default=False)
1125 uv: BoolProperty(name="Has UV", description="has an UV set", default=False)
1126 # printable_3d : BoolProperty( name = "3d printable", description = "can be 3d printed", default = False)
1127 animated: BoolProperty(name="Animated", description="is animated", default=False)
1128 face_count: IntProperty(name="Face count", description="face count, autofilled", default=0)
1129 face_count_render: IntProperty(name="Render Face Count", description="render face count, autofilled", default=0)
1131 object_count: IntProperty(name="Number of Objects", description="how many objects are in the asset, autofilled",
1132 default=0)
1133 mesh_poly_type: EnumProperty(
1134 name='Dominant Poly Type',
1135 items=mesh_poly_types,
1136 default='OTHER',
1137 description='',
1140 manifold: BoolProperty(name="Manifold", description="asset is manifold, autofilled", default=False)
1142 rig: BoolProperty(name="Rig", description="asset is rigged, autofilled", default=False)
1143 simulation: BoolProperty(name="Simulation", description="asset uses simulation, autofilled", default=False)
1145 filepath : StringProperty(
1146 name="Filepath",
1147 description="file path",
1148 default="",
1152 # THUMBNAIL STATES
1153 is_generating_thumbnail: BoolProperty(name="Generating Thumbnail",
1154 description="True when background process is running", default=False,
1155 update=autothumb.update_upload_model_preview)
1157 has_autotags: BoolProperty(name="Has Autotagging Done", description="True when autotagging done", default=False)
1160 class BlenderKitSceneUploadProps(PropertyGroup, BlenderKitCommonUploadProps):
1161 style: EnumProperty(
1162 name="Style",
1163 items=model_styles,
1164 description="Style of asset",
1165 default="REALISTIC",
1167 style_other: StringProperty(
1168 name="Style Other",
1169 description="Style not in the list",
1170 default="",
1172 engine: EnumProperty(
1173 name='Engine',
1174 items=engines,
1175 default='CYCLES',
1176 description='Output engine',
1179 production_level: EnumProperty(
1180 name='Production Level',
1181 items=(
1182 ('FINISHED', 'Finished', 'Render or animation ready asset'),
1183 ('TEMPLATE', 'Template', 'Asset intended to help in creation of something else'),
1185 default='FINISHED',
1186 description='Production state of the asset, \n also template should be actually finished, \n'
1187 'just the nature of it can be a template, like a thumbnailer scene, \n '
1188 'finished mesh topology as start for modelling or similar',
1191 engine_other: StringProperty(
1192 name="Engine",
1193 description="engine not specified by addon",
1194 default="",
1197 engine1: EnumProperty(
1198 name='2nd Engine',
1199 items=engines,
1200 default='NONE',
1201 description='Output engine',
1203 engine2: EnumProperty(
1204 name='3rd Engine',
1205 items=engines,
1206 default='NONE',
1207 description='Output engine',
1209 engine3: EnumProperty(
1210 name='4th Engine',
1211 items=engines,
1212 default='NONE',
1213 description='Output engine',
1216 thumbnail: StringProperty(
1217 name="Thumbnail",
1218 description="Path to the thumbnail - 512x512 .jpg image",
1219 subtype='FILE_PATH',
1220 default="",
1221 update=autothumb.update_upload_scene_preview)
1223 use_design_year: BoolProperty(name="Use Design Year",
1224 description="When this thing came into world for the first time\n"
1225 " e.g. for dinosaur, you set -240 million years ;) ",
1226 default=False)
1227 design_year: IntProperty(name="Design Year", description="when was this item designed", default=1960)
1228 # use_age : BoolProperty( name = "use item age", description = "use item age", default = False)
1229 condition: EnumProperty(
1230 items=conditions,
1231 default='UNSPECIFIED',
1232 description='age of the object',
1235 adult: BoolProperty(name="Adult Content", description="adult content", default=False)
1237 work_hours: FloatProperty(name="Work Hours", description="How long did it take you to finish the asset?",
1238 default=0.0, min=0.0, max=8760)
1240 modifiers: StringProperty(
1241 name="Modifiers Used",
1242 description="if you need specific modifiers, autofilled",
1243 default="",
1246 materials: StringProperty(
1247 name="Material Names",
1248 description="names of materials in the file, autofilled",
1249 default="",
1251 shaders: StringProperty(
1252 name="Shaders Used",
1253 description="shaders used in asset, autofilled",
1254 default="",
1257 dimensions: FloatVectorProperty(
1258 name="Dimensions",
1259 description="dimensions of the whole asset hierarchy",
1260 default=(0, 0, 0),
1262 bbox_min: FloatVectorProperty(
1263 name="Dimensions",
1264 description="dimensions of the whole asset hierarchy",
1265 default=(-.25, -.25, 0),
1267 bbox_max: FloatVectorProperty(
1268 name="Dimensions",
1269 description="dimensions of the whole asset hierarchy",
1270 default=(.25, .25, .5),
1273 texture_resolution_min: IntProperty(name="Texture Resolution Min",
1274 description="texture resolution min, autofilled", default=0)
1275 texture_resolution_max: IntProperty(name="Texture Resolution Max",
1276 description="texture resolution max, autofilled", default=0)
1278 pbr: BoolProperty(name="PBR Compatible", description="Is compatible with PBR standard", default=False)
1280 uv: BoolProperty(name="Has UV", description="has an UV set", default=False)
1281 # printable_3d : BoolProperty( name = "3d printable", description = "can be 3d printed", default = False)
1282 animated: BoolProperty(name="Animated", description="is animated", default=False)
1283 face_count: IntProperty(name="Face Count", description="face count, autofilled", default=0)
1284 face_count_render: IntProperty(name="Render Face Count", description="render face count, autofilled", default=0)
1286 object_count: IntProperty(name="Number of Objects", description="how many objects are in the asset, autofilled",
1287 default=0)
1288 mesh_poly_type: EnumProperty(
1289 name='Dominant Poly Type',
1290 items=mesh_poly_types,
1291 default='OTHER',
1292 description='',
1295 rig: BoolProperty(name="Rig", description="asset is rigged, autofilled", default=False)
1296 simulation: BoolProperty(name="Simulation", description="asset uses simulation, autofilled", default=False)
1298 # THUMBNAIL STATES
1299 is_generating_thumbnail: BoolProperty(name="Generating Thumbnail",
1300 description="True when background process is running", default=False,
1301 update=autothumb.update_upload_model_preview)
1303 has_autotags: BoolProperty(name="Has Autotagging Done", description="True when autotagging done", default=False)
1306 class BlenderKitModelSearchProps(PropertyGroup, BlenderKitCommonSearchProps):
1307 search_keywords: StringProperty(
1308 name="Search",
1309 description="Search for these keywords",
1310 default="",
1311 update=search.search_update
1313 search_style: EnumProperty(
1314 name="Style",
1315 items=search_model_styles,
1316 description="Keywords defining style (realistic, painted, polygonal, other)",
1317 default="ANY",
1318 update=search.search_update
1320 search_style_other: StringProperty(
1321 name="Style",
1322 description="Search style - other",
1323 default="",
1324 update=search.search_update
1326 search_engine: EnumProperty(
1327 items=engines,
1328 default='CYCLES',
1329 description='Output engine',
1330 update=search.search_update
1332 search_engine_other: StringProperty(
1333 name="Engine",
1334 description="Engine not specified by addon",
1335 default="",
1336 update=search.search_update
1340 # CONDITION
1341 search_condition: EnumProperty(
1342 items=conditions,
1343 default='UNSPECIFIED',
1344 description='Condition of the object',
1345 update=search.search_update
1348 search_adult: BoolProperty(
1349 name="Adult Content",
1350 description="You're adult and agree with searching adult content",
1351 default=False,
1352 update=search.search_update
1355 # DESIGN YEAR
1356 search_design_year: BoolProperty(name="Sesigned in Year",
1357 description="When the object was approximately designed",
1358 default=False,
1359 update=search.search_update,
1362 search_design_year_min: IntProperty(name="Minimum Design Year",
1363 description="Minimum design year",
1364 default=1950, min=-100000000, max=1000000000,
1365 update=search.search_update,
1368 search_design_year_max: IntProperty(name="Maximum Design Year",
1369 description="Maximum design year",
1370 default=2017,
1371 min=0,
1372 max=10000000,
1373 update=search.search_update,
1376 # POLYCOUNT
1377 search_polycount: BoolProperty(name="Use Polycount",
1378 description="Use polycount of object search tag",
1379 default=False,
1380 update=search.search_update, )
1382 search_polycount_min: IntProperty(name="Min Polycount",
1383 description="Minimum poly count of the asset",
1384 default=0,
1385 min=0,
1386 max=100000000,
1387 update=search.search_update, )
1389 search_polycount_max: IntProperty(name="Max Polycount",
1390 description="Maximum poly count of the asset",
1391 default=100000000,
1392 min=0,
1393 max=100000000,
1394 update=search.search_update,
1397 append_method: EnumProperty(
1398 name="Import Method",
1399 items=(
1400 ('LINK_COLLECTION', 'Link', 'Link Collection'),
1401 ('APPEND_OBJECTS', 'Append', 'Append as Objects'),
1403 description="Appended objects are editable in your scene. Linked assets are saved in original files, "
1404 "aren't editable but also don't increase your file size",
1405 default="LINK_COLLECTION"
1407 append_link: EnumProperty(
1408 name="How to Attach",
1409 items=(
1410 ('LINK', 'Link', ''),
1411 ('APPEND', 'Append', ''),
1413 description="choose if the assets will be linked or appended",
1414 default="LINK"
1416 import_as: EnumProperty(
1417 name="Import as",
1418 items=(
1419 ('GROUP', 'group', ''),
1420 ('INDIVIDUAL', 'objects', ''),
1423 description="choose if the assets will be linked or appended",
1424 default="GROUP"
1426 randomize_rotation: BoolProperty(name='Randomize Rotation',
1427 description="randomize rotation at placement",
1428 default=False)
1429 randomize_rotation_amount: FloatProperty(name="Randomization Max Angle",
1430 description="maximum angle for random rotation",
1431 default=math.pi / 36,
1432 min=0,
1433 max=2 * math.pi,
1434 subtype='ANGLE')
1435 offset_rotation_amount: FloatProperty(name="Offset Rotation",
1436 description="offset rotation, hidden prop",
1437 default=0,
1438 min=0,
1439 max=360,
1440 subtype='ANGLE')
1441 offset_rotation_step: FloatProperty(name="Offset Rotation Step",
1442 description="offset rotation, hidden prop",
1443 default=math.pi / 2,
1444 min=0,
1445 max=180,
1446 subtype='ANGLE')
1448 perpendicular_snap: BoolProperty(name='Perpendicular snap',
1449 description="Limit snapping that is close to perpendicular angles to be perpendicular.",
1450 default=True)
1452 perpendicular_snap_threshold: FloatProperty(name="Threshold",
1453 description="Limit perpendicular snap to be below these values.",
1454 default=.25,
1455 min=0,
1456 max=.5,
1460 class BlenderKitHDRSearchProps(PropertyGroup, BlenderKitCommonSearchProps):
1461 search_keywords: StringProperty(
1462 name="Search",
1463 description="Search for these keywords",
1464 default="",
1465 update=search.search_update
1469 class BlenderKitSceneSearchProps(PropertyGroup, BlenderKitCommonSearchProps):
1470 search_keywords: StringProperty(
1471 name="Search",
1472 description="Search for these keywords",
1473 default="",
1474 update=search.search_update
1476 search_style: EnumProperty(
1477 name="Style",
1478 items=search_model_styles,
1479 description="keywords defining style (realistic, painted, polygonal, other)",
1480 default="ANY",
1481 update=search.search_update
1483 search_style_other: StringProperty(
1484 name="Style",
1485 description="Search style - other",
1486 default="",
1487 update=search.search_update
1489 search_engine: EnumProperty(
1490 items=engines,
1491 default='CYCLES',
1492 description='Output engine',
1493 update=search.search_update
1495 search_engine_other: StringProperty(
1496 name="Engine",
1497 description="engine not specified by addon",
1498 default="",
1499 update=search.search_update
1503 def fix_subdir(self, context):
1504 '''Fixes project subdicrectory settings if people input invalid path.'''
1506 # pp = pathlib.PurePath(self.project_subdir)
1507 pp = self.project_subdir[:]
1508 pp = pp.replace('\\', '')
1509 pp = pp.replace('/', '')
1510 pp = pp.replace(':', '')
1511 pp = '//' + pp
1512 if self.project_subdir != pp:
1513 self.project_subdir = pp
1515 title = "Fixed to relative path"
1516 message = "This path should be always realative.\n" \
1517 " It's a directory BlenderKit creates where your .blend is \n " \
1518 "and uses it for storing assets."
1520 def draw_message(self, context):
1521 utils.label_multiline(self.layout, text=message, icon='NONE', width=400)
1523 bpy.context.window_manager.popup_menu(draw_message, title=title, icon='INFO')
1526 class BlenderKitAddonPreferences(AddonPreferences):
1527 # this must match the addon name, use '__package__'
1528 # when defining this in a submodule of a python package.
1529 bl_idname = __name__
1531 default_global_dict = paths.default_global_dict()
1533 enable_oauth = True
1535 api_key: StringProperty(
1536 name="BlenderKit API Key",
1537 description="Your blenderkit API Key. Get it from your page on the website",
1538 default="",
1539 subtype="PASSWORD",
1540 update=utils.save_prefs
1543 api_key_refresh: StringProperty(
1544 name="BlenderKit refresh API Key",
1545 description="API key used to refresh the token regularly.",
1546 default="",
1547 subtype="PASSWORD",
1550 api_key_timeout: IntProperty(
1551 name='api key timeout',
1552 description='time where the api key will need to be refreshed',
1553 default=0,
1556 api_key_life: IntProperty(
1557 name='api key life time',
1558 description='maximum lifetime of the api key, in seconds',
1559 default=0,
1562 refresh_in_progress: BoolProperty(
1563 name="Api key refresh in progress",
1564 description="Api key is currently being refreshed. Don't refresh it again.",
1565 default=False
1568 login_attempt: BoolProperty(
1569 name="Login/Signup attempt",
1570 description="When this is on, BlenderKit is trying to connect and login",
1571 default=False
1574 show_on_start: BoolProperty(
1575 name="Show assetbar when starting blender",
1576 description="Show assetbar when starting blender",
1577 default=False
1580 tips_on_start: BoolProperty(
1581 name="Show tips when starting blender",
1582 description="Show tips when starting blender",
1583 default=False
1586 search_in_header: BoolProperty(
1587 name="Show BlenderKit search in 3D view header",
1588 description="Show BlenderKit search in 3D view header",
1589 default=True
1592 global_dir: StringProperty(
1593 name="Global Files Directory",
1594 description="Global storage for your assets, will use subdirectories for the contents",
1595 subtype='DIR_PATH',
1596 default=default_global_dict,
1597 update=utils.save_prefs
1600 project_subdir: StringProperty(
1601 name="Project Assets Subdirectory",
1602 description="where data will be stored for individual projects",
1603 # subtype='DIR_PATH',
1604 default="//assets",
1605 update=fix_subdir
1608 directory_behaviour: EnumProperty(
1609 name="Use Directories",
1610 items=(
1611 ('BOTH', 'Global and subdir',
1612 'store files both in global lib and subdirectory of current project. '
1613 'Warning - each file can be many times on your harddrive, but helps you keep your projects in one piece'),
1614 ('GLOBAL', 'Global',
1615 "store downloaded files only in global directory. \n "
1616 "This can bring problems when moving your projects, \n"
1617 "since assets won't be in subdirectory of current project"),
1618 ('LOCAL', 'Local',
1619 'store downloaded files only in local directory.\n'
1620 ' This can use more bandwidth when you reuse assets in different projects. ')
1623 description="Which directories will be used for storing downloaded data",
1624 default="BOTH",
1626 thumbnail_use_gpu: BoolProperty(
1627 name="Use GPU for Thumbnails Rendering",
1628 description="By default this is off so you can continue your work without any lag",
1629 default=False
1632 panel_behaviour: EnumProperty(
1633 name="Panels Locations",
1634 items=(
1635 ('BOTH', 'Both Types',
1636 ''),
1637 ('UNIFIED', 'Unified 3D View Panel',
1638 ""),
1639 ('LOCAL', 'Relative to Data',
1643 description="Which directories will be used for storing downloaded data",
1644 default="UNIFIED",
1647 max_assetbar_rows: IntProperty(name="Max Assetbar Rows",
1648 description="max rows of assetbar in the 3D view",
1649 default=1,
1650 min=0,
1651 max=20)
1653 thumb_size: IntProperty(name="Assetbar thumbnail Size", default=96, min=-1, max=256)
1655 asset_counter: IntProperty(name="Usage Counter",
1656 description="Counts usages so it asks for registration only after reaching a limit",
1657 default=0,
1658 min=0,
1659 max=20000)
1661 # this is now made obsolete by the new popup upon registration -ensures the user knows about the first search.
1662 # first_run: BoolProperty(
1663 # name="First run",
1664 # description="Detects if addon was already registered/run.",
1665 # default=True,
1666 # update=utils.save_prefs
1669 use_timers: BoolProperty(
1670 name="Use timers",
1671 description="Use timers for BlenderKit. Usefull for debugging since timers seem to be unstable.",
1672 default=True,
1673 update=utils.save_prefs
1676 experimental_features: BoolProperty(
1677 name="Enable experimental features",
1678 description="Enable all experimental features of BlenderKit. Use at your own risk.",
1679 default=False,
1680 update=utils.save_prefs
1682 # allow_proximity : BoolProperty(
1683 # name="allow proximity data reports",
1684 # description="This sends anonymized proximity data \n \
1685 # and allows us to make relations between database objects \n \
1686 # without user interaction",
1687 # default=False
1690 def draw(self, context):
1691 layout = self.layout
1692 layout.prop(self, "show_on_start")
1694 if self.api_key.strip() == '':
1695 if self.enable_oauth:
1696 ui_panels.draw_login_buttons(layout)
1697 else:
1698 op = layout.operator("wm.url_open", text="Register online and get your API Key",
1699 icon='QUESTION')
1700 op.url = paths.BLENDERKIT_SIGNUP_URL
1701 else:
1702 if self.enable_oauth:
1703 layout.operator("wm.blenderkit_logout", text="Logout",
1704 icon='URL')
1706 # if not self.enable_oauth:
1707 layout.prop(self, "api_key", text='Your API Key')
1708 # layout.label(text='After you paste API Key, categories are downloaded, so blender will freeze for a few seconds.')
1709 layout.prop(self, "global_dir")
1710 layout.prop(self, "project_subdir")
1711 # layout.prop(self, "temp_dir")
1712 layout.prop(self, "directory_behaviour")
1713 layout.prop(self, "thumbnail_use_gpu")
1714 # layout.prop(self, "allow_proximity")
1715 # layout.prop(self, "panel_behaviour")
1716 layout.prop(self, "thumb_size")
1717 layout.prop(self, "max_assetbar_rows")
1718 layout.prop(self, "tips_on_start")
1719 layout.prop(self, "search_in_header")
1720 if bpy.context.preferences.view.show_developer_ui:
1721 layout.prop(self, "use_timers")
1722 layout.prop(self, "experimental_features")
1725 # registration
1726 classes = (
1728 BlenderKitAddonPreferences,
1729 BlenderKitUIProps,
1731 BlenderKitModelSearchProps,
1732 BlenderKitModelUploadProps,
1734 BlenderKitSceneSearchProps,
1735 BlenderKitSceneUploadProps,
1737 BlenderKitHDRSearchProps,
1738 BlenderKitHDRUploadProps,
1740 BlenderKitMaterialUploadProps,
1741 BlenderKitMaterialSearchProps,
1743 BlenderKitTextureUploadProps,
1745 BlenderKitBrushSearchProps,
1746 BlenderKitBrushUploadProps,
1748 BlenderKitRatingProps,
1752 def register():
1753 for cls in classes:
1754 bpy.utils.register_class(cls)
1756 bpy.types.Scene.blenderkitUI = PointerProperty(
1757 type=BlenderKitUIProps)
1759 # MODELS
1760 bpy.types.Scene.blenderkit_models = PointerProperty(
1761 type=BlenderKitModelSearchProps)
1762 bpy.types.Object.blenderkit = PointerProperty( # for uploads, not now...
1763 type=BlenderKitModelUploadProps)
1764 bpy.types.Object.bkit_ratings = PointerProperty( # for uploads, not now...
1765 type=BlenderKitRatingProps)
1767 # SCENES
1768 bpy.types.Scene.blenderkit_scene = PointerProperty(
1769 type=BlenderKitSceneSearchProps)
1770 bpy.types.Scene.blenderkit = PointerProperty( # for uploads, not now...
1771 type=BlenderKitSceneUploadProps)
1772 bpy.types.Scene.bkit_ratings = PointerProperty( # for uploads, not now...
1773 type=BlenderKitRatingProps)
1775 # HDRs
1776 bpy.types.Scene.blenderkit_HDR = PointerProperty(
1777 type=BlenderKitHDRSearchProps)
1778 bpy.types.Image.blenderkit = PointerProperty( # for uploads, not now...
1779 type=BlenderKitHDRUploadProps)
1780 bpy.types.Image.bkit_ratings = PointerProperty( # for uploads, not now...
1781 type=BlenderKitRatingProps)
1783 # MATERIALS
1784 bpy.types.Scene.blenderkit_mat = PointerProperty(
1785 type=BlenderKitMaterialSearchProps)
1786 bpy.types.Material.blenderkit = PointerProperty( # for uploads, not now...
1787 type=BlenderKitMaterialUploadProps)
1788 bpy.types.Material.bkit_ratings = PointerProperty( # for uploads, not now...
1789 type=BlenderKitRatingProps)
1791 # BRUSHES
1792 bpy.types.Scene.blenderkit_brush = PointerProperty(
1793 type=BlenderKitBrushSearchProps)
1794 bpy.types.Brush.blenderkit = PointerProperty( # for uploads, not now...
1795 type=BlenderKitBrushUploadProps)
1796 bpy.types.Brush.bkit_ratings = PointerProperty( # for uploads, not now...
1797 type=BlenderKitRatingProps)
1799 search.register_search()
1800 asset_inspector.register_asset_inspector()
1801 download.register_download()
1802 upload.register_upload()
1803 ratings.register_ratings()
1804 autothumb.register_thumbnailer()
1805 ui.register_ui()
1806 icons.register_icons()
1807 ui_panels.register_ui_panels()
1808 bg_blender.register()
1809 utils.load_prefs()
1810 overrides.register_overrides()
1811 bkit_oauth.register()
1812 tasks_queue.register()
1813 asset_bar_op.register()
1815 user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
1816 if user_preferences.use_timers:
1817 bpy.app.timers.register(check_timers_timer, persistent=True)
1819 bpy.app.handlers.load_post.append(scene_load)
1820 # detect if the user just enabled the addon in preferences, thus enable to run
1821 for w in bpy.context.window_manager.windows:
1822 for a in w.screen.areas:
1823 if a.type == 'PREFERENCES':
1824 tasks_queue.add_task((bpy.ops.wm.blenderkit_welcome, ('INVOKE_DEFAULT',)), fake_context=True,
1825 fake_context_area='PREFERENCES')
1828 def unregister():
1829 if bpy.app.timers.is_registered(check_timers_timer):
1830 bpy.app.timers.unregister(check_timers_timer)
1831 ui_panels.unregister_ui_panels()
1832 ui.unregister_ui()
1834 icons.unregister_icons()
1835 search.unregister_search()
1836 asset_inspector.unregister_asset_inspector()
1837 download.unregister_download()
1838 upload.unregister_upload()
1839 ratings.unregister_ratings()
1840 autothumb.unregister_thumbnailer()
1841 bg_blender.unregister()
1842 overrides.unregister_overrides()
1843 bkit_oauth.unregister()
1844 tasks_queue.unregister()
1845 asset_bar_op.unregister()
1847 del bpy.types.Scene.blenderkit_models
1848 del bpy.types.Scene.blenderkit_scene
1849 del bpy.types.Scene.blenderkit_HDR
1850 del bpy.types.Scene.blenderkit_brush
1851 del bpy.types.Scene.blenderkit_mat
1853 del bpy.types.Scene.blenderkit
1854 del bpy.types.Object.blenderkit
1855 del bpy.types.Image.blenderkit
1856 del bpy.types.Material.blenderkit
1857 del bpy.types.Brush.blenderkit
1859 for cls in classes:
1860 bpy.utils.unregister_class(cls)
1862 bpy.app.handlers.load_post.remove(scene_load)