omni.kit.stage_templates
new_stage scripts
user script example (DocumentsKitkit-defaultscriptsnew_stagetest.py)
class TestStage():
def __init__(self):
omni.kit.stage_templates.register_template("test", self.new_stage, 1)
def __del__(self):
omni.kit.stage_templates.unregister_template("test")
def new_stage(self, rootname):
import omni.kit.commands
from pxr import Usd, UsdLux
# Create basic DistantLight
omni.kit.commands.execute(
"CreatePrim",
prim_path="{}/defaultLight".format(rootname),
prim_type="DistantLight",
select_new_prim=False,
# https://github.com/PixarAnimationStudios/USD/commit/b5d3809c943950cd3ff6be0467858a3297df0bb7
attributes={UsdLux.Tokens.inputsAngle: 1.0, UsdLux.Tokens.inputsIntensity: 3000} if hasattr(UsdLux.Tokens, 'inputsIntensity') else \
UsdLux.Tokens.angle: 1.0, UsdLux.Tokens.intensity: 3000},
)
TestStage()
API Reference
- class omni.kit.stage_templates.NewStageExtension
- load_user_templates()
- new_stage_empty(rootname)
- on_shutdown()
- on_startup(ext_id)
- omni.kit.stage_templates.get_action_name(name)
- omni.kit.stage_templates.get_default_template()
Get name of default new_stage template. Used when new_stage is called without template name specified
- Parameters
param1 (str) – template name
- Returns
new_stage template name
- Return type
str
- omni.kit.stage_templates.get_extension_path(sub_directory)
- omni.kit.stage_templates.get_stage_template(name)
Get named new_stage template & create function pointer
- Parameters
param1 (str) – template name
- Returns
new_stage template name & create function pointer
- Return type
tuple
- omni.kit.stage_templates.get_stage_template_list()
Get list of loaded new_stage templates
- Parameters
none –
- Returns
list of groups of new_stage template names & create function pointers
- Return type
list
- omni.kit.stage_templates.load_templates()
- omni.kit.stage_templates.new_stage(on_new_stage_fn=None, template='empty', usd_context=None)
Execute new_stage
- Parameters
param2 (str) – template name, if not specified default name is used
param3 (omni.usd.UsdContext) – usd_context, the usd_context to create new stage
- Returns
nothing
- async omni.kit.stage_templates.new_stage_async(template='empty', usd_context=None)
Execute new_stage asynchronously
- Parameters
param1 (str) – template name, if not specified default name is used
param2 (omni.usd.UsdContext) – usd_context, the usd_context to create new stage
- Returns
awaitable object until stage is created
- omni.kit.stage_templates.new_stage_finalize(create_result, error_message, usd_context, template=None, on_new_stage_fn=None)
- omni.kit.stage_templates.new_stage_with_callback(on_new_stage_fn=None, template='empty', usd_context=None)
Execute new_stage
- Parameters
param1 (callable) – callback when new_stage is created
param2 (str) – template name, if not specified default name is used
param3 (omni.usd.UsdContext) – usd_context, the usd_context to create new stage
- Returns
nothing
- omni.kit.stage_templates.register_template(name, new_stage_fn, group=0, rebuild=True)
Register new_stage Template
- Parameters
param1 (str) – template name
param2 (callable) – function to create template
param3 (int) – group number. User by menu to split into groups with seperators
- Returns
True for success, False when template already exists.
- Return type
bool
- omni.kit.stage_templates.set_transform_helper(prim_path, translate=Gf.Vec3d(0.0, 0.0, 0.0), euler=Gf.Vec3d(0.0, 0.0, 0.0), scale=Gf.Vec3d(1.0, 1.0, 1.0))
- omni.kit.stage_templates.signature(obj, *, follow_wrapped=True, globals=None, locals=None, eval_str=False)
Get a signature object for the passed callable.
- omni.kit.stage_templates.unload_templates()
- omni.kit.stage_templates.unregister_template(name, rebuild: bool = True)
Remove registered new_stage Template
- Parameters
param1 (str) – template name
- Returns
nothing