UsdAttribute UsdPrim::GetAttribute(const TfToken& attrName) const { // An invalid prim will present a coding error, and then return an // invalid attribute return UsdAttribute(_Prim(), _ProxyPrimPath(), attrName); }
UsdAttribute PxrUsdMayaWriteUtil::GetOrCreateUsdAttr( const MPlug& plg, const UsdPrim& usdPrim, const std::string &attrName, bool custom) { MObject attrObj(plg.attribute()); TfToken usdAttrName(attrName); if (usdAttrName.IsEmpty()) { printf("Invalid attrName '%s' for %s\n", attrName.c_str(), plg.name().asChar()); return UsdAttribute(); } // See if usdAttr already exists. If so, return. UsdAttribute usdAttr = usdPrim.GetAttribute(usdAttrName); if (usdAttr) { return usdAttr; } SdfValueTypeName attrType = PxrUsdMayaWriteUtil::GetUsdTypeName(plg); // --------------------- // CreateAttribute on USD Prim if specified above if (attrType) { usdAttr = usdPrim.CreateAttribute(usdAttrName, attrType, custom); } else { // Skipping. Unsupported type. } return usdAttr; }