Primvars - do I need uo use UsdGeom.PrimvarsAPI or can I just GetAttribute?

Let’s say I only care about primvars:foo if it’s defined on the mesh prim that I’m looking at. If it exists, I want to modify it. If it doesn’t exist, I want to do nothing, and I don’t care if it was defined above me(I.e. I actually don’t want to inherit).

In this case, is it okay to just use mesh_prim.GetAttribute(“primvars:foo”), and treat it like a normal attribute with Get and Set?
Or is it really bad to assume the “primvars:” namespace and I have to use UsdGeomPrimvarsAPI for any access to a primvar?

(I don’t know if it matters, but I’m using python)

Hi @SteveHwan , just doing mesh_prim.GetAttribute(“primvars:foo”) will leave you ignorant of whether or not the primvar is “indexed”, and therefore how many values you may expect foo to hold, and how those values will be consumed. PrimvarsAPI will allow you to answer those questions.

4 Likes