Adding Folder Template#
This example plugin adds a custom folder template, which will be visible in the “Folder Structure” tab in the Prism Project Settings.
The template is then used in a postExport callback to generate a path where a USD file will be saved.
See the section for Single File Plugins on how to load this example.
# AddTemplatePath.py
name = "AddTemplatePath"
classname = "AddTemplatePath"
from qtpy.QtWidgets import *
class AddTemplatePath:
def __init__(self, core):
self.core = core
self.version = "v1.0.0"
# register a new template
data = {"label": "My Custom Template", "key": "@myustomTemplate_path@", "value": "@productversion_path@/@asset@/@asset@@extension@", "requires": ["extension"]}
self.core.projects.addProjectStructureItem("myCustomTemplate", data)
# register postExport callback
self.core.registerCallback("postExport", self.postExport, plugin=self)
def postExport(self, *args, **kwargs):
entity = self.core.paths.getCachePathData(kwargs["outputpath"])
if not entity or entity.get("type") != "asset":
return
# define the context for the template resolve
context = {"extension": ".usda"}
context.update(entity)
# generate a path from the template
path = self.core.projects.getResolvedProjectStructurePath("myCustomTemplate", context=context)
# the following files save an empty usd file to the generated path. It requires the USD plugin to be loaded.
usdApi = self.core.getPlugin("USD").api
stage = usdApi.createEmptyStage()
usdApi.saveStage(stage, path)