C++ API Reference
MPxAssembly Class Referenceabstract

Parent class of all user defined assembly nodes. More...

#include <MPxAssembly.h>

+ Inheritance diagram for MPxAssembly:

Public Member Functions

 MPxAssembly ()
 Class constructor. More...
 
 ~MPxAssembly () override
 Class destructor.
 
MPxNode::Type type () const override
 Returns the type of node that this is. More...
 
virtual MString createRepresentation (const MString &input, const MString &type, const MString &representation, MDagModifier *undoRedo=NULL, MStatus *ReturnStatus=NULL)=0
 Create a representation and add it to the list of representations. More...
 
virtual bool activate (const MString &rep)
 Activate a representation in the list of representations. More...
 
virtual MString getActive () const =0
 Get the active representation in the list of representations. More...
 
virtual bool isActive (const MString &rep) const
 Determines whether the argument representation is the active representation. More...
 
virtual MStringArray getRepresentations (MStatus *ReturnStatus=NULL) const =0
 Returns an array of the representations managed by the node attached to this function set. More...
 
virtual MString getRepType (const MString &rep) const =0
 Get the type of the argument representation. More...
 
virtual MString getRepLabel (const MString &rep) const =0
 Get the label of the argument representation. More...
 
virtual MStringArray repTypes () const =0
 Return the list of representation types that can be created for this assembly node. More...
 
virtual MStatus deleteRepresentation (const MString &rep)=0
 Delete a representation managed by the node. More...
 
virtual MStatus deleteAllRepresentations ()=0
 Delete all representations managed by this node. More...
 
virtual MString getRepNamespace () const
 Get the representations namespace of this assembly node. More...
 
virtual void updateRepNamespace (const MString &repNamespace)
 This method is called by Maya to tell the assembly that the base representation namespace specified by getRepNamespace() has been changed. More...
 
virtual MString setRepName (const MString &rep, const MString &newName, MStatus *ReturnStatus=NULL)=0
 Rename a representation. More...
 
virtual MStatus setRepLabel (const MString &rep, const MString &label)=0
 Change the representation label. More...
 
virtual bool supportsEdits () const
 Opt in/out of Maya's edit tracking system. More...
 
virtual bool supportsMemberChanges () const
 Can members of the assembly be changed? More...
 
virtual bool canRepApplyEdits (const MString &representation) const
 Determines whether the given representation can apply edits to its data. More...
 
virtual bool handlesAddEdits () const
 Determines whether the assembly is responsible for supplying edits to its data. More...
 
virtual MStatus addEdits ()
 Add edits so they can be applied by Maya when switching representations. More...
 
virtual void beforeSave ()
 Method called by Maya to allow assemblies to do any required preparation before file save. More...
 
virtual void postLoad ()
 Method called by Maya to initialize assemblies after their creation. More...
 
virtual void memberAdded (MObject &member)
 Called immediately after the argument node has been added to this assembly. More...
 
virtual void memberRemoved (MObject &member)
 Called immediately after the argument node has been removed from this assembly. More...
 
bool performActivate (const MString &representation)
 Provide access to the Maya core representation activation functionality. More...
 
bool performInactivate ()
 Provide access to the Maya core representation inactivation functionality. More...
 
virtual bool activateRep (const MString &representation)=0
 Called during activation to activate the new active representation. More...
 
virtual bool inactivateRep ()
 Called during activation to inactivate the currently active representation. More...
 
virtual void postActivateRep (const MString &representation)
 Called after activation of a representation including the load, activation and edits of any created sub-assemblies but prior to the application of edits. More...
 
virtual void preApplyEdits ()
 Method called by performActivate() just before edits are applied. More...
 
virtual void preUnapplyEdits ()
 Method called by performInactivate() just before edits are unapplied. More...
 
virtual void postApplyEdits ()
 Method called by performActivate() just after edits are applied. More...
 
virtual void postUnapplyEdits ()
 Method called by performInactivate() just after edits are unapplied. More...
 
virtual MString getInitialRep (const MObject &assembly, bool &hasInitialRep, MStatus *ReturnStatus=NULL) const
 Get the initial representation to use when the specified assembly is first loaded. More...
 
bool activating () const
 Return true when this assembly is activating a representation, within a call to activate() or activateNonRecursive(). More...
 
MTypeId typeId () const override
 Returns the TYPEID of this node. More...
 
MString typeName () const override
 Returns the type name of this node. More...
 
MString name () const override
 Returns the name of this particular instance of this class. More...
 
MObject thisMObject () const override
 Returns the MObject associated with this user defined node. More...
 
MStatus setExistWithoutInConnections (bool flag) override
 This method specifies whether or not the node can exist without input connections. More...
 
bool existWithoutInConnections (MStatus *ReturnStatus=NULL) const override
 Determines whether or not this node can exist without input connections. More...
 
MStatus setExistWithoutOutConnections (bool flag) override
 This method specifies whether or not the node can exist without output connections. More...
 
bool existWithoutOutConnections (MStatus *ReturnStatus=NULL) const override
 Determines whether or not this node can exist without output connections. More...
 
MStatus addSetAttrEdit (const MString &targetAssembly, const MString &plugName, const MString &parameters, MPxEditData *editData=NULL)
 Add a set attribute edit to be applied by Maya when switching representations. More...
 
MStatus addConnectAttrEdit (const MString &targetAssembly, const MString &srcPlugName, const MString &dstPlugName, MPxEditData *editData=NULL)
 Add a connect attribute edit to be applied by Maya when switching representations. More...
 
MStatus addDisconnectAttrEdit (const MString &targetAssembly, const MString &srcPlugName, const MString &dstPlugName, MPxEditData *editData=NULL)
 Add a disconnect attribute edit to be applied by Maya when switching representations. More...
 
MStatus addDeleteAttrEdit (const MString &targetAssembly, const MString &nodeName, const MString &attributeName, MPxEditData *editData=NULL)
 Add a delete attribute edit to be applied by Maya when switching representations. More...
 
MStatus addAddAttrEdit (const MString &targetAssembly, const MString &nodeName, const MString &longAttributeName, const MString &shortAttributeName, const MString &parameters, MPxEditData *editData=NULL)
 Add an add attribute edit to be applied by Maya when switching representations. More...
 
MStatus addParentEdit (const MString &targetAssembly, const MString &childNodeName, const MString &parentNodeName, const MString &parameters, MPxEditData *editData=NULL)
 Add a parent edit to be applied by Maya when switching representations. More...
 
- Public Member Functions inherited from MPxNode
 MPxNode ()
 Constructor. More...
 
virtual ~MPxNode ()
 Destructor.
 
virtual void postConstructor ()
 Post constructor. More...
 
virtual MStatus compute (const MPlug &, MDataBlock &)
 This method should be overridden in user defined nodes. More...
 
virtual bool getInternalValue (const MPlug &, MDataHandle &)
 This method is overridden by nodes that store attribute data in some internal format. More...
 
virtual bool setInternalValue (const MPlug &, const MDataHandle &)
 This method is overridden by nodes that store attribute data in some internal format. More...
 
