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
3536 4 1- Hypershader
- Member
- 37 posts
- Joined: March 2017
- Offline
- marcosimonrbl
- Member
- 23 posts
- Joined: Sept. 2021
- Offline
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: March 2017
- Offline
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 - Feb. 18, 2022 07:55:17
- Hypershader
- Member
- 37 posts
- Joined: March 2017
- Offline
- mtucker
- Staff
- 4438 posts
- Joined: July 2005
- Offline
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