Cleanup: simplify file name incrementing logic
[blender-addons.git] / blenderkit / __init__.py
blobb61861ee4a4a01f8fa95e7c90df23c7f0f21f868
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": (2, 92, 0),
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 print('loading in background')
142 print(bpy.context.window_manager)
143 if not bpy.app.background:
145 search.load_previews()
146 ui_props = bpy.context.scene.blenderkitUI
147 ui_props.assetbar_on = False
148 ui_props.turn_off = False
149 preferences = bpy.context.preferences.addons['blenderkit'].preferences
150 preferences.login_attempt = False
153 @bpy.app.handlers.persistent
154 def check_timers_timer():
155 ''' checks if all timers are registered regularly. Prevents possible bugs from stopping the addon.'''
156 if not bpy.app.timers.is_registered(search.timer_update):
157 bpy.app.timers.register(search.timer_update)
158 if not bpy.app.timers.is_registered(download.timer_update):
159 bpy.app.timers.register(download.timer_update)
160 if not (bpy.app.timers.is_registered(tasks_queue.queue_worker)):
161 bpy.app.timers.register(tasks_queue.queue_worker)
162 if not bpy.app.timers.is_registered(bg_blender.bg_update):
163 bpy.app.timers.register(bg_blender.bg_update)
164 return 5.0
168 conditions = (
169 ('UNSPECIFIED', 'Unspecified', "Don't use this in search"),
170 ('NEW', 'New', 'Shiny new item'),
171 ('USED', 'Used', 'Casually used item'),
172 ('OLD', 'Old', 'Old item'),
173 ('DESOLATE', 'Desolate', 'Desolate item - dusty & rusty'),
175 model_styles = (
176 ('REALISTIC', 'Realistic', "photo realistic model"),
177 ('PAINTERLY', 'Painterly', 'hand painted with visible strokes, mostly for games'),
178 ('LOWPOLY', 'Lowpoly', "Lowpoly art -don't mix up with polycount!"),
179 ('ANIME', 'Anime', 'Anime style'),
180 ('2D_VECTOR', '2D Vector', '2D vector'),
181 ('3D_GRAPHICS', '3D Graphics', '3D graphics'),
182 ('OTHER', 'Other', 'Other style'),
184 search_model_styles = (
185 ('REALISTIC', 'Realistic', "photo realistic model"),
186 ('PAINTERLY', 'Painterly', 'hand painted with visible strokes, mostly for games'),
187 ('LOWPOLY', 'Lowpoly', "Lowpoly art -don't mix up with polycount!"),
188 ('ANIME', 'Anime', 'Anime style'),
189 ('2D_VECTOR', '2D Vector', '2D vector'),
190 ('3D_GRAPHICS', '3D Graphics', '3D graphics'),
191 ('OTHER', 'Other', 'Other Style'),
192 ('ANY', 'Any', 'Any Style'),
194 material_styles = (
195 ('REALISTIC', 'Realistic', "photo realistic model"),
196 ('NPR', 'Non photorealistic', 'hand painted with visible strokes, mostly for games'),
197 ('OTHER', 'Other', 'Other style'),
199 search_material_styles = (
200 ('REALISTIC', 'Realistic', "photo realistic model"),
201 ('NPR', 'Non photorealistic', 'hand painted with visible strokes, mostly for games'),
202 ('ANY', 'Any', 'Any'),
204 engines = (
205 ('CYCLES', 'Cycles', 'blender cycles pathtracer'),
206 ('EEVEE', 'Eevee', 'blender eevee renderer'),
207 ('OCTANE', 'Octane', 'octane render enginge'),
208 ('ARNOLD', 'Arnold', 'arnold render engine'),
209 ('V-RAY', 'V-Ray', 'V-Ray renderer'),
210 ('UNREAL', 'Unreal', 'Unreal engine'),
211 ('UNITY', 'Unity', 'Unity engine'),
212 ('GODOT', 'Godot', 'Godot engine'),
213 ('3D-PRINT', '3D printer', 'object can be 3D printed'),
214 ('OTHER', 'Other', 'any other engine'),
215 ('NONE', 'None', 'no more engine block'),
217 pbr_types = (
218 ('METALLIC', 'Metallic-Roughness', 'Metallic/Roughness PBR material type'),
219 ('SPECULAR', 'Specular Glossy', ''),
222 mesh_poly_types = (
223 ('QUAD', 'quad', ''),
224 ('QUAD_DOMINANT', 'quad_dominant', ''),
225 ('TRI_DOMINANT', 'tri_dominant', ''),
226 ('TRI', 'tri', ''),
227 ('NGON', 'ngon_dominant', ''),
228 ('OTHER', 'other', ''),
231 thumbnail_angles = (
232 ('DEFAULT', 'default', ''),
233 ('FRONT', 'front', ''),
234 ('SIDE', 'side', ''),
235 ('TOP', 'top', ''),
238 thumbnail_snap = (
239 ('GROUND', 'ground', ''),
240 ('WALL', 'wall', ''),
241 ('CEILING', 'ceiling', ''),
242 ('FLOAT', 'floating', ''),
245 thumbnail_resolutions = (
246 ('256', '256', ''),
247 ('512', '512 - minimum for public', ''),
248 ('1024', '1024', ''),
249 ('2048', '2048', ''),
252 def udate_down_up(self, context):
253 """Perform a search if results are empty."""
254 s = context.scene
255 wm = bpy.context.window_manager
256 props = s.blenderkitUI
257 if wm.get('search results') == None and props.down_up == 'SEARCH':
258 search.search()
260 def switch_search_results(self, context):
261 s = bpy.context.scene
262 wm = bpy.context.window_manager
263 props = s.blenderkitUI
264 if props.asset_type == 'MODEL':
265 wm['search results'] = wm.get('bkit model search')
266 wm['search results orig'] = wm.get('bkit model search orig')
267 elif props.asset_type == 'SCENE':
268 wm['search results'] = wm.get('bkit scene search')
269 wm['search results orig'] = wm.get('bkit scene search orig')
270 elif props.asset_type == 'HDR':
271 wm['search results'] = wm.get('bkit hdr search')
272 wm['search results orig'] = wm.get('bkit hdr search orig')
273 elif props.asset_type == 'MATERIAL':
274 wm['search results'] = wm.get('bkit material search')
275 wm['search results orig'] = wm.get('bkit material search orig')
276 elif props.asset_type == 'TEXTURE':
277 wm['search results'] = wm.get('bkit texture search')
278 wm['search results orig'] = wm.get('bkit texture search orig')
279 elif props.asset_type == 'BRUSH':
280 wm['search results'] = wm.get('bkit brush search')
281 wm['search results orig'] = wm.get('bkit brush search orig')
282 if not(context.sculpt_object or context.image_paint_object):
283 ui.add_report(
284 'Switch to paint or sculpt mode to search in BlenderKit brushes.')
286 search.load_previews()
287 if wm['search results'] == None and props.down_up == 'SEARCH':
288 search.search()
292 def asset_type_callback(self, context):
294 Returns
295 items for Enum property, depending on the down_up property - BlenderKit is either in search or in upload mode.
298 user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
300 if self.down_up == 'SEARCH':
301 items = (
302 ('MODEL', 'Models', 'Find models in the BlenderKit online database', 'OBJECT_DATAMODE', 0),
303 ('MATERIAL', 'Materials', 'Find materials in the BlenderKit online database', 'MATERIAL', 2),
304 # ('TEXTURE', 'Texture', 'Browse textures', 'TEXTURE', 3),
305 ('SCENE', 'Scenes', 'Browse scenes', 'SCENE_DATA', 3),
306 ('HDR', 'Hdrs', 'Browse hdrs', 'WORLD', 4),
307 ('BRUSH', 'Brushes', 'Find brushes in the BlenderKit online database', 'BRUSH_DATA', 5)
309 else:
310 items = (
311 ('MODEL', 'Model', 'Upload a model to BlenderKit', 'OBJECT_DATAMODE', 0),
312 # ('SCENE', 'SCENE', 'Browse scenes', 'SCENE_DATA', 1),
313 ('MATERIAL', 'Material', 'Upload a material to BlenderKit', 'MATERIAL', 2),
314 # ('TEXTURE', 'Texture', 'Browse textures', 'TEXTURE', 3),
315 ('SCENE', 'Scenes', 'Browse scenes', 'SCENE_DATA', 3),
316 ('HDR', 'Hdrs', 'Browse hdrs', 'WORLD', 4),
317 ('BRUSH', 'Brush', 'Upload a brush to BlenderKit', 'BRUSH_DATA', 5)
320 return items
323 class BlenderKitUIProps(PropertyGroup):
324 down_up: EnumProperty(
325 name="Download vs Upload",
326 items=(
327 ('SEARCH', 'Search', 'Sctivate searching', 'VIEWZOOM', 0),
328 ('UPLOAD', 'Upload', 'Activate uploading', 'COPYDOWN', 1),
329 # ('RATING', 'Rating', 'Activate rating', 'SOLO_ON', 2)
331 description="BLenderKit",
332 default="SEARCH",
333 update = udate_down_up
335 asset_type: EnumProperty(
336 name="BlenderKit Active Asset Type",
337 items=asset_type_callback,
338 description="Activate asset in UI",
339 default=None,
340 update=switch_search_results
342 # these aren't actually used ( by now, seems to better use globals in UI module:
343 draw_tooltip: BoolProperty(name="Draw Tooltip", default=False)
344 addon_update: BoolProperty(name="Should Update Addon", default=False)
345 tooltip: StringProperty(
346 name="Tooltip",
347 description="asset preview info",
348 default="")
350 ui_scale = 1
352 thumb_size_def = 96
353 margin_def = 0
355 thumb_size: IntProperty(name="Thumbnail Size", default=thumb_size_def, min=-1, max=256)
357 margin: IntProperty(name="Margin", default=margin_def, min=-1, max=256)
358 highlight_margin: IntProperty(name="Highlight Margin", default=int(margin_def / 2), min=-10, max=256)
360 bar_height: IntProperty(name="Bar Height", default=thumb_size_def + 2 * margin_def, min=-1, max=2048)
361 bar_x_offset: IntProperty(name="Bar X Offset", default=20, min=0, max=5000)
362 bar_y_offset: IntProperty(name="Bar Y Offset", default=80, min=0, max=5000)
364 bar_x: IntProperty(name="Bar X", default=100, min=0, max=5000)
365 bar_y: IntProperty(name="Bar Y", default=100, min=50, max=5000)
366 bar_end: IntProperty(name="Bar End", default=100, min=0, max=5000)
367 bar_width: IntProperty(name="Bar Width", default=100, min=0, max=5000)
369 wcount: IntProperty(name="Width Count", default=10, min=0, max=5000)
370 hcount: IntProperty(name="Rows", default=5, min=0, max=5000)
372 reports_y: IntProperty(name="Reports Y", default=5, min=0, max=5000)
373 reports_x: IntProperty(name="Reports X", default=5, min=0, max=5000)
375 assetbar_on: BoolProperty(name="Assetbar On", default=False)
376 turn_off: BoolProperty(name="Turn Off", default=False)
378 mouse_x: IntProperty(name="Mouse X", default=0)
379 mouse_y: IntProperty(name="Mouse Y", default=0)
381 active_index: IntProperty(name="Active Index", default=-3)
382 scrolloffset: IntProperty(name="Scroll Offset", default=0)
383 drawoffset: IntProperty(name="Draw Offset", default=0)
385 dragging: BoolProperty(name="Dragging", default=False)
386 drag_init: BoolProperty(name="Drag Initialisation", default=False)
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", description="Search only for your assets",
461 default=False, update=search.search_update)
462 search_advanced: BoolProperty(name="Advanced Search Options", description="use advanced search properties",
463 default=False, update=search.search_update)
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="Span of the 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="Span of the 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', 'Calidated'),
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)
574 def name_update(self, context):
575 ''' checks for name change, because it decides if whole asset has to be re-uploaded. Name is stored in the blend file
576 and that's the reason.'''
577 utils.name_update(self)
582 def update_free(self, context):
583 if self.is_free == False:
584 self.is_free = True
585 ui_panels.ui_message(title = "All BlenderKit materials are free",
586 message = "Any material uploaded to BlenderKit is free." \
587 " However, it can still earn money for the author," \
588 " based on our fair share system. " \
589 "Part of subscription is sent to artists based on usage by paying users.")
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="APPEND_OBJECTS"
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
1501 append_link: EnumProperty(
1502 name="Append or link",
1503 items=(
1504 ('LINK', 'Link', ''),
1505 ('APPEND', 'Append', ''),
1507 description="choose if the scene will be linked or appended",
1508 default="APPEND"
1510 switch_after_append: BoolProperty(
1511 name = 'Switch to scene after download',
1512 default = False
1515 def fix_subdir(self, context):
1516 '''Fixes project subdicrectory settings if people input invalid path.'''
1518 # pp = pathlib.PurePath(self.project_subdir)
1519 pp = self.project_subdir[:]
1520 pp = pp.replace('\\', '')
1521 pp = pp.replace('/', '')
1522 pp = pp.replace(':', '')
1523 pp = '//' + pp
1524 if self.project_subdir != pp:
1525 self.project_subdir = pp
1527 ui_panels.ui_message(title = "Fixed to relative path",
1528 message = "This path should be always realative.\n" \
1529 " It's a directory BlenderKit creates where your .blend is \n " \
1530 "and uses it for storing assets.")
1534 class BlenderKitAddonPreferences(AddonPreferences):
1535 # this must match the addon name, use '__package__'
1536 # when defining this in a submodule of a python package.
1537 bl_idname = __name__
1539 default_global_dict = paths.default_global_dict()
1541 enable_oauth = True
1543 api_key: StringProperty(
1544 name="BlenderKit API Key",
1545 description="Your blenderkit API Key. Get it from your page on the website",
1546 default="",
1547 subtype="PASSWORD",
1548 update=utils.save_prefs
1551 api_key_refresh: StringProperty(
1552 name="BlenderKit refresh API Key",
1553 description="API key used to refresh the token regularly",
1554 default="",
1555 subtype="PASSWORD",
1558 api_key_timeout: IntProperty(
1559 name='api key timeout',
1560 description='time where the api key will need to be refreshed',
1561 default=0,
1564 api_key_life: IntProperty(
1565 name='api key life time',
1566 description='maximum lifetime of the api key, in seconds',
1567 default=0,
1570 refresh_in_progress: BoolProperty(
1571 name="Api key refresh in progress",
1572 description="Api key is currently being refreshed. Don't refresh it again",
1573 default=False
1576 login_attempt: BoolProperty(
1577 name="Login/Signup attempt",
1578 description="When this is on, BlenderKit is trying to connect and login",
1579 default=False
1582 show_on_start: BoolProperty(
1583 name="Show assetbar when starting blender",
1584 description="Show assetbar when starting blender",
1585 default=False
1588 tips_on_start: BoolProperty(
1589 name="Show tips when starting blender",
1590 description="Show tips when starting blender",
1591 default=False
1594 search_in_header: BoolProperty(
1595 name="Show BlenderKit search in 3D view header",
1596 description="Show BlenderKit search in 3D view header",
1597 default=True
1600 global_dir: StringProperty(
1601 name="Global Files Directory",
1602 description="Global storage for your assets, will use subdirectories for the contents",
1603 subtype='DIR_PATH',
1604 default=default_global_dict,
1605 update=utils.save_prefs
1608 project_subdir: StringProperty(
1609 name="Project Assets Subdirectory",
1610 description="where data will be stored for individual projects",
1611 # subtype='DIR_PATH',
1612 default="//assets",
1613 update=fix_subdir
1616 directory_behaviour: EnumProperty(
1617 name="Use Directories",
1618 items=(
1619 ('BOTH', 'Global and subdir',
1620 'store files both in global lib and subdirectory of current project. '
1621 'Warning - each file can be many times on your harddrive, but helps you keep your projects in one piece'),
1622 ('GLOBAL', 'Global',
1623 "store downloaded files only in global directory. \n "
1624 "This can bring problems when moving your projects, \n"
1625 "since assets won't be in subdirectory of current project"),
1626 ('LOCAL', 'Local',
1627 'store downloaded files only in local directory.\n'
1628 ' This can use more bandwidth when you reuse assets in different projects. ')
1631 description="Which directories will be used for storing downloaded data",
1632 default="BOTH",
1634 thumbnail_use_gpu: BoolProperty(
1635 name="Use GPU for Thumbnails Rendering",
1636 description="By default this is off so you can continue your work without any lag",
1637 default=False
1640 panel_behaviour: EnumProperty(
1641 name="Panels Locations",
1642 items=(
1643 ('BOTH', 'Both Types',
1644 ''),
1645 ('UNIFIED', 'Unified 3D View Panel',
1646 ""),
1647 ('LOCAL', 'Relative to Data',
1651 description="Which directories will be used for storing downloaded data",
1652 default="UNIFIED",
1655 max_assetbar_rows: IntProperty(name="Max Assetbar Rows",
1656 description="max rows of assetbar in the 3D view",
1657 default=1,
1658 min=0,
1659 max=20)
1661 thumb_size: IntProperty(name="Assetbar thumbnail Size", default=96, min=-1, max=256)
1663 asset_counter: IntProperty(name="Usage Counter",
1664 description="Counts usages so it asks for registration only after reaching a limit",
1665 default=0,
1666 min=0,
1667 max=20000)
1669 # this is now made obsolete by the new popup upon registration -ensures the user knows about the first search.
1670 # first_run: BoolProperty(
1671 # name="First run",
1672 # description="Detects if addon was already registered/run.",
1673 # default=True,
1674 # update=utils.save_prefs
1677 use_timers: BoolProperty(
1678 name="Use timers",
1679 description="Use timers for BlenderKit. Usefull for debugging since timers seem to be unstable",
1680 default=True,
1681 update=utils.save_prefs
1684 experimental_features: BoolProperty(
1685 name="Enable experimental features",
1686 description="Enable all experimental features of BlenderKit. Use at your own risk.",
1687 default=False,
1688 update=utils.save_prefs
1690 # allow_proximity : BoolProperty(
1691 # name="allow proximity data reports",
1692 # description="This sends anonymized proximity data \n \
1693 # and allows us to make relations between database objects \n \
1694 # without user interaction",
1695 # default=False
1698 def draw(self, context):
1699 layout = self.layout
1700 layout.prop(self, "show_on_start")
1702 if self.api_key.strip() == '':
1703 if self.enable_oauth:
1704 ui_panels.draw_login_buttons(layout)
1705 else:
1706 op = layout.operator("wm.url_open", text="Register online and get your API Key",
1707 icon='QUESTION')
1708 op.url = paths.BLENDERKIT_SIGNUP_URL
1709 else:
1710 if self.enable_oauth:
1711 layout.operator("wm.blenderkit_logout", text="Logout",
1712 icon='URL')
1714 # if not self.enable_oauth:
1715 layout.prop(self, "api_key", text='Your API Key')
1716 # layout.label(text='After you paste API Key, categories are downloaded, so blender will freeze for a few seconds.')
1717 layout.prop(self, "global_dir")
1718 layout.prop(self, "project_subdir")
1719 # layout.prop(self, "temp_dir")
1720 layout.prop(self, "directory_behaviour")
1721 layout.prop(self, "thumbnail_use_gpu")
1722 # layout.prop(self, "allow_proximity")
1723 # layout.prop(self, "panel_behaviour")
1724 layout.prop(self, "thumb_size")
1725 layout.prop(self, "max_assetbar_rows")
1726 layout.prop(self, "tips_on_start")
1727 layout.prop(self, "search_in_header")
1728 if bpy.context.preferences.view.show_developer_ui:
1729 layout.prop(self, "use_timers")
1730 layout.prop(self, "experimental_features")
1733 # registration
1734 classes = (
1736 BlenderKitAddonPreferences,
1737 BlenderKitUIProps,
1739 BlenderKitModelSearchProps,
1740 BlenderKitModelUploadProps,
1742 BlenderKitSceneSearchProps,
1743 BlenderKitSceneUploadProps,
1745 BlenderKitHDRSearchProps,
1746 BlenderKitHDRUploadProps,
1748 BlenderKitMaterialUploadProps,
1749 BlenderKitMaterialSearchProps,
1751 BlenderKitTextureUploadProps,
1753 BlenderKitBrushSearchProps,
1754 BlenderKitBrushUploadProps,
1756 BlenderKitRatingProps,
1760 def register():
1761 for cls in classes:
1762 bpy.utils.register_class(cls)
1764 bpy.types.Scene.blenderkitUI = PointerProperty(
1765 type=BlenderKitUIProps)
1767 # MODELS
1768 bpy.types.Scene.blenderkit_models = PointerProperty(
1769 type=BlenderKitModelSearchProps)
1770 bpy.types.Object.blenderkit = PointerProperty( # for uploads, not now...
1771 type=BlenderKitModelUploadProps)
1772 bpy.types.Object.bkit_ratings = PointerProperty( # for uploads, not now...
1773 type=BlenderKitRatingProps)
1775 # SCENES
1776 bpy.types.Scene.blenderkit_scene = PointerProperty(
1777 type=BlenderKitSceneSearchProps)
1778 bpy.types.Scene.blenderkit = PointerProperty( # for uploads, not now...
1779 type=BlenderKitSceneUploadProps)
1780 bpy.types.Scene.bkit_ratings = PointerProperty( # for uploads, not now...
1781 type=BlenderKitRatingProps)
1783 # HDRs
1784 bpy.types.Scene.blenderkit_HDR = PointerProperty(
1785 type=BlenderKitHDRSearchProps)
1786 bpy.types.Image.blenderkit = PointerProperty( # for uploads, not now...
1787 type=BlenderKitHDRUploadProps)
1788 bpy.types.Image.bkit_ratings = PointerProperty( # for uploads, not now...
1789 type=BlenderKitRatingProps)
1791 # MATERIALS
1792 bpy.types.Scene.blenderkit_mat = PointerProperty(
1793 type=BlenderKitMaterialSearchProps)
1794 bpy.types.Material.blenderkit = PointerProperty( # for uploads, not now...
1795 type=BlenderKitMaterialUploadProps)
1796 bpy.types.Material.bkit_ratings = PointerProperty( # for uploads, not now...
1797 type=BlenderKitRatingProps)
1799 # BRUSHES
1800 bpy.types.Scene.blenderkit_brush = PointerProperty(
1801 type=BlenderKitBrushSearchProps)
1802 bpy.types.Brush.blenderkit = PointerProperty( # for uploads, not now...
1803 type=BlenderKitBrushUploadProps)
1804 bpy.types.Brush.bkit_ratings = PointerProperty( # for uploads, not now...
1805 type=BlenderKitRatingProps)
1807 search.register_search()
1808 asset_inspector.register_asset_inspector()
1809 download.register_download()
1810 upload.register_upload()
1811 ratings.register_ratings()
1812 autothumb.register_thumbnailer()
1813 ui.register_ui()
1814 icons.register_icons()
1815 ui_panels.register_ui_panels()
1816 bg_blender.register()
1817 utils.load_prefs()
1818 overrides.register_overrides()
1819 bkit_oauth.register()
1820 tasks_queue.register()
1821 asset_bar_op.register()
1823 user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
1824 if user_preferences.use_timers:
1825 bpy.app.timers.register(check_timers_timer, persistent=True)
1827 bpy.app.handlers.load_post.append(scene_load)
1828 # detect if the user just enabled the addon in preferences, thus enable to run
1829 for w in bpy.context.window_manager.windows:
1830 for a in w.screen.areas:
1831 if a.type == 'PREFERENCES':
1832 tasks_queue.add_task((bpy.ops.wm.blenderkit_welcome, ('INVOKE_DEFAULT',)), fake_context=True,
1833 fake_context_area='PREFERENCES')
1836 def unregister():
1837 if bpy.app.timers.is_registered(check_timers_timer):
1838 bpy.app.timers.unregister(check_timers_timer)
1839 ui_panels.unregister_ui_panels()
1840 ui.unregister_ui()
1842 icons.unregister_icons()
1843 search.unregister_search()
1844 asset_inspector.unregister_asset_inspector()
1845 download.unregister_download()
1846 upload.unregister_upload()
1847 ratings.unregister_ratings()
1848 autothumb.unregister_thumbnailer()
1849 bg_blender.unregister()
1850 overrides.unregister_overrides()
1851 bkit_oauth.unregister()
1852 tasks_queue.unregister()
1853 asset_bar_op.unregister()
1855 del bpy.types.Scene.blenderkit_models
1856 del bpy.types.Scene.blenderkit_scene
1857 del bpy.types.Scene.blenderkit_HDR
1858 del bpy.types.Scene.blenderkit_brush
1859 del bpy.types.Scene.blenderkit_mat
1861 del bpy.types.Scene.blenderkit
1862 del bpy.types.Object.blenderkit
1863 del bpy.types.Image.blenderkit
1864 del bpy.types.Material.blenderkit
1865 del bpy.types.Brush.blenderkit
1867 for cls in classes:
1868 bpy.utils.unregister_class(cls)
1870 bpy.app.handlers.load_post.remove(scene_load)