Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVilém Duha <vilda.novak@gmail.com>2021-03-16 23:54:43 +0300
committerVilém Duha <vilda.novak@gmail.com>2021-03-16 23:54:43 +0300
commite24ff87b48445467f673641504fde759da531148 (patch)
tree17cd0001157aee43ef7cd5e59313ca648d672560
parentd00a25d34fca36687a29aaa6a653c32505c22b36 (diff)
BlenderKit: improve upload interface
Fixed quite a lot of tooltips Brought back a prompt for users to fill in data of the assets. This was accidentally disabled made the asset type enum foldable - takes too much space.
-rw-r--r--blenderkit/__init__.py97
-rw-r--r--blenderkit/ui.py1
-rw-r--r--blenderkit/ui_panels.py86
-rw-r--r--blenderkit/upload.py142
-rw-r--r--blenderkit/upload_bg.py13
5 files changed, 183 insertions, 156 deletions
diff --git a/blenderkit/__init__.py b/blenderkit/__init__.py
index 8f1fd0c6..89ef5e62 100644
--- a/blenderkit/__init__.py
+++ b/blenderkit/__init__.py
@@ -30,7 +30,8 @@ bl_info = {
if "bpy" in locals():
from importlib import reload
- #alphabetically sorted all add-on modules since reload only happens from __init__.
+
+ # alphabetically sorted all add-on modules since reload only happens from __init__.
# modules with _bg are used for background computations in separate blender instance and that's why they don't need reload.
append_link = reload(append_link)
@@ -100,7 +101,6 @@ else:
from blenderkit.bl_ui_widgets import bl_ui_draw_op
# from blenderkit.bl_ui_widgets import bl_ui_textbox
-
import os
import math
import time
@@ -110,7 +110,6 @@ import pathlib
log = logging.getLogger(__name__)
-
from bpy.app.handlers import persistent
import bpy.utils.previews
import mathutils
@@ -141,7 +140,6 @@ def scene_load(context):
print('loading in background')
print(bpy.context.window_manager)
if not bpy.app.background:
-
search.load_previews()
ui_props = bpy.context.scene.blenderkitUI
ui_props.assetbar_on = False
@@ -164,7 +162,6 @@ def check_timers_timer():
return 5.0
-
conditions = (
('UNSPECIFIED', 'Unspecified', "Don't use this in search"),
('NEW', 'New', 'Shiny new item'),
@@ -249,6 +246,7 @@ thumbnail_resolutions = (
('2048', '2048', ''),
)
+
def udate_down_up(self, context):
"""Perform a search if results are empty."""
s = context.scene
@@ -257,6 +255,7 @@ def udate_down_up(self, context):
if wm.get('search results') == None and props.down_up == 'SEARCH':
search.search()
+
def switch_search_results(self, context):
s = bpy.context.scene
wm = bpy.context.window_manager
@@ -279,7 +278,7 @@ def switch_search_results(self, context):
elif props.asset_type == 'BRUSH':
wm['search results'] = wm.get('bkit brush search')
wm['search results orig'] = wm.get('bkit brush search orig')
- if not(context.sculpt_object or context.image_paint_object):
+ if not (context.sculpt_object or context.image_paint_object):
ui.add_report(
'Switch to paint or sculpt mode to search in BlenderKit brushes.')
@@ -288,7 +287,6 @@ def switch_search_results(self, context):
search.search()
-
def asset_type_callback(self, context):
'''
Returns
@@ -303,7 +301,7 @@ def asset_type_callback(self, context):
('MATERIAL', 'Materials', 'Find materials in the BlenderKit online database', 'MATERIAL', 2),
# ('TEXTURE', 'Texture', 'Browse textures', 'TEXTURE', 3),
('SCENE', 'Scenes', 'Browse scenes', 'SCENE_DATA', 3),
- ('HDR', 'Hdrs', 'Browse hdrs', 'WORLD', 4),
+ ('HDR', 'HDRs', 'Browse HDRs', 'WORLD', 4),
('BRUSH', 'Brushes', 'Find brushes in the BlenderKit online database', 'BRUSH_DATA', 5)
)
else:
@@ -313,7 +311,7 @@ def asset_type_callback(self, context):
('MATERIAL', 'Material', 'Upload a material to BlenderKit', 'MATERIAL', 2),
# ('TEXTURE', 'Texture', 'Browse textures', 'TEXTURE', 3),
('SCENE', 'Scenes', 'Browse scenes', 'SCENE_DATA', 3),
- ('HDR', 'Hdrs', 'Browse hdrs', 'WORLD', 4),
+ ('HDR', 'HDRs', 'Browse HDRs', 'WORLD', 4),
('BRUSH', 'Brush', 'Upload a brush to BlenderKit', 'BRUSH_DATA', 5)
)
@@ -330,7 +328,7 @@ class BlenderKitUIProps(PropertyGroup):
),
description="BLenderKit",
default="SEARCH",
- update = udate_down_up
+ update=udate_down_up
)
asset_type: EnumProperty(
name="BlenderKit Active Asset Type",
@@ -339,6 +337,8 @@ class BlenderKitUIProps(PropertyGroup):
default=None,
update=switch_search_results
)
+
+ asset_type_expand: BoolProperty(name="Expand asset types", default=False)
# these aren't actually used ( by now, seems to better use globals in UI module:
draw_tooltip: BoolProperty(name="Draw Tooltip", default=False)
addon_update: BoolProperty(name="Should Update Addon", default=False)
@@ -577,16 +577,14 @@ def name_update(self, context):
utils.name_update(self)
-
-
def update_free(self, context):
- if self.is_free == False:
- self.is_free = True
- ui_panels.ui_message(title = "All BlenderKit materials are free",
- message = "Any material uploaded to BlenderKit is free." \
- " However, it can still earn money for the author," \
- " based on our fair share system. " \
- "Part of subscription is sent to artists based on usage by paying users.")
+ if self.is_free == 'FULL':
+ self.is_free = 'FREE'
+ ui_panels.ui_message(title="All BlenderKit materials are free",
+ message="Any material uploaded to BlenderKit is free." \
+ " However, it can still earn money for the author," \
+ " based on our fair share system. " \
+ "Part of subscription is sent to artists based on usage by paying users.\n")
class BlenderKitCommonUploadProps(object):
@@ -667,9 +665,15 @@ class BlenderKitCommonUploadProps(object):
# "Private assets are limited by quota",
# default=False)
- is_free: BoolProperty(name="Free for Everyone",
- description="You consent you want to release this asset as free for everyone",
- default=False)
+ is_free: EnumProperty(
+ name="Thumbnail Style",
+ items=(
+ ('FREE', 'Free', "You consent you want to release this asset as free for everyone."),
+ ('FULL', 'Full', "Your asset will be only available for subscribers")
+ ),
+ description="Assets can be in Free or in Full plan. Also free assets generate credits.",
+ default="FULL",
+ )
uploading: BoolProperty(name="Uploading",
description="True when background process is running",
@@ -686,7 +690,7 @@ class BlenderKitCommonUploadProps(object):
thumbnail_generating_state: StringProperty(
name="Thumbnail Generating State",
description="bg process reports for thumbnail generation",
- default='Please add thumbnail(jpg, at least 512x512)')
+ default='Please add thumbnail(jpg or png, at least 512x512)')
report: StringProperty(
name="Missing Upload Properties",
@@ -832,10 +836,19 @@ class BlenderKitMaterialUploadProps(PropertyGroup, BlenderKitCommonUploadProps):
default="",
)
- is_free: BoolProperty(name="Free for Everyone",
- description="You consent you want to release this asset as free for everyone",
- default=True, update=update_free
- )
+ is_free: EnumProperty(
+ name="Thumbnail Style",
+ items=(
+ ('FREE', 'Free', "You consent you want to release this asset as free for everyone."),
+ ('FULL', 'Full', "Your asset will be only available for subscribers.")
+ ),
+ description="Assets can be in Free or in Full plan. Also free assets generate credits. \n"
+ "All BlenderKit materials are free.",
+ default="FREE",
+ update=update_free
+ )
+
+
uv: BoolProperty(name="Needs UV", description="needs an UV set", default=False)
# printable_3d : BoolProperty( name = "3d printable", description = "can be 3d printed", default = False)
@@ -889,7 +902,9 @@ class BlenderKitMaterialUploadProps(PropertyGroup, BlenderKitCommonUploadProps):
thumbnail: StringProperty(
name="Thumbnail",
- description="Path to the thumbnail - 512x512 .jpg image",
+ description="Thumbnail path - 512x512 .jpg image, rendered with cycles. \n"
+ "Only standard BlenderKit previews will be accepted.\n"
+ "Only exception are special effects like fire or similar.",
subtype='FILE_PATH',
default="",
update=autothumb.update_upload_material_preview)
@@ -932,6 +947,7 @@ class BlenderKitHDRUploadProps(PropertyGroup, BlenderKitCommonUploadProps):
texture_resolution_max: IntProperty(name="Texture Resolution Max", description="texture resolution maximum",
default=0)
+
class BlenderKitBrushUploadProps(PropertyGroup, BlenderKitCommonUploadProps):
mode: EnumProperty(
name="Mode",
@@ -1005,7 +1021,7 @@ class BlenderKitModelUploadProps(PropertyGroup, BlenderKitCommonUploadProps):
manufacturer: StringProperty(
name="Manufacturer",
- description="Manufacturer, company making a design peace or product. Not you",
+ description="Manufacturer, company making a design piece or product. Not you",
default="",
)
@@ -1029,7 +1045,9 @@ class BlenderKitModelUploadProps(PropertyGroup, BlenderKitCommonUploadProps):
thumbnail: StringProperty(
name="Thumbnail",
- description="Path to the thumbnail - 512x512 .jpg image",
+ description="Thumbnail path - 512x512 .jpg\n"
+ "Rendered with cycles",
+
subtype='FILE_PATH',
default="",
update=autothumb.update_upload_model_preview)
@@ -1215,7 +1233,8 @@ class BlenderKitSceneUploadProps(PropertyGroup, BlenderKitCommonUploadProps):
thumbnail: StringProperty(
name="Thumbnail",
- description="Path to the thumbnail - 512x512 .jpg image",
+ description="Thumbnail path - 512x512 .jpg\n"
+ "Rendered with cycles",
subtype='FILE_PATH',
default="",
update=autothumb.update_upload_scene_preview)
@@ -1336,7 +1355,6 @@ class BlenderKitModelSearchProps(PropertyGroup, BlenderKitCommonSearchProps):
update=search.search_update
)
-
# CONDITION
search_condition: EnumProperty(
items=conditions,
@@ -1508,10 +1526,11 @@ class BlenderKitSceneSearchProps(PropertyGroup, BlenderKitCommonSearchProps):
default="APPEND"
)
switch_after_append: BoolProperty(
- name = 'Switch to scene after download',
- default = False
+ name='Switch to scene after download',
+ default=False
)
+
def fix_subdir(self, context):
'''Fixes project subdicrectory settings if people input invalid path.'''
@@ -1524,11 +1543,10 @@ def fix_subdir(self, context):
if self.project_subdir != pp:
self.project_subdir = pp
- ui_panels.ui_message(title = "Fixed to relative path",
- message = "This path should be always realative.\n" \
- " It's a directory BlenderKit creates where your .blend is \n " \
- "and uses it for storing assets.")
-
+ ui_panels.ui_message(title="Fixed to relative path",
+ message="This path should be always realative.\n" \
+ " It's a directory BlenderKit creates where your .blend is \n " \
+ "and uses it for storing assets.")
class BlenderKitAddonPreferences(AddonPreferences):
@@ -1694,6 +1712,7 @@ class BlenderKitAddonPreferences(AddonPreferences):
default=False,
update=utils.save_prefs
)
+
# allow_proximity : BoolProperty(
# name="allow proximity data reports",
# description="This sends anonymized proximity data \n \
diff --git a/blenderkit/ui.py b/blenderkit/ui.py
index 71eb5e32..f39e233b 100644
--- a/blenderkit/ui.py
+++ b/blenderkit/ui.py
@@ -412,7 +412,6 @@ def draw_tooltip(x, y, text='', author='', img=None, gravatar=None):
fsize = font_height
tcol = textcol
- print (i)
if l[:4] == 'Tip:' or l[:11] == 'Please rate' :
tcol = textcol_strong
fsize = font_height + 1
diff --git a/blenderkit/ui_panels.py b/blenderkit/ui_panels.py
index deb6d628..588954e8 100644
--- a/blenderkit/ui_panels.py
+++ b/blenderkit/ui_panels.py
@@ -143,14 +143,22 @@ def draw_upload_common(layout, props, asset_type, context):
layout.prop(props, 'is_private', expand=True)
if props.is_private == 'PUBLIC':
layout.prop(props, 'license')
+ layout.prop(props, 'is_free', expand=True)
+ prop_needed(layout, props, 'name', props.name)
+ if props.is_private == 'PUBLIC':
+ prop_needed(layout, props, 'description', props.description)
+ prop_needed(layout, props, 'tags', props.tags)
+ else:
+ layout.prop(props, 'description')
+ layout.prop(props, 'tags')
def poll_local_panels():
user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
return user_preferences.panel_behaviour == 'BOTH' or user_preferences.panel_behaviour == 'LOCAL'
-def prop_needed(layout, props, name, value, is_not_filled=''):
+def prop_needed(layout, props, name, value='', is_not_filled=''):
row = layout.row()
if value == is_not_filled:
# row.label(text='', icon = 'ERROR')
@@ -180,9 +188,6 @@ def draw_panel_hdr_upload(self, context):
draw_upload_common(layout, props, 'HDR', context)
- layout.prop(props, 'name')
- layout.prop(props, 'description')
- layout.prop(props, 'tags')
def draw_panel_hdr_search(self, context):
@@ -208,12 +213,10 @@ def draw_panel_model_upload(self, context):
draw_upload_common(layout, props, 'MODEL', context)
- prop_needed(layout, props, 'name', props.name)
-
col = layout.column()
if props.is_generating_thumbnail:
col.enabled = False
- prop_needed(col, props, 'thumbnail', props.has_thumbnail, False)
+ prop_needed(col, props, 'thumbnail', props.thumbnail)
if bpy.context.scene.render.engine in ('CYCLES', 'BLENDER_EEVEE'):
col.operator("object.blenderkit_generate_thumbnail", text='Generate thumbnail', icon='IMAGE')
@@ -227,15 +230,12 @@ def draw_panel_model_upload(self, context):
elif props.thumbnail_generating_state != '':
utils.label_multiline(layout, text=props.thumbnail_generating_state)
- layout.prop(props, 'description')
- layout.prop(props, 'tags')
# prop_needed(layout, props, 'style', props.style)
# prop_needed(layout, props, 'production_level', props.production_level)
layout.prop(props, 'style')
layout.prop(props, 'production_level')
layout.prop(props, 'condition')
- layout.prop(props, 'is_free')
layout.prop(props, 'pbr')
layout.label(text='design props:')
layout.prop(props, 'manufacturer')
@@ -272,8 +272,6 @@ def draw_panel_scene_upload(self, context):
# else:
# layout.operator("object.blenderkit_auto_tags", text='Auto fill tags')
- prop_needed(layout, props, 'name', props.name)
-
col = layout.column()
# if props.is_generating_thumbnail:
# col.enabled = False
@@ -291,9 +289,8 @@ def draw_panel_scene_upload(self, context):
# elif props.thumbnail_generating_state != '':
# utils.label_multiline(layout, text = props.thumbnail_generating_state)
- layout.prop(props, 'is_free')
- layout.prop(props, 'description')
- layout.prop(props, 'tags')
+
+
layout.prop(props, 'style')
layout.prop(props, 'production_level')
layout.prop(props, 'use_design_year')
@@ -623,30 +620,16 @@ def draw_panel_material_upload(self, context):
draw_upload_common(layout, props, 'MATERIAL', context)
- prop_needed(layout, props, 'name', props.name)
- layout.prop(props, 'description')
- layout.prop(props, 'style')
- # if props.style == 'OTHER':
- # layout.prop(props, 'style_other')
- # layout.prop(props, 'engine')
- # if props.engine == 'OTHER':
- # layout.prop(props, 'engine_other')
- layout.prop(props, 'tags')
- # layout.prop(props,'shaders')#TODO autofill on upload
- # row = layout.row()
- layout.prop(props, 'is_free')
-
- layout.prop(props, 'pbr')
- layout.prop(props, 'uv')
- layout.prop(props, 'animated')
- layout.prop(props, 'texture_size_meters')
-
# THUMBNAIL
row = layout.row()
if props.is_generating_thumbnail:
row.enabled = False
prop_needed(row, props, 'thumbnail', props.has_thumbnail, False)
+
+
+ if bpy.context.scene.render.engine in ('CYCLES', 'BLENDER_EEVEE'):
+ layout.operator("object.blenderkit_material_thumbnail", text='Render thumbnail with Cycles', icon='EXPORT')
if props.is_generating_thumbnail:
row = layout.row(align=True)
row.label(text=props.thumbnail_generating_state, icon='RENDER_STILL')
@@ -656,8 +639,21 @@ def draw_panel_material_upload(self, context):
elif props.thumbnail_generating_state != '':
utils.label_multiline(layout, text=props.thumbnail_generating_state)
- if bpy.context.scene.render.engine in ('CYCLES', 'BLENDER_EEVEE'):
- layout.operator("object.blenderkit_material_thumbnail", text='Render thumbnail with Cycles', icon='EXPORT')
+ layout.prop(props, 'style')
+ # if props.style == 'OTHER':
+ # layout.prop(props, 'style_other')
+ # layout.prop(props, 'engine')
+ # if props.engine == 'OTHER':
+ # layout.prop(props, 'engine_other')
+ # layout.prop(props,'shaders')#TODO autofill on upload
+ # row = layout.row()
+
+ layout.prop(props, 'pbr')
+ layout.prop(props, 'uv')
+ layout.prop(props, 'animated')
+ layout.prop(props, 'texture_size_meters')
+
+
# tname = "." + bpy.context.active_object.active_material.name + "_thumbnail"
# if props.has_thumbnail and bpy.data.textures.get(tname) is not None:
@@ -701,10 +697,6 @@ def draw_panel_brush_upload(self, context):
draw_upload_common(layout, props, 'BRUSH', context)
- layout.prop(props, 'name')
- layout.prop(props, 'description')
- layout.prop(props, 'tags')
-
def draw_panel_brush_search(self, context):
s = context.scene
@@ -974,8 +966,20 @@ class VIEW3D_PT_blenderkit_unified(Panel):
row.scale_x = 1.6
row.scale_y = 1.6
# split = row.split(factor=.
- col = layout.column()
- col.prop(ui_props, 'asset_type', expand=True, icon_only=False)
+
+ expand_icon = 'TRIA_DOWN'
+ if ui_props.asset_type_expand:
+ expand_icon = 'TRIA_RIGHT'
+ row = layout.row()
+ split = row.split(factor = 0.1)
+ split.prop(ui_props, 'asset_type_expand', icon = expand_icon, icon_only = True, emboss = False)
+ split = split.split(factor = 1.0)
+ if ui_props.asset_type_expand:
+ #expanded interface with names in column
+ split = split.row()
+ split.scale_x = 1.6
+ split.scale_y = 1.6
+ split.prop(ui_props, 'asset_type', expand=True, icon_only=ui_props.asset_type_expand)
# row = layout.column(align = False)
# layout.prop(ui_props, 'asset_type', expand=False, text='')
diff --git a/blenderkit/upload.py b/blenderkit/upload.py
index 2065ce08..0a7441d4 100644
--- a/blenderkit/upload.py
+++ b/blenderkit/upload.py
@@ -18,7 +18,7 @@
from blenderkit import asset_inspector, paths, utils, bg_blender, autothumb, version_checker, search, ui_panels, ui, \
- overrides, colors, rerequests, categories, upload_bg, tasks_queue, image_utils
+ overrides, colors, rerequests, categories, upload_bg, tasks_queue, image_utils
import tempfile, os, subprocess, json, re
@@ -47,6 +47,7 @@ licenses = (
('cc_zero', 'Creative Commons Zero', 'Creative Commons Zero'),
)
+
def comma2array(text):
commasep = text.split(',')
ar = []
@@ -71,50 +72,32 @@ def add_version(data):
def write_to_report(props, text):
- props.report = props.report + text + '\n'
+ props.report = props.report + ' - '+ text + '\n\n'
def check_missing_data_model(props):
- props.report = ''
autothumb.update_upload_model_preview(None, None)
-
- if props.name == '':
- write_to_report(props, 'Set model name')
- # if props.tags == '':
- # write_to_report(props, 'Write at least 3 tags')
if not props.has_thumbnail:
write_to_report(props, 'Add thumbnail:')
-
props.report += props.thumbnail_generating_state + '\n'
if props.engine == 'NONE':
write_to_report(props, 'Set at least one rendering/output engine')
- if not any(props.dimensions):
- write_to_report(props, 'Run autotags operator or fill in dimensions manually')
+
+ # if not any(props.dimensions):
+ # write_to_report(props, 'Run autotags operator or fill in dimensions manually')
def check_missing_data_scene(props):
- props.report = ''
autothumb.update_upload_model_preview(None, None)
-
- if props.name == '':
- write_to_report(props, 'Set scene name')
- # if props.tags == '':
- # write_to_report(props, 'Write at least 3 tags')
if not props.has_thumbnail:
write_to_report(props, 'Add thumbnail:')
-
props.report += props.thumbnail_generating_state + '\n'
if props.engine == 'NONE':
write_to_report(props, 'Set at least one rendering/output engine')
def check_missing_data_material(props):
- props.report = ''
autothumb.update_upload_material_preview(None, None)
- if props.name == '':
- write_to_report(props, 'Set material name')
- # if props.tags == '':
- # write_to_report(props, 'Write at least 3 tags')
if not props.has_thumbnail:
write_to_report(props, 'Add thumbnail:')
props.report += props.thumbnail_generating_state
@@ -124,16 +107,56 @@ def check_missing_data_material(props):
def check_missing_data_brush(props):
autothumb.update_upload_brush_preview(None, None)
- props.report = ''
- if props.name == '':
- write_to_report(props, 'Set brush name')
- # if props.tags == '':
- # write_to_report(props, 'Write at least 3 tags')
if not props.has_thumbnail:
write_to_report(props, 'Add thumbnail:')
props.report += props.thumbnail_generating_state
+def check_missing_data(asset_type, props):
+ '''
+ checks if user did everything allright for particular assets and notifies him back if not.
+ Parameters
+ ----------
+ asset_type
+ props
+
+ Returns
+ -------
+
+ '''
+ props.report = ''
+
+ if props.name == '':
+ write_to_report(props, f'Set {asset_type.lower()} name.\n'
+ f'It has to be in English and \n'
+ f'can not be longer than 40 letters.\n')
+ if len(props.name) > 40:
+ write_to_report(props, f'The name is too long. maximum is 40 letters')
+
+ if props.is_private == 'PUBLIC':
+
+ if len(props.description) < 20:
+ write_to_report(props, "The description is too short or empty. \n"
+ "Please write a description that describes \n "
+ "your asset as good as possible.\n"
+ "Description helps to bring your asset up\n in relevant search results. ")
+ if props.tags == '':
+ write_to_report(props, 'Write at least 3 tags.\n'
+ 'Tags help to bring your asset up in relevant search results.')
+
+ if asset_type == 'MODEL':
+ check_missing_data_model(props)
+ if asset_type == 'SCENE':
+ check_missing_data_scene(props)
+ elif asset_type == 'MATERIAL':
+ check_missing_data_material(props)
+ elif asset_type == 'BRUSH':
+ check_missing_data_brush(props)
+
+ if props.report != '':
+ props.report = f'Please fix these issues before {props.is_private.lower()} upload:\n\n' + props.report
+
+
def sub_to_camel(content):
replaced = re.sub(r"_.",
lambda m: m.group(0)[1].upper(), content)
@@ -514,8 +537,6 @@ def patch_individual_metadata(asset_id, metadata_dict, api_key):
return {'FINISHED'}
-
-
# class OBJECT_MT_blenderkit_fast_metadata_menu(bpy.types.Menu):
# bl_label = "Fast category change"
# bl_idname = "OBJECT_MT_blenderkit_fast_metadata_menu"
@@ -540,13 +561,14 @@ def update_free_full(self, context):
if self.asset_type == 'material':
if self.free_full == 'FULL':
self.free_full = 'FREE'
- ui_panels.ui_message(title = "All BlenderKit materials are free",
- message = "Any material uploaded to BlenderKit is free." \
- " However, it can still earn money for the author," \
- " based on our fair share system. " \
- "Part of subscription is sent to artists based on usage by paying users.")
+ ui_panels.ui_message(title="All BlenderKit materials are free",
+ message="Any material uploaded to BlenderKit is free." \
+ " However, it can still earn money for the author," \
+ " based on our fair share system. " \
+ "Part of subscription is sent to artists based on usage by paying users.")
+
-def can_edit_asset(active_index = -1, asset_data = None):
+def can_edit_asset(active_index=-1, asset_data=None):
if active_index == -1 and not asset_data:
return False
profile = bpy.context.window_manager.get('bkit profile')
@@ -562,6 +584,7 @@ def can_edit_asset(active_index = -1, asset_data = None):
return True
return False
+
class FastMetadata(bpy.types.Operator):
"""Fast change of the category of object directly in asset bar."""
bl_idname = "wm.blenderkit_fast_metadata"
@@ -597,7 +620,7 @@ class FastMetadata(bpy.types.Operator):
name="Subcategory",
description="main category to put into",
items=categories.get_subcategory_enums,
- update = categories.update_subcategory_enums
+ update=categories.update_subcategory_enums
)
subcategory1: EnumProperty(
name="Subcategory",
@@ -620,7 +643,7 @@ class FastMetadata(bpy.types.Operator):
default="PUBLIC",
)
- free_full:EnumProperty(
+ free_full: EnumProperty(
name="Free or Full Plan",
items=(
('FREE', 'Free', "You consent you want to release this asset as free for everyone"),
@@ -648,7 +671,7 @@ class FastMetadata(bpy.types.Operator):
layout.prop(self, 'subcategory')
if self.subcategory != 'NONE' and self.subcategory1 != 'NONE':
enums = categories.get_subcategory1_enums(self, context)
- if enums[0][0]!='NONE':
+ if enums[0][0] != 'NONE':
layout.prop(self, 'subcategory1')
layout.prop(self, 'name')
layout.prop(self, 'description')
@@ -658,8 +681,6 @@ class FastMetadata(bpy.types.Operator):
if self.is_private == 'PUBLIC':
layout.prop(self, 'license')
-
-
def execute(self, context):
user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
props = bpy.context.scene.blenderkitUI
@@ -685,7 +706,7 @@ class FastMetadata(bpy.types.Operator):
args=(self.asset_id, mdict, user_preferences.api_key))
thread.start()
tasks_queue.add_task((ui.add_report, (f'Uploading metadata for {self.name}. '
- f'Refresh search results to see that changes applied correctly.', 8,)))
+ f'Refresh search results to see that changes applied correctly.', 8,)))
return {'FINISHED'}
@@ -730,7 +751,7 @@ class FastMetadata(bpy.types.Operator):
wm = context.window_manager
- return wm.invoke_props_dialog(self, width = 600)
+ return wm.invoke_props_dialog(self, width=600)
def verification_status_change_thread(asset_id, state, api_key):
@@ -944,7 +965,7 @@ class Uploader(threading.Thread):
}
datafile = os.path.join(self.export_data['temp_dir'], BLENDERKIT_EXPORT_DATA_FILE)
- with open(datafile, 'w', encoding = 'utf-8') as s:
+ with open(datafile, 'w', encoding='utf-8') as s:
json.dump(data, s, ensure_ascii=False, indent=4)
# non waiting method - not useful here..
@@ -987,7 +1008,7 @@ class Uploader(threading.Thread):
})
if not os.path.exists(fpath):
- self.send_message ("File packing failed, please try manual packing first")
+ self.send_message("File packing failed, please try manual packing first")
return {'CANCELLED'}
self.send_message('Uploading files')
@@ -1018,28 +1039,6 @@ class Uploader(threading.Thread):
return {'CANCELLED'}
-def check_missing_data(asset_type, props):
- '''
- checks if user did everything allright for particular assets and notifies him back if not.
- Parameters
- ----------
- asset_type
- props
-
- Returns
- -------
-
- '''
- if asset_type == 'MODEL':
- check_missing_data_model(props)
- if asset_type == 'SCENE':
- check_missing_data_scene(props)
- elif asset_type == 'MATERIAL':
- check_missing_data_material(props)
- elif asset_type == 'BRUSH':
- check_missing_data_brush(props)
-
-
def start_upload(self, context, asset_type, reupload, upload_set):
'''start upload process, by processing data, then start a thread that cares about the rest of the upload.'''
@@ -1065,7 +1064,6 @@ def start_upload(self, context, asset_type, reupload, upload_set):
check_missing_data(asset_type, props)
# if previous check did find any problems then
if props.report != '':
- self.report({'ERROR_INVALID_INPUT'}, props.report)
return {'CANCELLED'}
if not reupload:
@@ -1188,14 +1186,18 @@ class UploadOperator(Operator):
if self.main_file:
upload_set.append('MAINFILE')
- #this is accessed later in get_upload_data and needs to be written.
+ # this is accessed later in get_upload_data and needs to be written.
# should pass upload_set all the way to it probably
if 'MAINFILE' in upload_set:
self.main_file = True
result = start_upload(self, context, self.asset_type, self.reupload, upload_set=upload_set, )
- return {'FINISHED'}
+ if props.report != '':
+ # self.report({'ERROR_INVALID_INPUT'}, props.report)
+ self.report({'ERROR_INVALID_CONTEXT'}, props.report)
+
+ return result
def draw(self, context):
props = utils.get_upload_props()
diff --git a/blenderkit/upload_bg.py b/blenderkit/upload_bg.py
index 685e280a..cc64f470 100644
--- a/blenderkit/upload_bg.py
+++ b/blenderkit/upload_bg.py
@@ -91,6 +91,11 @@ def upload_file(upload_data, f):
if 250 > upload_response.status_code > 199:
uploaded = True
+ upload_done_url = paths.get_api_url() + 'uploads_s3/' + upload['id'] + '/upload-file/'
+ upload_response = rerequests.post(upload_done_url, headers=headers, verify=True)
+ print(upload_response)
+ tasks_queue.add_task((ui.add_report, (f"Finished file upload{os.path.basename(f['file_path'])}",)))
+ return True
else:
print(upload_response.text)
message = f"Upload failed, retry. File : {f['type']} {os.path.basename(f['file_path'])}"
@@ -103,13 +108,11 @@ def upload_file(upload_data, f):
time.sleep(1)
# confirm single file upload to bkit server
- print(upload)
- upload_done_url = paths.get_api_url() + 'uploads_s3/' + upload['id'] + '/upload-file/'
- upload_response = rerequests.post(upload_done_url, headers=headers, verify=True)
- tasks_queue.add_task((ui.add_report, (f"Finished file upload{os.path.basename(f['file_path'])}",)))
- return uploaded
+
+
+ return False
def upload_files(upload_data, files):