virtual int internalArrayCount (const MPlug &) const
 This method is overridden by nodes that have internal array attributes which are not stored in Maya's datablock. More...
 
virtual void copyInternalData (MPxNode *)
 This method is overridden by nodes that store attribute data in some internal format. More...
 
virtual MStatus legalConnection (const MPlug &, const MPlug &, bool asSrc, bool &isLegal) const
 This method allows you to check for legal connections being made to attributes of this node. More...
 
virtual MStatus legalDisconnection (const MPlug &, const MPlug &, bool asSrc, bool &isLegal) const
 This method allows you to check for legal disconnections being made to attributes of this node. More...
 
virtual MStatus setDependentsDirty (const MPlug &plug, MPlugArray &plugArray)
 This method can be overridden in user defined nodes to specify which plugs should be set dirty based upon an input plug {plugBeingDirtied} which Maya is marking dirty. More...
 
virtual MStatus preEvaluation (const MDGContext &context, const MEvaluationNode &evaluationNode)
 Prepare a node's internal state for threaded evaluation. More...
 
virtual MStatus postEvaluation (const MDGContext &context, const MEvaluationNode &evaluationNode, PostEvaluationType evalType)
 Clean up node's internal state after threaded evaluation. More...
 
virtual SchedulingType schedulingType () const
 When overridden this method controls the degree of parallelism supported by the node during threaded evaluation. More...
 
virtual void getCacheSetup (const MEvaluationNode &, MNodeCacheDisablingInfo &, MNodeCacheSetupInfo &, MObjectArray &) const
 Provide node-specific setup info for the Cached Playback system. More...
 
virtual void configCache (const MEvaluationNode &, MCacheSchema &) const
 Defines the node's behavior when participating in Cached Playback. More...
 
