Hi,
I was wondering how I would go about creating a primvar using python inside of Solaris?
I hope someone can help!
Best,
Rich
Creating Primvars with Python in LOPs
5409 4 1-
- Hypershader
- Member
- 37 posts
- Joined: 3月 2017
- オフライン
-
- marcosimonrbl
- Member
- 23 posts
- Joined: 9月 2021
- オフライン
primitive.CreateAttribute(attributeName, Sdf.ValueTypeNames.<type>)
Types I found on the nVidia website: https://developer.nvidia.com/usd/tutorials [developer.nvidia.com]
also helpful: https://graphics.pixar.com/usd/release/api/class_usd_prim.html#a935381d7c7100b583fdcdb0e10dae9e6 [graphics.pixar.com]
Types I found on the nVidia website: https://developer.nvidia.com/usd/tutorials [developer.nvidia.com]
also helpful: https://graphics.pixar.com/usd/release/api/class_usd_prim.html#a935381d7c7100b583fdcdb0e10dae9e6 [graphics.pixar.com]
-
- Hypershader
- Member
- 37 posts
- Joined: 3月 2017
- オフライン
Hey,
Thanks this seems to work great for creatiing an attribute but unfortunately it isn't a primvar so i cannot reference it in a shader
I do need to be able to create a Primvar so any more info in regard to this would be useful
Thanks this seems to work great for creatiing an attribute but unfortunately it isn't a primvar so i cannot reference it in a shader
node = hou.pwd() stage = node.editableStage() from pxr import Sdf, Usd, UsdGeom asset = stage.GetPrimAtPath('/Asset') asset.CreateAttribute('test', Sdf.ValueTypeNames.String)
I do need to be able to create a Primvar so any more info in regard to this would be useful
Edited by Hypershader - 2022年2月18日 07:55:17
-
- Hypershader
- Member
- 37 posts
- Joined: 3月 2017
- オフライン
-
- mtucker
- スタッフ
- 4560 posts
- Joined: 7月 2005
- オフライン
Actually, there is a whole dedicated API for authoring primvars with python:
https://graphics.pixar.com/usd/release/api/class_usd_geom_primvars_a_p_i.html [graphics.pixar.com]
So something like (I didn't actually test this):
The advantage is that you don't need to know all the precise details of how primvars are expressed. You also get a python API for setting the interpolation metadata, using indexed primvars, etc. All of which is equivalent to building the attributes and setting the metadata yourself, but less error prone.
https://graphics.pixar.com/usd/release/api/class_usd_geom_primvars_a_p_i.html [graphics.pixar.com]
So something like (I didn't actually test this):
primvarsapi = UsdGeom.PrimvarsAPI(asset) primvar = primvarsapi.CreatePrimvar('test', Sdf.ValueTypeNames.String) primvar.Set('hi')
The advantage is that you don't need to know all the precise details of how primvars are expressed. You also get a python API for setting the interpolation metadata, using indexed primvars, etc. All of which is equivalent to building the attributes and setting the metadata yourself, but less error prone.
-
- Quick Links