Scripting API examples *************************** The Prism python scripting API can be used to customize various features of Prism and trigger actions. Almost every feature, which is available through the GUI can be accessed by external python scripts. Below there is a list of examples: General ==================================== **Create a new Prism instance:** :: import sys sys.path.append("C:/Program Files/Prism2/Scripts") import PrismCore core = PrismCore.create(prismArgs=["noUI"]) # use this if you want to load the previously active project core = PrismCore.create(prismArgs=["noUI", "loadProject"]) # use this is you want to show the GUI # core = PrismCore.show(prismArgs=["loadProject"]) print(core.version) **Create a new project:** :: name = "My Project Name" path = "D:/Projects/myProject" core.projects.createProject(name, path, preset="Default") **Change the active project:** :: path = "D:/Projects/myProject" core.changeProject(path) print(core.projectName) print(core.projectPath) **Create an assetfolder:** :: entity = { "type": "assetFolder", "asset_path": "MyFolder" } core.entities.createEntity(entity) **Create an asset:** :: entity = { "type": "asset", "asset_path": "MyFolder/MyAssetName" } core.entities.createEntity(entity) **Create a shot:** :: entity = { "type": "shot", "sequence": "a", "shot": "0010", } frameRange = [1001, 1040] core.entities.createEntity(entity, frameRange=frameRange) **Create a department:** :: entity = { "type": "shot", "sequence": "a", "shot": "0010", } department = "fx" core.entities.createDepartment(department, entity, createCat=False) **Create a task:** :: entity = { "type": "shot", "sequence": "a", "shot": "0010", } department = "fx" task = "fire" # this function might get renamed in future versions core.entities.createCategory(entity, department, task) **Create a scenefile from a preset:** :: entity = { "type": "shot", "sequence": "a", "shot": "0010", } department = "fx" task = "fire" # get all available preset of the current project presets = core.entities.getPresetScenes() # get the first preset, which is a Houdini scenefile fileName = [f for f in presets if f.endswith(".hip")][0] core.entities.createSceneFromPreset( entity, fileName, department, task, comment="high speed", ) Managing Plugins ==================================== **Check if a plugin is loaded:** :: pluginName = "USD" plugin = core.plugins.getPlugin(pluginName) isLoaded = plugin is not None if isLoaded: print("plugin %s is loaded from path: %s" % (pluginName, plugin.pluginPath) **Load a plugin:** :: # by name core.plugins.loadPlugin(name="USD") # by path core.plugins.loadPlugin(path="C:/path/to/plugin/USD") **Check if a pluginpath is in the plugin config and can be loaded, if not add it to the config:** :: pluginPath = "C:/path/to/plugin/USD" if not core.plugins.canPluginBeFound(pluginPath): core.plugins.addToPluginConfig(pluginPath=pluginPath) **Remove a pluginpath from the plugin config, so it won't get loaded:** :: pluginPath = "C:/path/to/plugin/USD" core.plugins.removeFromPluginConfig(pluginPath=pluginPath) **Install a Plugin:** :: core.getPlugin("PrismInternals").internals.installPlugin("Houdini") **Uninstall a Plugin:** :: plugin = core.getPlugin("Houdini") core.getPlugin("PrismInternals").internals.uninstallPlugin(plugin) **Add a DCC integration:** :: import os path = os.environ["USERPROFILE"] + "/Documents/houdini19.5" core.integration.addIntegration("Houdini", path=path) **Remove a DCC integration:** :: import os path = os.environ["USERPROFILE"] + "/Documents/houdini19.5" core.integration.removeIntegration("Houdini", path=path) Texture Library ==================================== **Ingest textures:** :: # getting the plugin instance plugin = core.getPlugin("TextureLibrary") # specifying the texture paths textures = [ "D:/test.jpg", "D:/test2.jpg" ] # specifying the location. Available options are the items in the location dropdown in the Texture Library window location = "Assets" # specifying the assetname including assetfolders asset = {"type": "asset", "asset_path": "MyFolder/MyAssetName"} # specifying subfolders where the files will be copied to subfolders = "proxies/v0001" # ingesting the textures into the project plugin.ingestTextures(textures, location, asset=asset, subfolders=subfolders) # adding textures to the project library instead to a specific asset location = "Project Library" plugin.ingestTextures(textures, location, subfolders=subfolders)