Add_reference_to_stage , assets in USD file invisible warning

I create a usd file named “zeroSample.usd”, I am trying to add it to stage as reference by following code:

self._stage=omni.usd.get_context().get_stage()
ref_path=“/World/zeroSample”
add_reference_to_stage(“file:/home/Documents/Prj/Zeros/zeroSample.usd”, ref_path)

The reference zeroSample added successfully in the stage, but assets in the original USD files are invisible.

[Warning] [omni.usd] Warning: in _ReportErrors at line 2830 of /buildAgent/work/ca6c508eae419cf8/USD/pxr/usd/usd/stage.cpp – Could not open asset @file:/home/isaac/Documents/Prj/Zeros/zeroSimple.usd’@ for reference on prim @anon:0x17c2b7a0:World8.usd@,@anon:0x7fb19c0655d0:World8-session.usda@</World/zeroSample>. (recomposing stage on stage @anon:0x17c2b7a0:World8.usd@ <0x15aa74b0>)

@liuyuanyuan.sh not sure if you’ve already resolved this problem since it’s been a few weeks. i am wondering if this code snippet is somewhat relevant - Create a Reference — Omniverse Developer Guide latest documentation

@Simplychenable , Unfortunately I did not solve this problem.

  1. I tried the method in the link you posted, got the same prompt “recomposing stage on stage”.
    The context of my programming is extension APP.
    As the following picture, I can print the USDA file, but can not see any thing in the viewport.

  2. I skipped this issue by following code, but it is not added as “reference”.

  async def open_stage(self):      
        (result,error)=await omni.usd.get_context().open_stage_async(self._path)     #"file:/home/isaac/Documents/Prj/Zeros/zeroSimple.usd"
        if not result:
            print(f"Errors: on open stage")
        else:
            print(result)
  1. How to solve the problem of “recomposing stage on stage”?

Does the “zeroSample.usd” have a default prim?

image

and just fyi, the URL i meant to link was “Create a Reference” and not “Add a Reference”. i’ve made the necessary change to my last post, sorry for the confusion.

it can be as short as…

import omni.kit.commands
from pxr import Sdf
import omni.usd

omni.kit.commands.execute('CreateReference',
	path_to=Sdf.Path('/World/zeroSample'),
	asset_path='file:/home/Documents/Prj/Zeros/zeroSample.usd',
	usd_context=omni.usd.get_context())

and to iterate, this is assuming zeroSample.usd has a defaultPrim; otherwise, the content of the usd won’t come through.

@Simplychenable ,

  I tried your last post and create the zeroSample reference successfully.

  So  "add"  command contain another stage in the reference?

 Thank you so much!  ^_^
1 Like