All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
util.h File Reference
+ Include dependency graph for util.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  MDataHandleHolder
 RAII-style helper for destructing an MDataHandle obtained from a plug once it goes out of scope. More...
 

Namespaces

 UsdMayaUtil
 General utilities for working with the Maya API.
 

Typedefs

using MDagPathSet = std::set< MDagPath, _CmpDag >
 Set of DAG paths. More...
 
template<typename V >
using MDagPathMap = std::map< MDagPath, V, _CmpDag >
 Mapping of DAG paths to an arbitrary type. More...
 
using MObjectHandleUnorderedSet = std::unordered_set< MObjectHandle, _HashObjectHandle >
 Unordered set of Maya object handles. More...
 
template<typename V >
using MObjectHandleUnorderedMap = std::unordered_map< MObjectHandle, V, _HashObjectHandle >
 Unordered mapping of Maya object handles to an arbitrary type. More...
 

Functions

double ConvertMMToInches (const double mm)
 Converts the given value mm in millimeters to the equivalent value in inches. More...
 
double ConvertInchesToMM (const double inches)
 Converts the given value inches in inches to the equivalent value in millimeters. More...
 
double ConvertMMToCM (const double mm)
 Converts the given value mm in millimeters to the equivalent value in centimeters. More...
 
double ConvertCMToMM (const double cm)
 Converts the given value cm in centimeters to the equivalent value in millimeters. More...
 
PXRUSDMAYA_API double ConvertMDistanceUnitToUsdGeomLinearUnit (const MDistance::Unit mdistanceUnit)
 Converts the given value mdistance in Maya's MDistance units to the equivalent value in USD's metersPerUnit. More...
 
PXRUSDMAYA_API MDistance::Unit ConvertUsdGeomLinearUnitToMDistanceUnit (const double linearUnit)
 Coverts the given value linearUnit in USD's metersPerUnit to the equivalent value in Maya's MDistance units. More...
 
PXRUSDMAYA_API std::string GetMayaNodeName (const MObject &mayaNode)
 Get the full name of the Maya node mayaNode. More...
 
PXRUSDMAYA_API MStatus GetMObjectByName (const std::string &nodeName, MObject &mObj)
 Gets the Maya MObject for the node named nodeName. More...
 
PXRUSDMAYA_API MStatus GetDagPathByName (const std::string &nodeName, MDagPath &dagPath)
 Gets the Maya MDagPath for the node named nodeName. More...
 
PXRUSDMAYA_API MStatus GetPlugByName (const std::string &attrPath, MPlug &plug)
 Gets the Maya MPlug for the given attrPath. More...
 
PXRUSDMAYA_API MPlug GetMayaTimePlug ()
 Get the MPlug for the output time attribute of Maya's global time object. More...
 
PXRUSDMAYA_API MPlug GetMayaShaderListPlug ()
 Get the MPlug for the shaders attribute of Maya's defaultShaderList. More...
 
PXRUSDMAYA_API MObject GetDefaultLightSetObject ()
 Get the MObject for the DefaultLightSet, which should add any light nodes as members for them to take effect in the scene. More...
 
PXRUSDMAYA_API bool isAncestorDescendentRelationship (const MDagPath &path1, const MDagPath &path2)
 
PXRUSDMAYA_API int getSampledType (const MPlug &iPlug, const bool includeConnectedChildren)
 
PXRUSDMAYA_API bool isAnimated (const MObject &mayaObject, const bool checkParent=false)
 Determine if the Maya object mayaObject is animated or not. More...
 
PXRUSDMAYA_API bool isPlugAnimated (const MPlug &plug)
 
PXRUSDMAYA_API bool isIntermediate (const MObject &object)
 Determine if a Maya object is an intermediate object. More...
 
PXRUSDMAYA_API bool isRenderable (const MObject &object)
 
PXRUSDMAYA_API bool isWritable (const MObject &object)
 Determine whether a Maya object can be saved to or exported from the Maya scene. More...
 
const std::string MayaDagDelimiter ("|")
 This is the delimiter that Maya uses to identify levels of hierarchy in the Maya DAG. More...
 
const std::string MayaNamespaceDelimiter (":")
 This is the delimiter that Maya uses to separate levels of namespace in Maya node names. More...
 
PXRUSDMAYA_API std::string stripNamespaces (const std::string &nodeName, const int nsDepth=-1)
 Strip nsDepth namespaces from nodeName. More...
 
PXRUSDMAYA_API std::string SanitizeName (const std::string &name)
 
PXRUSDMAYA_API std::string SanitizeColorSetName (const std::string &name)
 
PXRUSDMAYA_API bool GetLinearShaderColor (const MFnDagNode &node, 1::VtVec3fArray *RGBData, 1::VtFloatArray *AlphaData, 1::TfToken *interpolation, 1::VtIntArray *assignmentIndices)
 Get the base colors and opacities from the shader(s) bound to node. More...
 
PXRUSDMAYA_API bool GetLinearShaderColor (const MFnMesh &mesh, 1::VtVec3fArray *RGBData, 1::VtFloatArray *AlphaData, 1::TfToken *interpolation, 1::VtIntArray *assignmentIndices)
 Get the base colors and opacities from the shader(s) bound to mesh. More...
 
PXRUSDMAYA_API void MergeEquivalentIndexedValues (1::VtFloatArray *valueData, 1::VtIntArray *assignmentIndices)
 Combine distinct indices that point to the same values to all point to the same index for that value. More...
 