virtual MTimeRange transformInvalidationRange (const MPlug &source, const MTimeRange &input) const
 Override this method to register this node as an Invalidation-Range-Transformation kernel (IRT kernel) An IRT kernel node will change the invalidation time range for its downstream nodes For example, Dynamics-solver will transform invalidation time range [a,b] to [a,+inf) And Clip-Time-Editor will send out the invalidation range for each of the clip [a,b] to ( [t0+a,t0+b] U [t1+a,t1+b] U [t2+a,t2+b] U ... More...
 
bool hasInvalidationRangeTransformation () const
 Checks if this MPxNode derived node overrides the MPxNode::transformInvalidationRange method.
 
virtual MStatus connectionMade (const MPlug &, const MPlug &, bool asSrc)
 This method gets called when connections are made to attributes of this node. More...
 
virtual MStatus connectionBroken (const MPlug &, const MPlug &, bool asSrc)
 This method gets called when connections are broken with attributes of this node. More...
 
virtual MStatus dependsOn (const MPlug &, const MPlug &, bool &depends) const
 This method may be overridden by the user defined node. More...
 
virtual bool isPassiveOutput (const MPlug &) const
 This method may be overridden by the user defined node if it wants to provide output attributes which do not prevent value modifications to the destination attribute. More...
 
virtual MStatus shouldSave (const MPlug &, bool &isSaving)
 This method may be overridden by the user defined node. More...
 
virtual MPlug passThroughToOne (const MPlug &) const
 This method may be overridden by nodes that have a one-to-one relationship between an input attribute and a corresponding output attribute. More...
 
virtual bool passThroughToMany (const MPlug &, MPlugArray &) const
 This method is overridden by nodes that want to control the traversal behavior of some Maya search algorithms which traverse the history/future of shape nodes looking for directly related nodes. More...
 
virtual bool isAbstractClass () const
 Override this class to return true if this node is an abstract node. More...
 
virtual bool isTrackingTopology () const
 Override this class to return true if this node wants to track topology. More...
 
virtual MStringArray getFilesToArchive (bool shortName=false, bool unresolvedName=false, bool markCouldBeImageSequence=false) const
 Use this method to return all external files used by this node. More...
 
virtual void getExternalContent (MExternalContentInfoTable &table) const
 Returns the external content (files) that this node depends on. More...
 
bool addExternalContentForFileAttr (MExternalContentInfoTable &, const MObject &attr) const
 Adds content info to the specified table from a file path attribute. More...
 
bool setExternalContentForFileAttr (const MObject &attr, const MExternalContentLocationTable &)
 Sets content info in the specified attribute from the table. More...
 
virtual void setExternalContent (const MExternalContentLocationTable &)
 Changes the location of external content in batch. More...
 
void _setMPSafe (bool isMPSafe)
 This method is obsolete. More...
 
MDataBlock _forceCache (const MDGContext &)
 This method is obsolete. More...
 
virtual bool getInternalValueInContext (const MPlug &, MDataHandle &, MDGContext &)
 This method is obsolete. More...
 
virtual bool setInternalValueInContext (const MPlug &, const MDataHandle &, MDGContext &)
 This method is obsolete. More...
 
virtual int internalArrayCount (const MPlug &, const MDGContext &) const
 This method is obsolete. More...
 

Static Public Member Functions

static const char * className ()
 Returns the name of this class. More...
 
- Static Public Member Functions inherited from MPxNode
static MStatus addAttribute (const MObject &attr)
 This method adds a new attribute to a user defined node type during the type's initialization. More...
 
static MStatus inheritAttributesFrom (const MString &parentClassName)
 This method allows a class of plugin node to inherit all of the attributes of a second class of plugin node. More...
 
static MStatus attributeAffects (const MObject &whenChanges, const MObject &isAffected)
 This method specifies that a particular input attribute affects a specific output attribute. More...
 
static MStatus attributeAffects (const MObject &whenChanges, const MObject &isAffected, bool affectsTopology)
 This method is an extension to the other version of the attributeAffects method. More...
 
static const char * className ()
 Returns the name of this class. More...
 

Protected Member Functions

MDataBlock forceCache () override
 USE _forceCache() IN SCRIPT. More...
 
MStatus setDoNotWrite (bool flag) override
 USE _setDoNotWrite() IN SCRIPT. More...
 
bool doNotWrite (MStatus *ReturnStatus=nullptr) const override
 USE _doNotWrite() IN SCRIPT. More...
 
void setMPSafe (bool flag) override
 This method is obsolete. More...
 
virtual MString getInitialRep (const MObject &assembly, MStatus *ReturnStatus=NULL) const
 This method is obsolete. More...
 
- Protected Member Functions inherited from MPxNode
virtual MDataBlock forceCache (const MDGContext &)
 This method is obsolete. More...
 

Additional Inherited Members

- Public Types inherited from MPxNode
enum  Type {
  kDependNode, kLocatorNode, kDeformerNode, kManipContainer,
  kSurfaceShape, kFieldNode, kEmitterNode, kSpringNode,
  kIkSolverNode, kHardwareShader, kHwShaderNode, kTransformNode,
  kObjectSet, kFluidEmitterNode, kImagePlaneNode, kParticleAttributeMapperNode,
  kCameraSetNode, kConstraintNode, kManipulatorNode, kMotionPathNode,
  kClientDeviceNode, kThreadedDeviceNode, kAssembly, kSkinCluster,
  kGeometryFilter, kBlendShape, kLast
}
 Defines the type of node. More...
 
enum  SchedulingType {
  kParallel, kSerial, kGloballySerial, kUntrusted ,
  kDefaultScheduling = kSerial, kSerialize = kSerial, kGloballySerialize = kGloballySerial
}
 Defines the degree of parallelism of a node. More...
 
- Static Public Attributes inherited from MPxNode
static MObject message
 message attribute
 
static MObject isHistoricallyInteresting
 is historically interesting attribute
 
static MObject caching
 caching attribute
 
static MObject state
 state attribute
 
static MObject frozen
 frozen attribute
 

Detailed Description

Parent class of all user defined assembly nodes.

MPxAssembly is the parent class of all user defined assembly nodes. User defined assemblies are DAG nodes. An assembly allows activation of one of its representations. The implementation of representations is not specified by the MPxAssembly API: for example, a representation can be a data structure internal to the assembly implementation, identified by string name, or it can be a DAG node.

An assembly object is also a DAG container. As such, operations on containers can be done on assemblies.

This class can be used to implement new kinds of assembly nodes within Maya that integrate with Maya's scene assembly workflows.

For use of assemblies, see function set MFnAssembly. For use of container functionality on assemblies, see function set MFnContainerNode.

Deriving from MPxAssembly to Extend Scene Assembly

To extend Maya's scene assembly, you can write a dependency graph plug-in with an assembly node that is derived from MPxAssembly. The plug-in can be written either in C++ or in Python. A minimal scene assembly node must maintain a list of representations, and be able to activate one of them, inactivating the previous representation in the process.

An MPxAssembly derived node must be created with no representation active. In other words, after the MPxAssembly derived class constructor executes, the getActive() method must return the empty string. This is to ensure support for workflows where nested assembly hierarchies are expanded a single level at a time.

Fundamental Properties of Representations

The fundamental properties of a representation are the following:

Name
The MPxAssembly API refers to representations by string names, so the plug-in must have a correspondence between these names and its own representation data structures. The representation name is to be used in programming, should not be localized, and is not shown in the Maya UI.
Label
This is the representation property that is shown in the Maya UI to identify a representation to a user, and is the property that should be localized if desired.
Type
This representation property expresses commonality with other representations of the same type, and is used to control creation through createRepresentation(). It should not be localized.

Virtual Method Overrides

Here is a summary description of how to override MPxAssembly methods to implement a scene assembly node. The following MPxAssembly pure virtual methods must be overriden by even the most basic scene assembly node.

createRepresentation()
Use the type-dependent input, the representation type, and the given representation name to create a representation, and add it to the list of representations.
getActive()
Return the currently-active representation.
getRepresentations()
Return the list of representation names.
getRepType()
Return the type a representation.
getRepLabel()
Return the label of a representation.
repTypes()
Return the list of representation types that can be created.
deleteRepresentation()
Delete a representation from the list of representations.
deleteAllRepresentations()
Delete all representations.
setRepName()
Set a representation's name.
setRepLabel()
Set a representation's label.
activateRep()
Choose a representation to be active in the Maya scene, and inactivate the previously-active representation.

All other virtual methods have default implementations in MPxAssembly. Please refer to the documentation of these methods to determine if this default behavior is appropriate for your plug-in.

Non-Destructive Edit Tracking

Assembly nodes can track certain edits done on their members. These edits are non-destructive and recorded separately from the representation data onto which they are applied. Please see the Maya documentation for more details. Edits are a property of the assembly node, not of individual representations, and when switching active representations will be applied to a newly-activated representation if the representation can apply edits (see canRepApplyEdits()).

A plug-in node can opt in to the Maya edit tracking system simply by overriding supportsEdits() to return true.

To interact with edits once they have been created, see MItEdits.

Namespace Support

To avoid node name clashes on member nodes, each assembly node can optionally have a representation namespace, a namespace into which all nodes resulting from activating a representation will be placed. This representation namespace is always a child namespace of the namespace in which the assembly node itself has been placed. In the case of nested assemblies, this will produce a hierarchy of namespaces that matches the hierarchy of assemblies.

Without the use of namespaces, member node name clashes will be resolved by Maya adding a numerical suffix to clashing nodes. If an assembly node is tracking edits on its members, this name clash resolution will cause edits to fail, as edits are applied by name. Therefore, the use of representation namespaces is very strongly recommended when tracking assembly member edits.

Activate Support

An MPxAssembly derived class can completely override the activation of a representation (and therefore inactivation of the previously-active representation) provided by activate(). However, MPxAssembly provides the performActivate() and performInactivate() non-virtual methods as building blocks from which a derived class activate() method can be implemented. See the performActivate() and performInactivate() methods for a description of services that can be useful to derived class implementations of activate().

Assembly Integration into Maya

Once a derived assembly node type has been implemented, and registered into Maya's type system through MFnPlugin::registerNode(), it should be registered to the assembly command as an available assembly node type. See the assembly command documentation for more details.

MPxAssembly::inactivateRep() and undo

The default representation inactivation code flushes the undo queue on activating a new representation. This is done for performance reasons: undoable inactivation of the previously-active representation with a very large number of nodes and attribute connections (e.g. a large and deeply-nested hierarchy) would require an undoable delete, which is time-consuming (to record the operations to undo), and memory-consuming (as the undo data is stored in memory). The consequence of this is that once a representation switch is done, any operations previously on the undo queue are lost.

However, this behavior is under plugin control, by overriding MPxAssembly::inactivateRep(). If the current representation is known to be lightweight (e.g. in terms of number of Maya nodes), a plugin can bypass the default representation inactivation code, and implement its own inactivation using the normal undoable delete, and therefore preserve undo capability.

Top-Level Assemblies versus Nested Assemblies

Assembly nodes can be created inside a hierarchy of assemblies. An assembly can be nested inside another assembly; the nested assembly is a DAG child of its parent assembly. MFnAssembly::getParentAssembly() and MFnAssembly::getSubAssemblies() can be used to efficiently navigate the hierarchy of assembly nodes. Nested assemblies are created through the activation of a representation on their parent assembly.

An assembly node that does not have an assembly parent is called a top-level assembly. It is created through file I/O (either opening a file, or importing a file at the top level), or through scripting. Top-level assemblies have special properties:

  • Top-level assemblies are saved as part of the Maya file being edited (the top-level Maya file). Nested assemblies are not saved in the top-level Maya file. They are created by their parent assembly, and are saved elsewhere, or created procedurally by their parent's activation code.
  • Top-level assemblies collect and store all non-destructive edits made to nodes under their DAG hierarchy while editing the top-level Maya file. Nested assemblies can contain edits which will be applied to nodes under their DAG hierarchy, but these edits are read-only and cannot be changed or deleted, only overridden. In contrast, edits on top-level assemblies can be added and deleted. In a hierarchy of assembly nodes, the application of edits is also hierarchical: edits from leaf assemblies are applied first, followed by parent edits, and so on, ending at the top-level assemblies. When edits are made to the same Maya data structure from multiple levels in the hierarchy, parent edits override child edits.
  • Top-level assemblies created through scripting are not initialized by Maya through postLoad(). Nested assemblies are always initialized by Maya through postLoad(), and top-level assemblies created by file I/O are initialized by Maya, but top-level assemblies created through scripting are not, and the script should call postLoad() on the assembly, if required.
Examples:
sceneAssembly/adskRepresentationFactory.h, sceneAssembly/adskRepresentations.cpp, sceneAssembly/adskRepresentations.h, and sceneAssembly/assemblyDefinition.h.

Constructor & Destructor Documentation

OPENMAYA_MAJOR_NAMESPACE_OPEN MPxAssembly ( )

Class constructor.

Any calls to the MPxAssembly methods must be done in the postConstructor method and not here.

Member Function Documentation

MPxNode::Type type ( ) const
overridevirtual

Returns the type of node that this is.

This is used to differentiate user defined nodes that are derived off different MPx base classes.

It is not necessary to override this method.

Returns
Type of the node (MPxNode::kAssembly)

Reimplemented from MPxNode.

MString createRepresentation ( const MString input,
const MString type,
const MString representation,
MDagModifier undoRedo = NULL,
MStatus ReturnStatus = NULL 
)
pure virtual

Create a representation and add it to the list of representations.

The input argument string is used as input data to the representation creation process. The semantics of this input are defined by the assembly derived class.

If passed in non-empty, the representation argument is used as a starting point for the representation name. This string value can be modified by the derived implementation to meet representation name uniqueness, or other constraints. If empty, the implementation is responsible for creating the representation name. The final representation name is returned by this method, after it has been added to the assembly.

If non-null, the pointer to an MDagModifier object can be used to help implement undo / redo for createRepresentation(): its redoIt() and undoIt() methods can be called in an MPxCommand. Note that MDagModifier can execute an arbitrary command through MDGModifier::commandToExecute().

Parameters
[in]inputInput data for representation creation.
[in]typeType of representation to create.
[in]representationRepresentation name starting point.
[out]undoRedoPointer to MDagModifier object, for undo / redo purposes.
[out]ReturnStatusReturn status.
Returns
Added representation name.
Status Codes:
  • MS::kSuccess Representation addition succeeded. All other status codes indicate failure.
Examples:
sceneAssembly/assemblyDefinition.h.
bool activate ( const MString representation)
virtual

Activate a representation in the list of representations.

Derived implementations should inactivate the currently-active representation, if any, activate the newly-active representation, and return true for success. If the argument representation is not in the list of this node's representations, this method should return false. Passing in an empty string argument means inactivate the previously-active representation (if any), activate no representation, and return true.

The default implementation does the following:

// If the argument representation is not an empty string, check that
// it is one of the assembly's representations. If not, return false.
// Perform the activation by inactivating the previously-active
// representation, and activating the new one.
return performActivate(representation);
}
return false;

