BlenderKit: fix upload of objects with ' or " in their name.

it now doesn't allow these character in object/datablock names when uploading.
This commit is contained in:
Vilém Duha 2019-09-04 15:34:09 +02:00
parent 16299222c4
commit e760c7f30e
4 changed files with 26 additions and 13 deletions

View File

@ -371,18 +371,8 @@ class BlenderKitCommonSearchProps(object):
def name_update(self, context):
''' checks for name change, because it decides if whole asset has to be re-uploaded. Name is stored in the blend file
and that's the reason.'''
props = utils.get_upload_props()
if props.name_old != props.name:
props.name_changed = True
props.name_old = props.name
nname = props.name.strip()
nname = nname.replace('_', ' ')
if nname.isupper():
nname = nname.lower()
nname = nname[0].upper() + nname[1:]
props.name = nname
asset = utils.get_active_asset()
asset.name = nname
utils.name_update()
def update_tags(self, context):

View File

@ -110,7 +110,7 @@ def start_thumbnailer(self, context):
basename = os.path.join(basename, "temp")
if not ext:
ext = ".blend"
asset_name = mainmodel.blenderkit.name
asset_name = mainmodel.name
tempdir = tempfile.mkdtemp()
file_dir = os.path.dirname(bpy.data.filepath)

View File

@ -533,6 +533,10 @@ def auto_fix(asset_type=''):
def start_upload(self, context, asset_type, reupload, upload_set):
'''start upload process, by processing data'''
# fix the name first
utils.name_update()
props = utils.get_upload_props()
storage_quota_ok = check_storage_quota(props)
if not storage_quota_ok:

View File

@ -465,3 +465,22 @@ def automap(target_object=None, target_slot=None, tex_size=1, bg_exception=False
if just_scale:
scale_uvs(tob, scale=Vector((1/tex_size, 1/tex_size)))
bpy.context.view_layer.objects.active = actob
def name_update():
props = get_upload_props()
if props.name_old != props.name:
props.name_changed = True
props.name_old = props.name
nname = props.name.strip()
nname = nname.replace('_', ' ')
if nname.isupper():
nname = nname.lower()
nname = nname[0].upper() + nname[1:]
props.name = nname
# here we need to fix the name for blender data = ' or " give problems in path evaluation down the road.
fname = props.name
fname = fname.replace('\'', '')
fname = fname.replace('\"', '')
asset = get_active_asset()
asset.name = fname