C++ API Reference
|
Parent class of all user defined assembly nodes. More...
#include <MPxAssembly.h>
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 ¶meters, 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 ¶meters, 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 ¶meters, 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... | |
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.
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.
The fundamental properties of a representation are the following:
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.
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.
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.
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.
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().
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.
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.
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:
OPENMAYA_MAJOR_NAMESPACE_OPEN MPxAssembly | ( | ) |
Class constructor.
Any calls to the MPxAssembly methods must be done in the postConstructor method and not here.
|
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.
Reimplemented from MPxNode.
|
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().
[in] | input | Input data for representation creation. |
[in] | type | Type of representation to create. |
[in] | representation | Representation name starting point. |
[out] | undoRedo | Pointer to MDagModifier object, for undo / redo purposes. |
[out] | ReturnStatus | Return status. |
|
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:
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.
[in] | representation | Representation to activate. |
|
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.
|
virtual |
Determines whether the argument representation is the active representation.
The default implementation compares the argument representation to the result of getActive().
[in] | representation | Representation to query. |
|
pure virtual |
Returns an array of the representations managed by the node attached to this function set.
[out] | ReturnStatus | Return status |
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.
[in] | representation | Representation whose type must be returned. |
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.
[in] | representation | Representation whose label must be returned. |
|
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.
Delete a representation managed by the node.
[in] | rep | Representation to delete. |
|
pure virtual |
Delete all representations managed by this node.
|
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.
|
virtual |
This method is called by Maya to tell the assembly that the base representation namespace specified by getRepNamespace() has been changed.
[in] | repNamespace | New namespace for representations. |
|
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.
[in] | representation | Current representation name. |
[in] | newName | New representation name starting point. |
[out] | ReturnStatus | Return status. |
Change the representation label.
[in] | representation | Representation name. |
[in] | label | New representation label. |
|
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.
|
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.
|
virtual |
Determines whether the given representation can apply edits to its data.
The default implementation returns false.
[in] | representation | Representation to query. |
|
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.
|
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.
|
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.
|
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.
|
virtual |
Called immediately after the argument node has been added to this assembly.
Default implementation does nothing.
[in] | member | Newly-added member node. |
|
virtual |
Called immediately after the argument node has been removed from this assembly.
Default implementation does nothing.
[in] | member | Newly-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.
[in] | representation | Representation to activate. |
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.
Called during activation to activate the new active representation.
See activate() documentation for more details.
[in] | representation | Representation name. |
|
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.
|
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.
[in] | representation | Name of representation that was activated. |
|
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.
|
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.
|
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.
|
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.
|
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.
[in] | assembly | The assembly for which the initial representation is being requested |
[out] | hasInitialRep | Return whether or not we have an initial representation |
[out] | ReturnStatus | Return status |
|
static |
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.
|
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.
Reimplemented from MPxNode.
|
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.
Reimplemented from MPxNode.
|
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.
Reimplemented from MPxNode.
|
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.
Reimplemented from MPxNode.
|
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.
[in] | flag | true if this node can exist without input connections, false otherwise |
Reimplemented from MPxNode.
|
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.
[out] | ReturnStatus | Status code. |
Reimplemented from MPxNode.
|
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.
[in] | flag | true if this node can exist without output connections, false otherwise |
Reimplemented from MPxNode.
|
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.
[out] | ReturnStatus | Status code. |
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.
[in] | targetAssembly | The most enclosing assembly holding the edited node. |
[in] | plugName | The name of the node and attr, in "nodeName.attr" syntax. |
[in] | parameters | Parameters to be added to the setAttr command, in MEL syntax. |
[in] | editData | Optional user-defined data to be associated with the edit |
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.
[in] | targetAssembly | The most enclosing assembly holding the destination plug node. |
[in] | srcPlugName | The name of the node and attribute that are the source of the connection, in "nodeName.attr" syntax. |
[in] | dstPlugName | The name of the node and attribute that are the destination of the connection, in "nodeName.attr" syntax. |
[in] | editData | Optional 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.
[in] | targetAssembly | The most enclosing assembly holding the destination plug node. |
[in] | srcPlugName | The name of the node and attribute that are the source of the connection, in "nodeName.attr" syntax. |
[in] | dstPlugName | The name of the node and attribute that are the destination of the connection, in "nodeName.attr" syntax. |
[in] | editData | Optional 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.
[in] | targetAssembly | The most enclosing assembly holding the affected node. |
[in] | nodeName | The name of the node that the attribute will be removed from. |
[in] | attributeName | The long name or short name of the attribute to be removed. |
[in] | editData | Optional 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.
[in] | targetAssembly | The most enclosing assembly holding the affected node. |
[in] | nodeName | The name of the node that the attribute will be added to. |
[in] | longAttributeName | The long name of the attribute to be added. |
[in] | shortAttributeName | The short name of the attribute to be added. |
[in] | parameters | Parameters to be added to the addAttr command, in MEL syntax. |
[in] | editData | Optional 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:
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.
[in] | targetAssembly | The most enclosing assembly holding the affected node. |
[in] | childNodeName | The name of the child node being parented |
[in] | parentNodeName | The name of the parent node |
[in] | parameters | Parameters to be added to the parent command, in MEL syntax. |
[in] | editData | Optional user-defined data to be associated with the edit |
|
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.
Reimplemented from MPxNode.
|
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.
[in] | flag | True if the user node should not be saved. |
Reimplemented from MPxNode.
|
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.
[out] | ReturnStatus |
Reimplemented from MPxNode.
|
overrideprotectedvirtual |
This method is obsolete.
[as of Maya 2019]
Reimplemented from MPxNode.
|
protectedvirtual |
This method is obsolete.
Get the initial representation to use when the specified assembly is first loaded.
[as of Maya 2018]
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.
[in] | assembly | The assembly for which the initial representation is being requested |
[out] | ReturnStatus | Return status |