PXRUSDMAYA_API void MergeEquivalentIndexedValues (1::VtVec2fArray *valueData, 1::VtIntArray *assignmentIndices)
 Combine distinct indices that point to the same values to all point to the same index for that value. More...
 
PXRUSDMAYA_API void MergeEquivalentIndexedValues (1::VtVec3fArray *valueData, 1::VtIntArray *assignmentIndices)
 Combine distinct indices that point to the same values to all point to the same index for that value. More...
 
PXRUSDMAYA_API void MergeEquivalentIndexedValues (1::VtVec4fArray *valueData, 1::VtIntArray *assignmentIndices)
 Combine distinct indices that point to the same values to all point to the same index for that value. More...
 
PXRUSDMAYA_API void CompressFaceVaryingPrimvarIndices (const MFnMesh &mesh, 1::TfToken *interpolation, 1::VtIntArray *assignmentIndices)
 Attempt to compress faceVarying primvar indices to uniform, vertex, or constant interpolation if possible. More...
 
PXRUSDMAYA_API bool IsAuthored (const MPlug &plug)
 Get whether plug is authored in the Maya scene. More...
 
PXRUSDMAYA_API MPlug GetConnected (const MPlug &plug)
 
PXRUSDMAYA_API void Connect (const MPlug &srcPlug, const MPlug &dstPlug, const bool clearDstPlug)
 
PXRUSDMAYA_API MPlug FindChildPlugByName (const MPlug &plug, const MString &name)
 Get a named child plug of plug by name. More...
 
PXRUSDMAYA_API::SdfPath MayaNodeNameToSdfPath (const std::string &nodeName, const bool stripNamespaces)
 Converts the given Maya node name nodeName into an SdfPath. More...
 
PXRUSDMAYA_API::SdfPath MDagPathToUsdPath (const MDagPath &dagPath, const bool mergeTransformAndShape, const bool stripNamespaces)
 Converts the given Maya MDagPath dagPath into an SdfPath. More...
 
PXRUSDMAYA_API bool GetBoolCustomData (const 1::UsdAttribute &obj, const 1::TfToken &key, const bool defaultValue)
 Convenience function to retrieve custom data. More...
 
template<typename T >
bool getPlugValue (const MFnDependencyNode &depNode, const MString &attr, T *val, bool *isAnimated=nullptr)
 Compute the value of attr, returning true upon success. More...
 
PXRUSDMAYA_API MMatrix GfMatrixToMMatrix (const GfMatrix4d &mx)
 Convert a Gf matrix to an MMatrix. More...
 
PXRUSDMAYA_API bool getPlugMatrix (const MFnDependencyNode &depNode, const MString &attr, MMatrix *outVal)
 
PXRUSDMAYA_API bool setPlugMatrix (const MFnDependencyNode &depNode, const MString &attr, const GfMatrix4d &mx)
 Set a matrix value on plug name attr, of depNode. More...
 
PXRUSDMAYA_API bool setPlugMatrix (const GfMatrix4d &mx, MPlug &plug)
 
PXRUSDMAYA_API bool setPlugValue (const 1::UsdAttribute &attr, MPlug &attrPlug)
 Given an usdAttr , extract the value at the default timecode and write it on attrPlug. More...
 
PXRUSDMAYA_API bool setPlugValue (const 1::UsdAttribute &attr, const 1::UsdTimeCode time, MPlug &attrPlug)
 Given an usdAttr , extract the value at timecode time and write it on attrPlug. More...
 
template<typename T >
bool setPlugValue (const MFnDependencyNode &depNode, const MString &attr, const T &val)
 sets attr to have value val, assuming it exists on depNode. More...
 
PXRUSDMAYA_API TfRefPtr
< MDataHandleHolder > 
GetPlugDataHandle (const MPlug &plug)
 Obtains an RAII helper object for accessing the MDataHandle stored on the plug. More...
 
PXRUSDMAYA_API bool SetNotes (MFnDependencyNode &depNode, const std::string &notes)
 
PXRUSDMAYA_API bool SetHiddenInOutliner (MFnDependencyNode &depNode, const bool hidden)
 
PXRUSDMAYA_API VtDictionary GetDictionaryFromArgDatabase (const MArgDatabase &argData, const VtDictionary &guideDict)
 Reads values from the given argData into a VtDictionary, using the guideDict to figure out which keys and what type of values should be read from argData. More...
 
PXRUSDMAYA_API VtValue ParseArgumentValue (const std::string &key, const std::string &value, const VtDictionary &guideDict)
 Parses value based on the type of key in guideDict, returning the parsed value wrapped in a VtValue. More...
 
PXRUSDMAYA_API std::vector
< std::string > 
GetAllAncestorMayaNodeTypes (const std::string &ty)
 Gets all Maya node types that are ancestors of the given Maya node type ty. More...
 
PXRUSDMAYA_API bool FindAncestorSceneAssembly (const MDagPath &dagPath, MDagPath *assemblyPath=nullptr)
 If dagPath is a scene assembly node or is the descendant of one, populates the *assemblyPath with the assembly path and returns true. More...
 
PXRUSDMAYA_API MBoundingBox GetInfiniteBoundingBox ()
 

Variables

const double MillimetersPerInch = 25.4
 
const double MillimetersPerCentimeter = 10.0