See performInactivate() and performActivate() documentation for more details.

If you have opted into Maya's edit tracking system by overriding MPxAssembly::supportsEdits() to return true, you must call performActivate() and performInactivate() from within your implementation of activate() to get proper edit handling behaviour. This will ensure that edits are properly saved and restored when you switch representations.

Parameters
[in]representationRepresentation to activate.
Returns
Whether activation of the argument representation was successful or not.
MString getActive ( ) const
pure virtual

Get the active representation in the list of representations.

Derived implementations should return the active representation, if any, else an empty string. If the list of representations is empty, the return object should be an empty string.

Returns
The active representation, if any, else an empty string.
Examples:
sceneAssembly/assemblyDefinition.h.
bool isActive ( const MString representation) const
virtual

Determines whether the argument representation is the active representation.

The default implementation compares the argument representation to the result of getActive().

Parameters
[in]representationRepresentation to query.
Returns
true if the argument is active, false otherwise.
MStringArray getRepresentations ( MStatus ReturnStatus = NULL) const
pure virtual

Returns an array of the representations managed by the node attached to this function set.

Parameters
[out]ReturnStatusReturn status
Returns
representations array.
Status Codes:
  • MS::kSuccess The method was successful to get the representations.
  • MS::kFailure The method failed to get the representations.
Examples:
sceneAssembly/assemblyDefinition.h.
MString getRepType ( const MString representation) const
pure virtual

Get the type of the argument representation.

The type of a representation is a string that expresses its commonality with other representations of this assembly type. The type string does not have to be user-readable, and does not have to be localized; the type label should be used for UI purposes. If the argument representation is not found in this assembly, an empty string is returned.

Parameters
[in]representationRepresentation whose type must be returned.
Returns
Representation type.
Examples:
sceneAssembly/assemblyDefinition.h.
MString getRepLabel ( const MString representation) const
pure virtual

Get the label of the argument representation.

The label of a representation is a string that is meant to be shown in the UI and identify the representation meaningfully to a user. The representation label should support localization requirements. If the argument representation is not found in this assembly, an empty string is returned.

Parameters
[in]representationRepresentation whose label must be returned.
Returns
Representation label.
Examples:
sceneAssembly/assemblyDefinition.h.
MStringArray repTypes ( ) const
pure virtual

Return the list of representation types that can be created for this assembly node.

This can be a fixed list of representation types, or it can vary according to the state of the assembly node. For example, an assembly node might only want to allow one representation of a given type, so repTypes() could be used to enforce that constraint.

Returns
Array of representation types.
Examples:
sceneAssembly/assemblyDefinition.h.
MStatus deleteRepresentation ( const MString rep)
pure virtual

Delete a representation managed by the node.

Parameters
[in]repRepresentation to delete.
Returns
Return status.
Status Codes:
  • MS::kSuccess The method successfully deleted the representation.
  • MS::kFailure The method failed to delete the representation.
Examples:
sceneAssembly/assemblyDefinition.h.
MStatus deleteAllRepresentations ( )
pure virtual

Delete all representations managed by this node.

Returns
Return status.
Status Codes:
  • MS::kSuccess The method successfully deleted all representations.
  • MS::kFailure The method failed to delete all representations.
Examples:
sceneAssembly/assemblyDefinition.h.
MString getRepNamespace ( ) const
virtual

Get the representations namespace of this assembly node.

This is the namespace where nodes created by the activation of a representation will be added. This namespace is shared by all representations. The name can be updated by Maya if a name clash occurs when the namespace is added to its parent namespace (see MPxAssembly::updateRepNamespace() for details).

The default implementation returns a namespace formatted as follows: assembly base name appended with the '_NS' prefix. The plugin could decide to not support namespaces by returning an empty string.

Returns
Namespace for representations.
Examples:
sceneAssembly/assemblyDefinition.h, and sceneAssembly/assemblyReference.cpp.
void updateRepNamespace ( const MString repNamespace)
virtual

This method is called by Maya to tell the assembly that the base representation namespace specified by getRepNamespace() has been changed.

