Materialbutton

A materialbutton item is used to place a button in the rollout that will display the 3ds Max Material/Map Browser dialog when clicked. Only materials will be displayed in the Material/Map Browser dialog.

The syntax is:

materialbutton <name> [ <caption> ] [material:<material>] [images:<image_spec_array>] [toolTip:<string>]

The default alignment of materialbutton items is #center.

Example:

Rollout assign_material "Assign Material"

(

label smtl_lbl "Set selected object's material to:"

materialbutton choosemtl "Pick Material"

on choosemtl picked mtl do

(

print mtl

if $ != undefined do $.material=mtl

)

)

createDialog assign_material

 

Testing_materialButton_UI_01.gif

Parameters

material:

The initial material value returned by the material property before the user has selected a material using the materialbutton. Defaults to undefined.

images:

An image-specification array for providing bitmap images for the materialbutton. If this is specified, the <label> is ignored and the contents of the materialbutton are replaced with the bitmaps. The form is:

images:#(<image>, <maskImage>, <count_integer>, \
<enabled_out_image_index>, <enabled_in_image_index>, \
<disabled_out_image_index>, <disabled_in_image_index>)

where <image> and <maskImage> can be either a bitmap file name string or a MAXScript bitmap value. <count_integer> specifies the number of sub-images in the bitmaps, and the image_index values specify which sub-image in the bitmaps is to be used for each of the four materialbutton states.

For example:

bm1 = render camera:$cam01 outputSize:[80,60]

...

materialbutton foo images:#(bm1, undefined, 1, 1, 1, 1, 1)

would use a rendering as the materialbutton image, and

materialbutton decay images:#("dcybtns.bmp", "dcymask.bmp", 6, 1, 4, 1, 4)

would use sub-images 1 and 4 of bitmaps dcybtns.bmp and dcymask.bmp for the out and in states of the materialbutton, respectively.

See also Image Buttons.

toolTip:

Provides text for a tooltip for the materialbutton. No tooltip if unsupplied.

Properties

<materialbutton>.material Material

The current material value for the materialbutton, or the material value specified by the material parameter if the user has not yet selected a material.

<materialbutton>.images Array

Sets the image-specification array for the materialbutton.

For example:

-- re-render, update button

bm1 = render()

foo.images = #(bm1, undefined, 1, 1, 1, 1, 1)

This property is write-only.

<materialbutton>.tooltip String

new.gif NEW in 3ds Max 9: Get/set the tooltip string of the checkbutton.

For example:

rollout test "Test"

(

mapbutton mat_test "Material Button" tooltip:"This is a material button"

)

createDialog test

test.mat_test.tooltip = "The tooltip has changed!"

Events

on <materialbutton> picked <arg> do <expr>

Called when the user selects a material from the Material/Map Browser dialog while in the materialbutton pick command mode. The <arg> argument will contain the selected material value. The handler is not called if the user cancels out of the Material/Map Browser dialog.

on <materialbutton> rightclick do <expr>

Called when the right mouse button is released over the button. Available in 3ds Max 8 and higher.

 

Notes:

When a materialButton is used in a rollout in a scripted material plug-in, and so turn up the Material Editor, it behaves with the same functionality as sub-material buttons do in regular materials. This includes supporting drag-and-drop with instance/copy, and opening materials if they have been assigned.

Warning:

A materialButton cannot be used in a rollout of a scripted map plug-in. The 3ds Max Material Editor architecture assumes that a Sub-Material can only be a child of another material and will be confused when trying to assign a sub-material to a map.

See also

Rollout User-Interface Items Common Properties

Rollout User-Interface Items Common Layout Parameters

Rollout User-Interface Control Types