pymel.core.general.addAttr

addAttr(*args, **kwargs)

This command is used to add a dynamic attribute to a node or nodes. Either the longName or the shortName or both must be specified. If neither a dataType nor an attributeType is specified, a double attribute will be added. The dataType flag can be specified more than once indicating that any of the supplied types will be accepted (logical-or). To add a non- double attribute the following criteria can be used to determine whether the dataType or the attributeType flag is appropriate. Some types, such as double3can use either. In these cases the -dtflag should be used when you only wish to access the data as an atomic entity (eg. you never want to access the three individual values that make up a double3). In general it is best to use the -atin these cases for maximum flexibility. In most cases the -dtversion will not display in the attribute editor as it is an atomic type and you are not allowed to change individual parts of it. All attributes flagged as (compound)below or the compound attribute itself are not actually added to the node until all of the children are defined (using the -pflag to set their parent to the compound being created). See the EXAMPLES section for more details. Type of attribute Flag and argument to use boolean -at bool 32 bit integer -at long 16 bit integer -at short 8 bit integer -at byte char -at char enum -at enum (specify the enum names using the enumName flag) float -at float(use quotes since float is a mel keyword) double -at double angle value -at doubleAngle linear value -at doubleLinear string -dt string(use quotes since string is a mel keyword) array of strings -dt stringArray compound -at compound message (no data) -at message time -at time 4x4 double matrix -dt matrix(use quotes since matrix is a mel keyword) 4x4 float matrix -at fltMatrix reflectance -dt reflectanceRGBreflectance (compound) -at reflectance spectrum -dt spectrumRGB spectrum (compound) -at spectrum 2 floats -dt float2 2 floats (compound) -at float2 3 floats -dt float3 3 floats (compound) -at float3 2 doubles -dt double2 2 doubles (compound) -at double2 3 doubles -dt double3 3 doubles (compound) -at double3 2 32-bit integers -dt long2 2 32-bit integers (compound) -at long2 3 32-bit integers -dt long3 3 32-bit integers (compound) -at long3 2 16-bit integers -dt short2 2 16-bit integers (compound) -at short2 3 16-bit integers -dt short3 3 16-bit integers (compound) -at short3 array of doubles -dt doubleArray array of 32-bit ints -dt Int32Array array of vectors -dt vectorArray nurbs curve -dt nurbsCurve nurbs surface -dt nurbsSurface polygonal mesh -dt mesh lattice -dt lattice array of double 4D points -dt pointArray In query mode, return type is based on queried flag.

Modifications:
  • allow python types to be passed to set -at type

    str string float double int long bool bool Vector double3

  • when querying dataType, the dataType is no longer returned as a list

Flags:
  • attributeType : at (unicode) [create,query]

    Specifies the attribute type, see above table for more details. Note that the attribute types float, matrixand stringare also MEL keywords and must be enclosed in quotes.

  • binaryTag : bt (unicode) [create,query]

    This flag is obsolete and does not do anything any more

  • cachedInternally : ci (bool) [create,query]

    Whether or not attribute data is cached internally in the node. This flag is currently not supported (it will always be set to a default value of true).

  • dataType : dt (unicode) [create,query]

    Specifies the data type. See setAttrfor more information on data type names.

  • defaultValue : dv (float) [create,query,edit]

    Specifies the default value for the attribute (can only be used for numeric attributes).

  • enumName : en (unicode) [create,query,edit]

    Flag used to specify the ui names corresponding to the enum values. The specified string should contain a colon- separated list of the names, with optional values. If values are not specified, they will treated as sequential integers starting with 0. For example: -enumName A:B:Cwould produce options: A,B,C with values of 0,1,2; -enumName zero:one:two:thousand=1000would produce four options with values 0,1,2,1000; and -enumName solo=1:triplet=3:quintet=5would produce three options with values 1,3,5. (Note that there is a current limitation of the Channel Box that will sometimes incorrectly display an enumerated attribute’s pull-down menu. Extra menu items can appear that represent the numbers inbetween non-sequential option values. To avoid this limitation, specify sequential values for the options of any enumerated attributes that will appear in the Channel Box. For example: solo=1:triplet=2:quintet=3.)

  • exists : ex (bool) [create,query]

    Returns true if the attribute queried is a user-added, dynamic attribute; false if not. Flag can have multiple arguments, passed either as a tuple or a list.

  • hasMaxValue : hxv (bool) [create,query,edit]

    Flag indicating whether an attribute has a maximum value. (can only be used for numeric attributes).

  • hasMinValue : hnv (bool) [create,query,edit]

    Flag indicating whether an attribute has a minimum value. (can only be used for numeric attributes).

  • hasSoftMaxValue : hsx (bool) [create,query]

    Flag indicating whether a numeric attribute has a soft maximum.

  • hasSoftMinValue : hsn (bool) [create,query]

    Flag indicating whether a numeric attribute has a soft minimum.

  • hidden : h (bool) [create,query]

    Will this attribute be hidden from the UI?

  • indexMatters : im (bool) [create,query]

    Sets whether an index must be used when connecting to this multi-attribute. Setting indexMatters to false forces the attribute to non-readable.

  • internalSet : internalSet (bool) [create,query]

    Whether or not the internal cached value is set when this attribute value is changed. This is an internal flag used for updating UI elements.

  • keyable : k (bool) [create,query]

    Is the attribute keyable by default?

  • longName : ln (unicode) [create,query]

    Sets the long name of the attribute.

  • maxValue : max (float) [create,query,edit]

    Specifies the maximum value for the attribute (can only be used for numeric attributes).

  • minValue : min (float) [create,query,edit]

    Specifies the minimum value for the attribute (can only be used for numeric attributes).

  • multi : m (bool) [create,query]

    Makes the new attribute a multi-attribute.

  • niceName : nn (unicode) [create,query,edit]

    Sets the nice name of the attribute for display in the UI. Setting the attribute’s nice name to a non-empty string overrides the default behaviour of looking up the nice name from Maya’s string catalog. (Use the MEL commands attributeNiceNameand attributeQuery -niceNameto lookup an attribute’s nice name in the catalog.)

  • numberOfChildren : nc (int) [create,query]

    How many children will the new attribute have?

  • parent : p (unicode) [create,query]

    Attribute that is to be the new attribute’s parent.

  • readable : r (bool) [create,query]

    Can outgoing connections be made from this attribute?

  • shortName : sn (unicode) [create,query]

    Sets the short name of the attribute.

  • softMaxValue : smx (float) [create,query,edit]

    Soft maximum, valid for numeric attributes only. Specifies the upper default limit used in sliders for this attribute.

  • softMinValue : smn (float) [create,query,edit]

    Soft minimum, valid for numeric attributes only. Specifies the upper default limit used in sliders for this attribute.

  • storable : s (bool) [create,query]

    Can the attribute be stored out to a file?

  • usedAsColor : uac (bool) [create,query]

    Is the attribute to be used as a color definition? Must have 3 DOUBLE or 3 FLOAT children to use this flag. The attribute type -atshould be double3or float3as appropriate. It can also be used to less effect with data types -dtas double3or float3as well but some parts of the code do not support this alternative. The special attribute types/data spectrumand reflectancealso support the color flag and on them it is set by default.

  • writable : w (bool) [create,query]

    Can incoming connections be made to this attribute?

Derived from mel command maya.cmds.addAttr

Previous topic

pymel.core.general.about

Next topic

pymel.core.general.affectedNet

Core

Core Modules

Other Modules

This Page