Parameters
[in]repNamespaceNew namespace for representations.
MString setRepName ( const MString representation,
const MString newName,
MStatus ReturnStatus = NULL 
)
pure virtual

Rename a representation.

The newName argument is used as a starting point for the new representation name. This string value can be modified by the derived implementation to meet representation name uniqueness, or other constraints. This method returns the final representation name.

Parameters
[in]representationCurrent representation name.
[in]newNameNew representation name starting point.
[out]ReturnStatusReturn status.
Returns
New representation name.
Status Codes:
  • MS::kSuccess The method successfully renamed the representation.
  • MS::kFailure The method failed to rename the representation.
Examples:
sceneAssembly/assemblyDefinition.h.
MStatus setRepLabel ( const MString representation,
const MString label 
)
pure virtual

Change the representation label.

Parameters
[in]representationRepresentation name.
[in]labelNew representation label.
Returns
Return status.
Status Codes:
  • MS::kSuccess The method successfully changed the representation label.
  • MS::kFailure The method failed to change the representation label.
Examples:
sceneAssembly/assemblyDefinition.h.
bool supportsEdits ( ) const
virtual

Opt in/out of Maya's edit tracking system.

Override this method to return true if you want your assembly to support tracking of edits to its member nodes.

The edits system is node-based and only representations that have Maya nodes can handle tracking. Only certain types of edits can be tracked (see MItEdits for more details).

Use the MItEdits interface to manage/query edits generated by the edits system.

The default implementation returns false, so edits are not tracked.

Returns
Whether to track edits on member nodes or not.
bool supportsMemberChanges ( ) const
virtual

Can members of the assembly be changed?

If the assembly does not use Maya's edit tracking system (see supportsEdits()), does it support changes to its member nodes, outside of activation? If so, this means that any mutating operation on Maya nodes (parenting, connecting, disconnecting, renaming, deleting, setting attributes, adding attributes, removing attributes, locking) can be performed on member nodes of the assembly.

This method is only used if supportsEdits() returns false. If supportsEdits() returns true, Maya will track edits to assembly members, and the return value of supportsMemberChanges() will have no meaning.

The default implementation returns false, so that any mutating operation to member nodes of the assembly is prevented, and the assembly behaves as a read-only container of nodes. Override this method to return true if the assembly supports changes to its member nodes, e.g. if it implements its own edit tracking system without using Maya's.

This predicate is only used outside of representation activation. During activation, all types of changes to the assembly's members are allowed, including of course deleting the previous representation's nodes, and creating nodes for the new representation.

bool canRepApplyEdits ( const MString representation) const
virtual

Determines whether the given representation can apply edits to its data.

The default implementation returns false.

Parameters
[in]representationRepresentation to query.
Returns
true if the representation can apply tracked edits, false otherwise.
Examples:
sceneAssembly/assemblyDefinition.h.
bool handlesAddEdits ( ) const
virtual

Determines whether the assembly is responsible for supplying edits to its data.

If this method returns true, Maya will call MPxAssembly::addEdits(). These edits will later be applied, either by Maya, or by the assembly through MPxAssembly::applyEdits(), if MPxAssembly::handlesApplyEdits() returns true.

Edits can be added for any node in the assembly's representations, which includes edits to any nested assembly of this assembly. In a scene with multiple levels of nested assemblies, if more than one nested assembly has edits to a given lower-level nested assembly, edits are applied by Maya starting at the most nested assembly level, moving up the chain of nesting assemblies. In this way, the most nested assembly's edit are overridden by less nested assembly edits, if they edit the same attribute or connection.

Returns
true if the assembly adds edits, false if no edits are added.
MStatus addEdits ( )
virtual

Add edits so they can be applied by Maya when switching representations.

This method is called by Maya to allow an assembly node to provide edits to be applied at each representation switch. These edits will later be applied, either by Maya, or by the assembly through MPxAssembly::applyEdits(), if MPxAssembly::handlesApplyEdits() returns true.

Edits can be added for any node in the assembly's representations, which includes edits to any nested assembly of this assembly. In a scene with multiple levels of nested assemblies, if more than one nested assembly has edits to a given lower-level nested assembly, edits are applied by Maya starting at the most nested assembly level, moving up the chain of nesting assemblies. In this way, the most nested assembly's edit are overridden by less nested assembly edits, if they edit the same attribute or connection.

In the event that edits have already been added to this assembly (e.g. from a Maya scene representation), the new edits will simply be added to the list.

To add edits for a node, the plugin must call the methods addSetAttrEdit(), addConnectAttrEdit(), addDisconnectAttrEdit(), addDeleteAttrEdit(), and addAddAttrEdit(), as appropriate, for each edit to be added. An assembly should only add edits that it owns, and not those of nested assemblies: those will be queried by Maya separately. The assembly on which an edit is added is referred to as the edit owner.

The methods for adding edits require a targetAssembly name to be specified. The targetAssembly name is the most enclosing assembly holding the edited node. The targetAssembly is always specified as a node name relative to the namespace of this parent assembly (i.e. the edit owner) on which the method is being called.

To specify a relative node name that is in a namespace at or above the parent assembly namespace, a special syntax of "..:" is incorporated to indicate the parent namespace without explicitly naming it.

Use of this convention is necessary when the targetAssembly is the same as the parent assembly. The targetAssembly name in this case would be the same as the parent assembly name and would be specified as "..:parentAssemblyName".

A similar convention is used for specifying node names that reside in the parent assembly namespace, for example to specify the destination attribute for an edit, the format "..:parentAssemblyNamespace:nodeName.attr"

The implementation in this class returns MS::kFailure.

Returns
Return status.
Status Codes:
  • MS::kSuccess The method succeeded.
  • MS::kFailure No valid node attached to function set.
void beforeSave ( )
virtual

Method called by Maya to allow assemblies to do any required preparation before file save.

It is called by Maya on top-level assemblies that are about to be saved, before the file I/O operation is actually performed.

Note that if this assembly supports edit tracking, any changes made within beforeSave() will not be recorded as edits.

Default implementation is to do nothing.

void postLoad ( )
virtual

Method called by Maya to initialize assemblies after their creation.

It is called on top-level assemblies after file I/O has completed, and on nested assemblies after the representation that contains them has finished activating. Maya does not call the postLoad() method when creating a node directly through the assembly command; it will only do so in two cases, (1) after file I/O (top-level assemblies only), or (2) after activation (nested assemblies only).

Note how this is later than MPxNode::postConstructor(), which is called immediately after the node has been created. For example, if the assembly is created through file I/O, the file I/O operation that created the node in the scene is not complete at the point of the postConstructor() call.

In contrast, in our example, postLoad() is called after the file I/O operation (open, import) is done, so a postLoad() implementation can itself issue file I/O operations with the knowledge that previous I/O operations have completed.

Note that if this assembly supports edit tracking, any changes made within postLoad() will be considered part of the setup process for the assembly and will not be recorded as edits.

