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, attributes={UsdLux.Tokens.angle: 1.0, UsdLux.Tokens.intensity: 3000},

)

TestStage()


API Reference

class omni.kit.stage_templates.CloudydayStage

Bases: object

new_stage(rootname)
class omni.kit.stage_templates.NewStageExtension(self: omni.ext._extensions.IExt)None

Bases: omni.ext._extensions.IExt

load_user_templates()
new_stage_empty(rootname)
on_shutdown()
on_startup(ext_id)
class omni.kit.stage_templates.StudioStage

Bases: object

new_stage(rootname)
class omni.kit.stage_templates.SunflowersStage

Bases: object

new_stage(rootname)
class omni.kit.stage_templates.SunlightStage

Bases: object

new_stage(rootname)
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

class omni.kit.stage_templates.partial

Bases: object

partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords.

args

tuple of arguments to future partial calls

func

function object to use in future partial calls

keywords

dictionary of keyword arguments to future partial calls

omni.kit.stage_templates.register_template(name, new_stage_fn, group=0)

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))
class omni.kit.stage_templates.suppress(*exceptions)

Bases: contextlib.AbstractContextManager

Context manager to suppress specified exceptions

After the exception is suppressed, execution proceeds with the next statement following the with statement.

with suppress(FileNotFoundError):

os.remove(somefile)

# Execution still resumes here if the file was already removed

omni.kit.stage_templates.unload_templates()
omni.kit.stage_templates.unregister_template(name)

Remove registered new_stage Template

Parameters

param1 (str) – template name

Returns

nothing