Search - User list
Full Version: Layer attributes from VEX
Root » Solaris and Karma » Layer attributes from VEX
jparker
How do I get layer info with VEX?

I want the layer's scale info, so I tried this:

float unitscale = usd_metadata(0, '/', 'metersPerUnit');

But I get a zero instead of the right unit. Is this wrong? Sorry if I'm spamming the forum with obvious questions…
agelosc
I'm not sure about vex but you can easily get anything with a python node and the pxr USD API. For example

from pxr import Usd

stage = Usd.Stage.Open(<usd file path>)
unitscale = stage.GetMetadata("metersPerUnit")

There is already a stage variable when you create a python lop which is the conne ted stage so you can possibly skip the whole Usd.Open() line.

I might have syntax errors but hope it paints a picture. Documentation for the USD python API is a bit tricky but it's worth looking into it.
rafal
It should work. Looks like a bug. Quick check shows that USD API method `UsdStage::GetObjectAtPath(“/”)` does not return the pseudo-root object for some reason.
jparker
I see, I also just tried to get the information with Python and got this error:
>>> stage.GetObjectAtPath('/').GetAllMetadata()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
RuntimeError: Accessed <pxr.Usd.Object object at 0x7f234d02b2f8>

while something like this works in a parameter expression:

pwd().inputs()[0].stage().GetMetadata('metersPerUnit')
jparker
I'll file a bug and send an example scene (and reference this thread).
jparker
Bug #109661
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB