Skip to content

Commit 7e0356a

Browse files
committed
Fixes import from url option
1 parent 85c1294 commit 7e0356a

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

__init__.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
'author': 'Sketchfab',
4141
'license': 'APACHE2',
4242
'deps': '',
43-
'version': (1, 6, 0),
43+
'version': (1, 6, 1),
4444
"blender": (2, 80, 0),
4545
'location': 'View3D > Tools > Sketchfab',
4646
'warning': '',
@@ -647,6 +647,9 @@ def download_model(self, uid):
647647
if "/orgs/" in skfb.manualImportPath:
648648
try:
649649
orgName = skfb.manualImportPath.split("/orgs/")[1].split("/")[0]
650+
if skfb.skfb_api.user_has_orgs and not skfb.skfb_api.active_org:
651+
skfb.skfb_api.request_user_orgs()
652+
650653
user_orgs = skfb.skfb_api.user_orgs
651654
orgUid = ""
652655
for org in user_orgs:
@@ -680,13 +683,12 @@ def handle_download(self, r, *args, **kwargs):
680683

681684
gltf = r.json()['gltf']
682685
skfb_model = get_sketchfab_model(uid)
683-
if skfb_model is not None:
684-
skfb_model.download_url = gltf['url']
685-
skfb_model.time_url_requested = time.time()
686-
skfb_model.url_expires = gltf['expires']
687-
self.get_archive(gltf['url'], skfb_model.title)
688-
else:
689-
ShowMessage("ERROR", "Cannot retrieve information for this model", "")
686+
687+
# If the model name is not known at this step, we could try to do an additional API call to get it
688+
# This can happen when the user chose to import a model from its url
689+
# However this adds an additional call and a bit of complexity for org models (need additional parsing),
690+
# so for a simple hotfix models imported this way will be called "Sketchfab model"
691+
self.get_archive(gltf['url'], skfb_model.title if skfb_model else "Sketchfab Model")
690692

691693
def get_archive(self, url, title):
692694
if url is None:

0 commit comments

Comments
 (0)