Layer attributes from VEX
3365
5
1
jparker
Member
321 posts
Joined:
オンライン
2020年11月21日 22:30
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
Member
3 posts
Joined: 10月 2016
オフライン
2020年11月23日 12:59
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
スタッフ
1470 posts
Joined: 7月 2005
オフライン
2020年11月23日 13:49
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
Member
321 posts
Joined:
オンライン
2020年11月23日 14:20
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' )
Edited by jparker - 2020年11月23日 14:22:29
jparker
Member
321 posts
Joined:
オンライン
2020年11月23日 14:26
I'll file a bug and send an example scene (and reference this thread).
jparker
Member
321 posts
Joined:
オンライン
2020年11月23日 14:49
Bug #109661