MPxAssembly::postLoad() should never be called directly. Always use MFnAssembly::postLoad(), to ensure that Maya's internal postLoad() initialization is invoked before MPxAssembly::postLoad() is called.

An implementation of postLoad() should check MFnAssembly::canActivate() to determine whether it can activate a representation. See MFnAssembly::activateNonRecursive() for more details.

Default implementation is to do nothing.

Examples:
sceneAssembly/assemblyDefinition.h.
void memberAdded ( MObject member)
virtual

Called immediately after the argument node has been added to this assembly.

Default implementation does nothing.

Parameters
[in]memberNewly-added member node.
void memberRemoved ( MObject member)
virtual

Called immediately after the argument node has been removed from this assembly.

Default implementation does nothing.

Parameters
[in]memberNewly-removed member node.
bool performActivate ( const MString representation)

Provide access to the Maya core representation activation functionality.

This is useful to plugins overriding the default activate() method; see the activate() documentation for more details. A plugin implementing its own activate() method should call performActivate() when activating the newly-active representation to ensure it obtains the Maya services it needs.

The core representation activation functionality will call activateRep(). It will then initialize any nested assembly created by the activation using postLoad(), and will finally apply edits to the activated representation. If the postLoad() implementation of the newly-created nested assemblies calls activate(), this will recurse into performActivate() for the nested assembly.

Any changes made during performActivate() will not be tracked as edits, so that activating a representation will not generate spurious edits. Furthermore, performActivate() is not constrained to only those operations supported by edit tracking, so that node adds, deletes and renames are allowed, as expected.

Parameters
[in]representationRepresentation to activate.
Returns
true for success, false for failure.
bool performInactivate ( )

Provide access to the Maya core representation inactivation functionality.

This is useful to plugins overriding the default activate() method; see the activate() documentation for more details. A plugin implementing its own activate() method should call performInactivate() when inactivating the currently-active representation to ensure it obtains the Maya services it needs.

The core representation inactivation functionality performs the exact reverse of performActivate(). It first unapplies edits to the currently-active representation. It then loops over all nested assemblies (if any) and recursively calls performInactivate() on each. Finally, it calls inactivateRep().

Any changes made during performInactivate() will not be tracked as edits, so that inactivating a representation will not generate spurious edits. Furthermore, performInactivate() is not constrained to only those operations supported by edit tracking, so that node adds, deletes and renames are allowed, as expected.

Returns
true for success, false for failure.
MStatus activateRep ( const MString representation)
pure virtual

Called during activation to activate the new active representation.

See activate() documentation for more details.

Parameters
[in]representationRepresentation name.
Returns
true for success, false for failure.
Examples:
sceneAssembly/assemblyDefinition.h.
bool inactivateRep ( )
virtual

Called during activation to inactivate the currently active representation.

See activate() documentation for more details.

The default implementation clears out all nodes in the assembly. Derived assembly node types that wish to change this behavior (e.g. hide nodes rather than removing them) should override this method.

Returns
true for success, false for failure.
Examples:
sceneAssembly/assemblyDefinition.h.
void postActivateRep ( const MString representation)
virtual

Called after activation of a representation including the load, activation and edits of any created sub-assemblies but prior to the application of edits.

Parameters
[in]representationName of representation that was activated.
void preApplyEdits ( )
virtual

Method called by performActivate() just before edits are applied.

This method is called by performActivate() after the new representation has been activated with activateRep(), after any newly-created nested assemblies have been initialized with postLoad(), but just before edits are applied to this assembly (and any nested assemblies).

A use of this method might be to manage the assembly's list of edits before they are applied, perhaps adding edits.

This is called regardless of whether the representation supports edits or not.

The default implementation does nothing.

void preUnapplyEdits ( )
virtual

Method called by performInactivate() just before edits are unapplied.

This method is called by performInactivate() before unapplying edits, before any nested assemblies are inactivated, and before the current representation is inactivated with inactivateRep(). Therefore, when this call is made, no change has been made to the currently-active representation.

A use of this method might be to manage the assembly's list of edits before they are unapplied, perhaps removing edits. Any removed edit will be unapplied first, which can be done safely because the current representation has not been inactivated yet.

This is called regardless of whether the representation supports edits or not.

The default implementation does nothing.

void postApplyEdits ( )
virtual

Method called by performActivate() just after edits are applied.

This method is called by performActivate() after edits are applied to this assembly (and all nested assemblies).

A use of this method might be to perform additional work after edit application.

This is called regardless of whether the representation supports edits or not.

The default implementation does nothing.

void postUnapplyEdits ( )
virtual

Method called by performInactivate() just after edits are unapplied.

This method is called by performInactivate() after unapplying edits, before any nested assemblies are inactivated, and before the current representation is inactivated with inactivateRep().

A use of this method might be to perform additional work after edit unapplication.

This is called regardless of whether the representation supports edits or not.

The default implementation does nothing.

MString getInitialRep ( const MObject assembly,
bool &  hasInitialRep,
MStatus ReturnStatus = NULL 
) const
virtual

Get the initial representation to use when the specified assembly is first loaded.

This method can be customized by the assembly implementation to determine which representation should be activated when an assembly is first initialized. The hasInitialRep return argument must be set to false if no initial representation has been determined. Returning an empty string with hasInitialRep true means the initial active representation for the assembly should be no representation.

This method should not be called directly - individual assemblies should always call MFnAssembly::getInitialRep(). When an assembly requests its initial representation, Maya will internally locate the associated top level assembly node and invoke this method on it to return the actual representation to use.

This base class defines no implementation, sets the hasInitialRep return argument to false, and returns an empty string. Derived implementations can override this method to customize this behaviour. Maya ensures that this method will only be called on top level assemblies.

Parameters
[in]assemblyThe assembly for which the initial representation is being requested
[out]hasInitialRepReturn whether or not we have an initial representation
[out]ReturnStatusReturn status
Returns
The initial representation to use, if any, else an empty string.
Status Codes:
  • MS::kSuccess The method successfully completed
  • MS::kFailure The method encountered a failure condition
const char * className ( )
static

Returns the name of this class.

Returns
The name of this class.
bool activating ( ) const

Return true when this assembly is activating a representation, within a call to activate() or activateNonRecursive().

Reset to false just before initializing nested assemblies (through postLoad()) and applying edits. This can be used to implement activation-specific behavior for the assembly.

Returns
true if the assembly is activating a representation, false otherwise.
MTypeId typeId ( ) const
overridevirtual

Returns the TYPEID of this node.

The TYPEID is a four byte identifier that uniquely identifies this type of node to the binary file format.

It is not necessary to override this method.

Returns
Type id of the node

Reimplemented from MPxNode.

MString typeName ( ) const
overridevirtual

Returns the type name of this node.

The type name identifies the node type to the ASCII file format. It may also be used with the MEL command "createNode" to create a new node of this type.

It is not necessary to override this method.

Returns
Type name of the node

Reimplemented from MPxNode.

Examples:
sceneAssembly/assemblyDefinition.h.
MString name ( ) const
overridevirtual

Returns the name of this particular instance of this class.

