Custom Attributes Definition Values

Attribute definition values have several directly accessible properties:

<def>.name

Get and set descriptive name

<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.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.

Example:

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

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 definiton from the current scene and the current running 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

See also

Scripted Custom Attributes

Adding Custom Attributes

Global and Private Custom Attributes Definitions

Custom Attribute Management Functions

Custom Attributes in Materials and Texture Maps