Custom Attributes Definition Values

Attribute definition values have several directly accessible properties:

<def>.name 

Get and set a descriptive name.

<def>.version 

Read-only, the version of the definition.

Available in 3ds Max 2015 and higher.

<def>.source 

Read-only, the source code for the definition.

<def>.defData 

Get and set the user-supplied def data value

<def>.attribID 

Read-only, a two-element array containing the attribID for the def

custAttributes.getDefSource <attrib_def> 

Returns the source code for the attributes definition as a string.

custAttributes.getOwner <attrib_def> 

Returns the object the custom attribute is applied to.

custAttributes.getDefClass <attrib_def> 

Returns the MAXClass associated with an attrib_def.

Available in 3ds Max 2008 and higher.

Previously available in the Avguard Extensions.

custAttributes.getDefInstances <attrib_def> 

Returns an array of the MSCustAttrib instances of the attrib_def.

Available in 3ds Max 2008 and higher.

Previously available in the Avguard Extensions.

custAttributes.setDefData <def> <data> 

Adds user-supplied data to an attributes definition.

The < data > value supplied here will be stored persistently with the definition and loaded on scene loads containing attribute sets of this definition.

custAttributes.getDefData <attrib_def> 

Returns the saved user-supplied data.

custAttributes.getPBlockDefs <attrib_def> 

These methods return an array containing a runtime readable encoding of all of the parameter block definitions in the custAttributes definition.

The array is presented in the following form:

#(<paramblock>, <paramblock2>, ...) 
<paramblock> 

An array of details for one parameter block in this form:

#(<name>, <id>, <refno>, <keyword_params>, <parameter1>, <parameter2>, <parameter3>, ....)   <id> 

The parameter block’s internal ID number

<refno> 

The reference number of the parameter block in the owning plug-in instance

<keyword_params> 

An array of the keyword parameters given on the parameter block definition in the form:

#(<keyword>, <value>, <keyword2_name>, <value2>, ...) <Parameter1 to ParameterN 

Definition details for each parameter in the block in the following form:

#(<param_name> <keyword_params>) 
<keyword_params> 

An array containing all of the keyword parameters specified on that parameter's definition in the cust attrib definition, in the same form as the <keyword_params> above.

Here is a function that will extract ParameterBlock data from a custom attribute.

EXAMPLE

   mapped fn custAttribute_showPBlockDefs obj = 
   ( 
     format "%\n" obj.name 
     for objDef in (custAttributes.getDefs obj) do 
     ( 
       format "\t%\n" objDef 
       format "\tname: %\n" objDef.name 
       format "\tattribute id: %\n" objDef.attribID   
       format "\tParameter Blocks:" 
       pbArray = custAttributes.getPBlockDefs objdef 
       for a = 1 to pbArray.count do 
       ( 
         itms = pbArray [a]   
         format "\n\t\tname = %\n" itms[1] 
         format "\t\tid = %\n" itms[2] 
         format "\t\towners reference number = %\n" itms[3] 
         keywordParams = itms[4] 
         format "\t\tparameter block keywords:\n" 
         for x = 1 to keywordParams.Count/2 do 
         ( 
           format "\t\t\t% = %\n" keywordParams[x] keywordParams[x+1] 
           x = x+1 
         ) 
         format "\t\tparameters:" 
         for y = 5 to itms.Count do 
         ( 
           format "\n\t\t\t#name = %\n" itms[y][1] 
           for z = 1 to itms[y][2].Count by 2 do 
           ( 
             format "\t\t\t% = %\n" itms[y][2][z] itms[y][2][z+1] 
           ) 
         ) 
       ) 
     ) 
   ) 
custAttributes.getSceneDefs () 

Returns an array of all the attribute definitions in the current scene.

custAttributes.deleteDef <attrib_def> 

Deletes the given attribute definition from the current scene and the current running 3ds Max session. There must be no objects in the scene containing custom attributes added using this definition.

Note: The name can be obtained via the .name property.

Next Topic:

Access to Custom Attributes Virtual Array