Each object in the dependency graph has a name. This name will be used by the UI and by MEL.

It is not necessary to override this method.

Returns
Name of the node

Reimplemented from MPxNode.

MObject thisMObject ( ) const
overridevirtual

Returns the MObject associated with this user defined node.

This makes it possible to use MFnDependencyNode or to construct plugs to this node's attributes.

It is not necessary to override this method.

Returns
MObject handle for this node

Reimplemented from MPxNode.

Examples:
sceneAssembly/adskRepresentations.cpp.
MStatus setExistWithoutInConnections ( bool  flag)
overridevirtual

This method specifies whether or not the node can exist without input connections.

If a node connected to this node is deleted resulting in no more input connections and if this flag is false, then this node will be deleted.

Parameters
[in]flagtrue if this node can exist without input connections, false otherwise
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this MPxNode has not been initialized properly. Make sure this method is not being called from the constructor.

Reimplemented from MPxNode.

bool existWithoutInConnections ( MStatus ReturnStatus = NULL) const
overridevirtual

Determines whether or not this node can exist without input connections.

If a node connected to this node is deleted resulting in no more input connections and if this flag is false, then this node will be deleted.

Parameters
[out]ReturnStatusStatus code.
Returns
true is this node can exist without input connections, false otherwise
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this MPxNode has not been initialized properly. Make sure this method is not being called from the constructor.

Reimplemented from MPxNode.

MStatus setExistWithoutOutConnections ( bool  flag)
overridevirtual

This method specifies whether or not the node can exist without output connections.

If a node connected to this node is deleted resulting in no more output connections and if this flag is false, then this node will be deleted.

Parameters
[in]flagtrue if this node can exist without output connections, false otherwise
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this MPxNode has not been initialized properly. Make sure this method is not being called from the constructor.

Reimplemented from MPxNode.

bool existWithoutOutConnections ( MStatus ReturnStatus = NULL) const
overridevirtual

Determines whether or not this node can exist without output connections.

If a node connected to this node is deleted resulting in no more output connections and if this flag is false, then this node will be deleted.

Parameters
[out]ReturnStatusStatus code.
Returns
true is this node can exist without output connections, false otherwise
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this MPxNode has not been initialized properly. Make sure this method is not being called from the constructor.

Reimplemented from MPxNode.

MStatus addSetAttrEdit ( const MString targetAssembly,
const MString plugName,
const MString parameters,
MPxEditData editData = NULL 
)

Add a set attribute edit to be applied by Maya when switching representations.

This method is intended to be called by the plugin's addEdits() method, to add a set attribute edit. The set attribute edit is implemented with the setAttr command, so the full generality of setAttr command options is possible.

The targetAssembly name is specified relative to this assembly. Refer to the addEdits() method documentation for more information about specifying the targetAssembly for edits.

The plugName is in "nodeName.attr" format, and is specified relative to this assembly. Refer to the addEdits() method documentation for more information about specifying relative node names for edits.

The editData is an optional user data element that can be associated with this edit. The object must be dynamically allocated. Ownership of the editData will be assumed by Maya and subsequent management of the data object, including its eventual deletion will be handled along with the edit it is associated with. For this reason, an editData object should only be associated with a single edit, the same object should not be shared or associated with other edits. If multiple edits have editData of the same value, each edit must have its own unique copy.

Parameters
[in]targetAssemblyThe most enclosing assembly holding the edited node.
[in]plugNameThe name of the node and attr, in "nodeName.attr" syntax.
[in]parametersParameters to be added to the setAttr command, in MEL syntax.
[in]editDataOptional user-defined data to be associated with the edit
Returns
Return status.
Status Codes:
  • MS::kSuccess The edit was successfully added
  • MS::kFailure The edit was not successfully added
MStatus addConnectAttrEdit ( const MString targetAssembly,
const MString srcPlugName,
const MString dstPlugName,
MPxEditData editData = NULL 
)

Add a connect attribute edit to be applied by Maya when switching representations.

This method is intended to be called by the plugin's addEdits() method, to add a connect attribute edit.

The targetAssembly name is specified relative to this assembly. Refer to the addEdits() method documentation for more information about specifying the targetAssembly for edits.

The srcPlugName and dstPlugName are in "nodeName.attr" format, and are specified relative to this assembly. Refer to the addEdits() method documentation for more information about specifying relative node names for edits.

Note that the targetAssembly for connections is determined by the destination plug of the connection.

The editData is an optional user data element that can be associated with this edit. The object must be dynamically allocated. Ownership of the editData will be assumed by Maya and subsequent management of the data object, including its eventual deletion will be handled along with the edit it is associated with. For this reason, an editData object should only be associated with a single edit, the same object should not be shared or associated with other edits. If multiple edits have editData of the same value, each edit must have its own unique copy.

Parameters
[in]targetAssemblyThe most enclosing assembly holding the destination plug node.
[in]srcPlugNameThe name of the node and attribute that are the source of the connection, in "nodeName.attr" syntax.
[in]dstPlugNameThe name of the node and attribute that are the destination of the connection, in "nodeName.attr" syntax.
[in]editDataOptional user-defined data to be associated with the edit
MStatus addDisconnectAttrEdit ( const MString targetAssembly,
const MString srcPlugName,
const MString dstPlugName,
MPxEditData editData = NULL 
)

Add a disconnect attribute edit to be applied by Maya when switching representations.

This method is intended to be called by the plugin's addEdits() method, to add a disconnect attribute edit.

The targetAssembly name is specified relative to this assembly. Refer to the addEdits() method documentation for more information about specifying the targetAssembly for edits.

The srcPlugName and dstPlugName are in "nodeName.attr" format, and are specified relative to this assembly. Refer to the addEdits() method documentation for more information about specifying relative node names for edits.

Note that the targetAssembly for disconnections is determined by the destination plug of the connection.

The editData is an optional user data element that can be associated with this edit. The object must be dynamically allocated. Ownership of the editData will be assumed by Maya and subsequent management of the data object, including its eventual deletion will be handled along with the edit it is associated with. For this reason, an editData object should only be associated with a single edit, the same object should not be shared or associated with other edits. If multiple edits have editData of the same value, each edit must have its own unique copy.

Note: it is recommended that a disconnectAttrEdit be followed by a setAttrEdit on the destination plug to ensure it is set to a predictable value after disconnection.

Parameters
[in]targetAssemblyThe most enclosing assembly holding the destination plug node.
[in]srcPlugNameThe name of the node and attribute that are the source of the connection, in "nodeName.attr" syntax.
[in]dstPlugNameThe name of the node and attribute that are the destination of the connection, in "nodeName.attr" syntax.
[in]editDataOptional user-defined data to be associated with the edit
MStatus addDeleteAttrEdit ( const MString targetAssembly,
const MString nodeName,
const MString attributeName,
MPxEditData editData = NULL 
)

Add a delete attribute edit to be applied by Maya when switching representations.

This method is intended to be called by the plugin's addEdits() method, to insert an edit that will remove a dynamic attribute from a node.

