Skip to content

Commit

Permalink
Merge pull request #13 from sketchfab/r22-and-login-error_D3D-5636
Browse files Browse the repository at this point in the history
Updates for S22 and fixes login error
  • Loading branch information
cedricpinson authored May 27, 2020
2 parents 061b996 + 357f2ff commit db0fe1b
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
4 changes: 4 additions & 0 deletions SketchfabPlugin.pyp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ if not SKFB_DEPENDENCIES_PATH in sys.path:
sys.path.insert(0, SKFB_DEPENDENCIES_PATH)

from sketchfab.config import Config
from sketchfab.utils import Utils
from sketchfab.ui_importer import *
from sketchfab.ui_exporter import *

Expand Down Expand Up @@ -104,6 +105,9 @@ if __name__ == "__main__":
iconPath = os.path.join(os.path.split(__file__)[0], "res", "icon.png")
icon.InitWith(iconPath)

# Create the necessary directories
Utils.setup_plugin()

# Register the importer
plugins.RegisterCommandPlugin(id=Config.IMPORTER_ID,
str=Config.IMPORTER_TITLE,
Expand Down
3 changes: 0 additions & 3 deletions sketchfab/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,6 @@ def get_square_crop_resolution(im):
if uid not in self.skfb_api.search_results['current']:
return

if not os.path.exists(Config.SKETCHFAB_THUMB_DIR):
os.makedirs(Config.SKETCHFAB_THUMB_DIR)

preview_path = Utils.build_thumbnail_path(uid)

if os.path.exists(preview_path):
Expand Down
4 changes: 2 additions & 2 deletions sketchfab/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

class Config:

PLUGIN_VERSION = "1.3.0"
PLUGIN_VERSION = "1.3.1"
PLUGIN_TITLE = "Sketchfab Plugin"
PLUGIN_AUTHOR = "Sketchfab"
PLUGIN_TWITTER = "@sketchfab"
Expand All @@ -40,7 +40,7 @@ class Config:

# sometimes the path in preferences is empty
def get_temp_path():
return c4d.storage.GeGetC4DPath(c4d.C4D_PATH_PREFS)
return c4d.storage.GeGetStartupWritePath()

GITHUB_REPOSITORY_URL = 'https://github.com/sketchfab/c4d-plugin'
PLUGIN_LATEST_RELEASE = GITHUB_REPOSITORY_URL + '/releases/latest'
Expand Down
10 changes: 9 additions & 1 deletion sketchfab/ui_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
c4d.FBXEXPORT_SPLINES: 1,
# Geometry and Materials
c4d.FBXEXPORT_SAVE_NORMALS: 1,
c4d.FBXEXPORT_TEXTURES: 1,
c4d.FBXEXPORT_EMBED_TEXTURES: 1,
c4d.FBXEXPORT_FBX_VERSION: c4d.FBX_EXPORTVERSION_NATIVE,
# cancel all these one
Expand All @@ -79,6 +78,15 @@
c4d.FBXEXPORT_ASCII: 0
}

# Take API changes from R22 into account
# https://developers.maxon.net/docs/Cinema4DPythonSDK/html/misc/changelog/changelog_s22.html
if c4d.GetC4DVersion() >= 22000:
export_options[c4d.FBXEXPORT_BAKE_MATERIALS] = 0
export_options[c4d.FBXEXPORT_MATERIALS] = c4d.FBXEXPORT_MATERIALS_PHONGLAMBERT
else:
# In S22+, this becomes enforced by FBXEXPORT_EMBED_TEXTURES
export_options[c4d.FBXEXPORT_TEXTURES] = 1

# Globals
g_uploaded = False
g_error = ""
Expand Down
2 changes: 2 additions & 0 deletions sketchfab/ui_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,8 @@ def draw_model_import(self):

if not caption:
caption = "IMPORT MODEL" if self.skfb_api.is_user_logged() else "You need to be logged in"
if self.skfb_model is not None and self.skfb_model.download_size:
caption += " (" + self.skfb_model.download_size + ")"

self.AddButton(id=BTN_IMPORT, flags=c4d.BFH_CENTER | c4d.BFV_CENTER, initw=200, inith=38, name=caption)
self.LayoutChanged(GROUP_MODEL_IMPORT)
Expand Down
2 changes: 2 additions & 0 deletions sketchfab/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ def setup_plugin():
os.makedirs(Config.SKETCHFAB_TEMP_DIR)
if not os.path.exists(Config.SKETCHFAB_THUMB_DIR):
os.makedirs(Config.SKETCHFAB_THUMB_DIR)
if not os.path.exists(Config.SKETCHFAB_MODEL_DIR):
os.makedirs(Config.SKETCHFAB_MODEL_DIR)
@staticmethod
def get_uid_from_thumbnail_url(thumbnail_url):
return thumbnail_url.split('/')[4]
Expand Down

0 comments on commit db0fe1b

Please sign in to comment.