A newer version of Max is available. Click here to access the latest version of the documentation

autopattr Reference

Expose multiple objects to the pattr system

autopattr

Description

Causes multiple objects within a patcher to be automatically included in the pattr system.

Note: you should use only one instance of an autopattr object per level in a patch.

Examples

Arguments

name [symbol]

Optional

A symbol argument can be used to set the autopattr object's name. In the absence of an argument, the autopattr object is given an arbitrary, semi-random name, such as u197000004.

Attributes

autoname [int]

The word autoname, followed by a 1 or 0, enables or disables the autopattr object's autoname state. The default is 0 (off). When enabled, the autopattr object will automatically name any unnamed objects in the patcher supported by the pattr system and bind to them, if possible. Naming only occurs when the patcher loads, when the autopattr object is again instantiated, or when the autopattr object receives the message autoname 1. New objects placed in a patcher after the autopattr has been instantiated will not be autonamed until one of these conditions is met.

autorestore [int]

The word autorestore, followed by a 1 or 0, enables or disables the autopattr object's autorestore state. The default is 1 (on). When enabled, the autopattr object will automatically output its last-saved values when the patcher is loaded, and distribute them to bound objects. Values are saved whenever the patcher is saved.

dirty [int]

The word dirty, followed by a 1 or 0, enables or disables the patcher-dirty flag. The default is 0 (disabled). When enabled, the autopattr object will dirty the patch whenever its state changes.

greedy [int]

The word greedy, followed by a 1 or 0, enables or disables the attribute-gathering feature of the autopattr object. The default is 0 (disabled). When enabled, any internal attributes of objects attached to the left outlet of the autopattr object will be exposed to the pattr system (as well as the normal value, if present).

name [symbol]

The word name, followed by a symbol, sets the autopattr object's patcher name.

Common Box Attributes

annotation [symbol]

Sets the text that will be displayed in the Clue window when the user moves the mouse over the object.

background [int] (default: 0)

Adds or removes the object from the patcher's background layer. background 1 adds the object to the background layer, background 0 removes it. Objects in the background layer are shown behind all objects in the default foreground layer.

color [4 floats]

Sets the color for the object box outline.

fontface [int]

Sets the type style used by the object. The options are:

plain
bold
italic
bold italic Possible values:

0 = 'regular'
1 = 'bold'
2 = 'italic'
3 = 'bold italic'

fontname [symbol]

Sets the object's font.

fontsize [float]

Sets the object's font size (in points). Possible values:

'8'
'9'
'10'
'11'
'12'
'13'
'14'
'16'
'18'
'20'
'24'
'30'
'36'
'48'
'64'
'72'

hidden [int] (default: 0)

Toggles whether an object is hidden when the patcher is locked.

hint [symbol]

Sets the text that will be displayed in as a pop-up hint when the user moves the mouse over the object in a locked patcher.

ignoreclick [int] (default: 0)

Toggles whether an object ignores mouse clicks in a locked patcher.

jspainterfile [symbol]

JS Painter File

patching_rect [4 floats] (default: 0. 0. 100. 0.)

Sets the position and size of the object in the patcher window.

position [2 floats]

g/s(set)

Sets the object's x and y position in both patching and presentation modes (if the object belongs to its patcher's presentation), leaving its size unchanged.

presentation [int] (default: 0)

Sets whether an object belongs to the patcher's presentation.

presentation_rect [4 floats] (default: 0. 0. 0. 0.)

Sets the x and y position and width and height of the object in the patcher's presentation, leaving its patching position unchanged.

rect [4 floats]

g/s(set)

Sets the x and y position and width and height of the object in both patching and presentation modes (if the object belongs to its patcher's presentation).

size [2 floats]

g/s(set)

Sets the object's width and height in both patching and presentation modes (if the object belongs to its patcher's presentation), leaving its position unchanged.

textcolor [4 floats]

Sets the color for the object's text in RGBA format.

textjustification [int]

Sets the justification for the object's text. Possible values:

0 = 'left'
1 = 'center'
2 = 'right'

varname [symbol]

Sets the patcher's scripting name, which can be used to address the object by name in pattr, scripting messages to thispatcher, and the js object.

Messages

bang

bang is passed through the autopattr object and output from its center right outlet.

int

Arguments

input [int]
An int is passed through the autopattr object and output from its center right outlet.

float

Arguments

input [float]
float is passed through the autopattr object and output from its center right outlet.

list

Arguments

input [list]
list is passed through the autopattr object and output from its center right outlet.

anything

Arguments

input/arguments [list]
Any message is analyzed. If the first element of the message matches the name of an object maintained by the autopattr, the subsequent arguments in the message set that object's value. If the first element of the message matches get (name), where (name) matches the name of an object maintained by the autopattr, the value of that object is sent from the autopattr object's right outlet, prepended by the object's name. Otherwise, the message is passed through the autopattr object and output from its center right outlet.

getattributes

Causes a list of all objects names maintained by the autopattr object to be output from the right outlet, prepended by the symbol attributes.

getstate

Causes a series of lists to be output from the autopattr object's right outlet, one for every object maintained by the autopattr. Each list begins with the name of the object, and is followed by the object's current value.

Output

(internal)

Out left outlet: Any user interface object (or other object that responds to the internal messaging system utilized by autopattr) connected to the left outlet of the autopattr object will be automatically named (if necessary) and bound to. If the autopattr object's greedy attribute has been enabled, any attributes associated with the bound object will also be exposed to the pattr system. The name is automatically generated from the object's class name (e.g. a connected number box might be named number[1].) At the time of this writing, the following Max user interface objects can be bound in this fashion: dial, function, gain~, ggate, gswitch, js, jsui (see the JavaScript in Max manual for more information on using the pattr system with JavaScript), led, matrixctrl, multislider, number box (int and float), pictctrl, pictslider, radiogroup, rslider, slider, table, textedit, toggle and umenu.

Out center-left outlet: Any user interface object (or other object that responds to the internal messaging system utilized by autopattr) connected to the center left outlet of the autopattr object will be automatically named (if necessary) and excluded from the autopattr object's bound-object list.

anything

Out center-right outlet: Any message not matching a get or set request to an object maintained by the autopattr is passed, unchanged, through the center right outlet.

Out right outlet: get queries to an object maintained by the autopattr are output from the right outlet, also known as the dumpout outlet.

See Also

Name Description
pattr Provide an alias with a named data wrapper
pattrforward Send any message to a named object
pattrhub Access all pattr objects in a patcher
pattrmarker Provide pattr communication between patchers
pattrstorage Save and recall pattr presets
Max pattr Tutorial 2: Automatic Bindings and Storage Max pattr Tutorial 2: Automatic Bindings and Storage