Last updated on
May 24, 2023
- Command Line overview
- sbsbaker
- sbscooker
- sbsmtools
- sbsmutator
- sbsrender
- sbsupdater
- Pysbs - Python API overview
- Getting started
- General topics
-
API Content
- API Content overview
-
Substance definitions
- Common interfaces
- compnode
- context projectmgr
- graph
- mdl
-
modelgraphindex
- modelannotationnames
- modelgraph
- modelgraphgenerator
- modelgraphimplementation
- modelnodenames
- modeloperand
- moduleannotation
- moduleconnection
- modulegraph
- modulegraphgenerator
- modulegraphimplementation
- modulegraphlibrary
- modulegraphregister
- modulenode
- modulenodeimplementation
- modulenodeinstance
- moduleoperand
- moduleoutputbridging
- moduleparaminput
- params
- projectmgrdoc
- sbsarchive
- sbscommon
- sbspreset
- sbsproject
- substance
-
Libraries
- sbsenum
- sbslibrary
- sbsbakerslibrary
- Helpers
- Execution context
- API Change log
- Substance Maya toolset
- Substance 3D home
- Home
-
Command Line Tools
- Command Line overview
- sbsbaker
- sbscooker
- sbsmtools
- sbsmutator
- sbsrender
- sbsupdater
- Samples
- Setup and Getting Started
-
Integrations
- Substance Maya toolset
- Changelog overview
script_update_with_sbsupdater
script_update_with_sbsupdater.scriptUpdatePackagesVersion(aContext, aPreviousVersion, aPreviousUpdaterVersion, aPackagesFolderRootDir, aBatchToolsFolder=None)
script_update_with_sbsupdater.scriptUpdatePackagesVersion(aContext, aPreviousVersion, aPreviousUpdaterVersion, aPackagesFolderRootDir, aBatchToolsFolder=None)
script_update_with_sbsupdater.scriptUpdatePackagesVersion(aContext, aPreviousVersion, aPreviousUpdaterVersion, aPackagesFolderRootDir, aBatchToolsFolder=None)
Allows to update to the current version of Substance Designer all .sbs recursively included in the given folder path using the Mutator Batch Tool.
Parameters: |
|
---|---|
Returns: | True if success |
Here is the code of function scriptUpdatePackagesVersion:
aUpdaterPath = aContext.getBatchToolExePath(aBatchTool=sbsenum.BatchToolsEnum.UPDATER, aBatchToolsFolder=aBatchToolsFolder)
aPresetPackagePath = aContext.getDefaultPackagePath()
try:
aCommand = [aUpdaterPath, '--no-dependency', '--output-path', '{inputPath}', '--output-name', '{inputName}', '--presets-path', aPresetPackagePath]
log.info(aCommand)
aRootDir = os.path.normpath(aPackagesFolderRootDir)
for root, subFolders, files in os.walk(aRootDir):
for aFile in files:
if aFile.endswith('.sbs'):
aPackagePath = os.path.join(root, aFile)
aDoc = substance.SBSDocument(aContext=aContext, aFileAbsPath=aPackagePath)
log.info('Parse substance '+aPackagePath)
try:
aDoc.parseDoc()
except SBSIncompatibleVersionError:
pass
if aDoc.mFormatVersion == aPreviousVersion and aDoc.mUpdaterVersion == aPreviousUpdaterVersion:
aMutatorCmd = aCommand + ['--input', aPackagePath]
print(aMutatorCmd)
log.info('Update substance '+aPackagePath)
subprocess.check_call(aMutatorCmd)
log.info('=> All packages have been updated using the Mutator Batch Tool')
return True
except BaseException as error:
log.error("!!! [demoUpdatePackagesVersion] Failed to update a package")
raise error
aUpdaterPath = aContext.getBatchToolExePath(aBatchTool=sbsenum.BatchToolsEnum.UPDATER, aBatchToolsFolder=aBatchToolsFolder)
aPresetPackagePath = aContext.getDefaultPackagePath()
try:
aCommand = [aUpdaterPath, '--no-dependency', '--output-path', '{inputPath}', '--output-name', '{inputName}', '--presets-path', aPresetPackagePath]
log.info(aCommand)
aRootDir = os.path.normpath(aPackagesFolderRootDir)
for root, subFolders, files in os.walk(aRootDir):
for aFile in files:
if aFile.endswith('.sbs'):
aPackagePath = os.path.join(root, aFile)
aDoc = substance.SBSDocument(aContext=aContext, aFileAbsPath=aPackagePath)
log.info('Parse substance '+aPackagePath)
try:
aDoc.parseDoc()
except SBSIncompatibleVersionError:
pass
if aDoc.mFormatVersion == aPreviousVersion and aDoc.mUpdaterVersion == aPreviousUpdaterVersion:
aMutatorCmd = aCommand + ['--input', aPackagePath]
print(aMutatorCmd)
log.info('Update substance '+aPackagePath)
subprocess.check_call(aMutatorCmd)
log.info('=> All packages have been updated using the Mutator Batch Tool')
return True
except BaseException as error:
log.error("!!! [demoUpdatePackagesVersion] Failed to update a package")
raise error
aUpdaterPath = aContext.getBatchToolExePath(aBatchTool=sbsenum.BatchToolsEnum.UPDATER, aBatchToolsFolder=aBatchToolsFolder) aPresetPackagePath = aContext.getDefaultPackagePath() try: aCommand = [aUpdaterPath, '--no-dependency', '--output-path', '{inputPath}', '--output-name', '{inputName}', '--presets-path', aPresetPackagePath] log.info(aCommand) aRootDir = os.path.normpath(aPackagesFolderRootDir) for root, subFolders, files in os.walk(aRootDir): for aFile in files: if aFile.endswith('.sbs'): aPackagePath = os.path.join(root, aFile) aDoc = substance.SBSDocument(aContext=aContext, aFileAbsPath=aPackagePath) log.info('Parse substance '+aPackagePath) try: aDoc.parseDoc() except SBSIncompatibleVersionError: pass if aDoc.mFormatVersion == aPreviousVersion and aDoc.mUpdaterVersion == aPreviousUpdaterVersion: aMutatorCmd = aCommand + ['--input', aPackagePath] print(aMutatorCmd) log.info('Update substance '+aPackagePath) subprocess.check_call(aMutatorCmd) log.info('=> All packages have been updated using the Mutator Batch Tool') return True except BaseException as error: log.error("!!! [demoUpdatePackagesVersion] Failed to update a package") raise error