The targetAssembly name and nodeName are specified relative to this assembly. Refer to the addEdits() method documentation for more information about specifying the targetAssembly and relative node names for edits.

The editData is an optional user data element that can be associated with this edit. The object must be dynamically allocated. Ownership of the editData will be assumed by Maya and subsequent management of the data object, including its eventual deletion will be handled along with the edit it is associated with. For this reason, an editData object should only be associated with a single edit, the same object should not be shared or associated with other edits. If multiple edits have editData of the same value, each edit must have its own unique copy.

Parameters
[in]targetAssemblyThe most enclosing assembly holding the affected node.
[in]nodeNameThe name of the node that the attribute will be removed from.
[in]attributeNameThe long name or short name of the attribute to be removed.
[in]editDataOptional user-defined data to be associated with the edit
MStatus addAddAttrEdit ( const MString targetAssembly,
const MString nodeName,
const MString longAttributeName,
const MString shortAttributeName,
const MString parameters,
MPxEditData editData = NULL 
)

Add an add attribute edit to be applied by Maya when switching representations.

This method is intended to be called by the plugin's addEdits() method, to insert an edit that will add a dynamic attribute to a node.

The targetAssembly name and nodeName are specified relative to this assembly. Refer to the addEdits() method documentation for more information about specifying the targetAssembly and relative node names for edits.

The parameters value is used to specify additional arguments to the addAttr command, such as the attribute type or data type information. Refer to the addAttr command for additional information.

The editData is an optional user data element that can be associated with this edit. The object must be dynamically allocated. Ownership of the editData will be assumed by Maya and subsequent management of the data object, including its eventual deletion will be handled along with the edit it is associated with. For this reason, an editData object should only be associated with a single edit, the same object should not be shared or associated with other edits. If multiple edits have editData of the same value, each edit must have its own unique copy.

Note: it is recommended that an addAttrEdit be followed by a setAttrEdit on the new attribute to ensure it is initialized to a predictable and valid value.

Parameters
[in]targetAssemblyThe most enclosing assembly holding the affected node.
[in]nodeNameThe name of the node that the attribute will be added to.
[in]longAttributeNameThe long name of the attribute to be added.
[in]shortAttributeNameThe short name of the attribute to be added.
[in]parametersParameters to be added to the addAttr command, in MEL syntax.
[in]editDataOptional user-defined data to be associated with the edit
MStatus addParentEdit ( const MString targetAssembly,
const MString childNodeName,
const MString parentNodeName,
const MString parameters,
MPxEditData editData = NULL 
)

Add a parent edit to be applied by Maya when switching representations.

This method is intended to be called by the plugin's addEdits() method, to insert an edit that will create a parenting relationship between two nodes.

The targetAssembly name, parentNodeName and childNodeName are specified relative to this assembly. Refer to the addEdits() method documentation for more information about specifying the targetAssembly and relative node names for edits.

The parameters value is used to specify additional arguments to the parent command such as relative or shape. Refer to the parent command for additional information.

Parent edits are only allowed between main-scene nodes and nodes in an assembly. The targetAssembly for parenting is determined depending on which of the nodes (parent or child) is inside an assembly. There are two kinds of parent edits, parent-in and parent-out:

A parent-in is when we have:
A:nodeInAssembly
|_ nodeInMain
And the targetAssembly would be "A"
Parent-out is when we have:
nodeInMain
|_ A:nodeInAssembly
And the targetAssembly would be "A"
We could have also created a parent edit between a deeply-nested node
and a main-scene node. In this case, we have something like
A:B:nodeInAssembly
|_ mainSceneNode
And targetAssembly would be "B" in this case.

The editData is an optional user data element that can be associated with this edit. The object must be dynamically allocated. Ownership of the editData will be assumed by Maya and subsequent management of the data object, including its eventual deletion will be handled along with the edit it is associated with. For this reason, an editData object should only be associated with a single edit, the same object should not be shared or associated with other edits. If multiple edits have editData of the same value, each edit must have its own unique copy.

Parameters
[in]targetAssemblyThe most enclosing assembly holding the affected node.
[in]childNodeNameThe name of the child node being parented
[in]parentNodeNameThe name of the parent node
[in]parametersParameters to be added to the parent command, in MEL syntax.
[in]editDataOptional user-defined data to be associated with the edit
MDataBlock forceCache ( )
overrideprotectedvirtual

USE _forceCache() IN SCRIPT.

Get the datablock for this node at the current evaluation context.

If there is no datablock then one will be created.

Note
This should be used only in places where fast access to the datablock outside of a compute is critical such as the transformUsing method of MPxSurfaceShape.
Warning
Do not override this method.
Returns
The datablock

Reimplemented from MPxNode.

MStatus setDoNotWrite ( bool  flag)
overrideprotectedvirtual

USE _setDoNotWrite() IN SCRIPT.

Use this method to mark the "do not write" state of this proxy node.

If set, this node will not be saved when the Maya model is written out.

NOTES: 1. Plug-in "requires" information will be written out with the model when saved. But a subsequent reload and resave of the file will cause these to go away. 2. If this node is a DAG and has a parent or children, the "do not write" flag of the parent or children will not be set. It is the developerメs responsibility to ensure that the resulting scene file is capable of being read in without errors due to unwritten nodes.

Parameters
[in]flagTrue if the user node should not be saved.

Reimplemented from MPxNode.

bool doNotWrite ( MStatus ReturnStatus = nullptr) const
overrideprotectedvirtual

USE _doNotWrite() IN SCRIPT.

Use this method to query the "do not write" state of this proxy node.

True is returned if this node will not be saved when the Maya model is written out.

Parameters
[out]ReturnStatus

Reimplemented from MPxNode.

void setMPSafe ( bool  flag)
overrideprotectedvirtual

This method is obsolete.

[as of Maya 2019]

Deprecated:
Override schedulingType() to set thread safety instead.

Reimplemented from MPxNode.

MString getInitialRep ( const MObject assembly,
MStatus ReturnStatus = NULL 
) const
protectedvirtual

This method is obsolete.

Get the initial representation to use when the specified assembly is first loaded.

[as of Maya 2018]

Deprecated:
Use MPxAssembly::getInitialRep(const MObject&, bool& , MStatus* ) instead.

This method can be customized by the assembly implementation to determine which representation should be activated when an assembly is first initialized. An empty string should be returned if no initial representation has been determined.

This method should not be called directly - individual assemblies should always call MFnAssembly::getInitialRep(). When an assembly requests its initial representation, Maya will internally locate the associated top level assembly node and invoke this method on it to return the actual representation to use.

This base class defines no implementation and will unconditionally return an empty string. Derived implementations can override this method to customize this behaviour. Maya ensures that this method will only be called on top level assemblies.

Parameters
[in]assemblyThe assembly for which the initial representation is being requested
[out]ReturnStatusReturn status
Returns
The initial representation to use, if any, else an empty string.
Status Codes:
  • MS::kSuccess The method successfully completed
  • MS::kFailure The method encountered a failure condition

The documentation for this class was generated from the following files: