diff options
author | Vilém Duha <vilda.novak@gmail.com> | 2019-09-04 16:34:09 +0300 |
---|---|---|
committer | Vilém Duha <vilda.novak@gmail.com> | 2019-09-10 17:55:32 +0300 |
commit | e760c7f30e7f43af7ed1c0ab55625362ea923951 (patch) | |
tree | e5e9690975ae7c7bb0b7b8c7177f881ec3007808 | |
parent | 16299222c41de0bd77335cd0e97656edeb2090c3 (diff) |
BlenderKit: fix upload of objects with ' or " in their name.
it now doesn't allow these character in object/datablock names when uploading.
-rw-r--r-- | blenderkit/__init__.py | 14 | ||||
-rw-r--r-- | blenderkit/autothumb.py | 2 | ||||
-rw-r--r-- | blenderkit/upload.py | 4 | ||||
-rw-r--r-- | blenderkit/utils.py | 19 |
4 files changed, 26 insertions, 13 deletions
diff --git a/blenderkit/__init__.py b/blenderkit/__init__.py index 516f470c..d7689a3c 100644 --- a/blenderkit/__init__.py +++ b/blenderkit/__init__.py @@ -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): diff --git a/blenderkit/autothumb.py b/blenderkit/autothumb.py index f9e7c85f..4be82f29 100644 --- a/blenderkit/autothumb.py +++ b/blenderkit/autothumb.py @@ -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) diff --git a/blenderkit/upload.py b/blenderkit/upload.py index 75f203df..955713b5 100644 --- a/blenderkit/upload.py +++ b/blenderkit/upload.py @@ -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: diff --git a/blenderkit/utils.py b/blenderkit/utils.py index 20dcaec8..688346c0 100644 --- a/blenderkit/utils.py +++ b/blenderkit/utils.py @@ -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
\ No newline at end of file |