MAXWrapper Common Properties, Operators, and Methods

The following properties and methods are applicable to any value that is derived from MAXWrapper.

Properties

The following MAXWrapper value and class properties give you access to the plug-in category, such as Standard Primitives, Extended Primitives, or Particle Systems:

<MAXWrapperobject>.category      Name, read-only

<maxclass>.category              Name, read-only

<maxsuperclass>.categories       Array, read-only

The category property returns a Name value containing the category. You can use it on either a 3ds max object class, such as Line, Box, or Fog, or on an instance of any 3ds max object class. For scene nodes, the category usually corresponds to one of the names in the drop down list in the Create panel. These are the categories such as #Standard_Primitives, #Compound_Objects, and #Particles_Only.

For modifiers, the category determines which group the modifier appears in the Configure Button Sets / Modifiers list. These are the categories such as #MAX_STANDARD, #MAX_EDIT, and #MAX_SURFACE.

For textures, the category determines which group the texture appears in the Material/Map Browser. These are the categories such as #2D (2D maps), #3D (3D maps), and #COMP (Compositors).

The categories property can be used on any of the 3ds max object superclasses, such as Shape, GeometryClass, Helper, SpacewarpObject, TextureMap, or Modifier, to get a list of the available categories for that superclass, returned as an array of Names. For example:

$line01.category -- returns #Splines

Gengon.category -- returns #Extended_Primitives

Shape.categories -- returns #(#Shape, #Splines, #NURBS_Curves)

<MAXWrapperobject>.classID

<maxclass>.classID

The classID property retrieves the internal 3ds max Class ID of the MAXWrapper classes and objects. The value returned is an array containing two numbers, PartA and PartB of the 3ds max internal class ID. For a MAXWrapper object, the value returned is the Class ID of the class the object is an instance of. For example,

Box.classID -- returns #(16, 0)

b=box()

b.classID -- returns #(16, 0)

The combination of the PartA and PartB numbers is guaranteed to be unique for each class.

<MAXWrapperObject>.superClassID

<maxclass>.superClassID

Retrieves the 3ds max superclass ID of the MAXWrapper classes and objects.

Methods

copy <MAXWrapper_object>

The copy() function is implemented by all the 3ds max objects available in MAXScript, such as scene objects, controllers, modifiers, materials, etc. You can use this function to make a clone of the source object, for example in situations where you want individual copies or you want to make a shared object unique. For example:

addModifier $foo $baz.bend

will cause foo to share the bend modifier on baz, whereas:

addModifier $foo (copy $baz.bend)

will give foo a separate clone of the bend modifier on baz. Any changes to the bend modifier on foo will not affect baz and vice versa.

In the next example, we set up several objects all sharing a single rotation controller:

c = bezier_rotation()

$foo.rotation.controller = c

$baz.rotation.controller = c

$bar.rotation.controller = c

To later make one of the controllers unique, you could do this:

$baz.rotation.controller =

copy $baz.rotation.controller

When the MAXWrapper object is not a scene node, the copy is only created in MAXScript memory. When the MAXWrapper object is a scene node, a new scene node is created which is visible and accessible by the user in the 3ds max viewports.

exprForMAXObject <MAXWrapper_object>

Returns a string containing a MAXScript expression that will 'name' the specified MAXWrapper object using property access and indexes as needed. For example, if you have in variable m a bend modifier on a scene object named "foo", then:

exprForMAXObject m

would yield the string:

"$foo.bend"

This method is an exposure of an internal method that macro recorder uses, and its output will vary depending on the macro recorder options.

b=box()
--> $Box:Box02 @ [0.000000,0.000000,0.000000]
c=b.pos.controller
--> Controller:Bezier_Position
exprformaxobject c
--> "$Box02.pos.controller"
bm=bend()
--> Bend:Bend
addmodifier b bm
--> OK
exprformaxobject bm
--> "$Box02.modifiers[#Bend]"

Here, changing the macro recorder options from "Explicit scene object names" to "Selection-relative scene object names", yeilds:

exprformaxobject bm
--> "$.modifiers[#Bend]"

createInstance <maxclass> [keyarg1:v] [keyarg2:v] ...

This method is used to directly create the 'base objects' that you see in a Node (or any other object). The main use for this is to create temporary geometry base objects from which meshes will be extracted to help create the meshes for scripted geometry primitive plug-ins. The optional <keyargs> are the same base-object keyword arguments as can be supplied for the class constructor. These are typically the parameters of the base object. For example:

b = createInstance Box length:10 height:40 width:20

creates an instance of a Box. This box will not appear in the 3ds max viewports, as it is not a node. It only contains the geometry associated with the Box object. You can get at the mesh representation of these instanced objects with the mesh property, which yields a TriMesh value.

replaceInstances <old_MAXWrapper> <new_MAXWrapper>

Replaces all instances of the old MAXWrapper with the new MAXWrapper. Old and new MAXWrapper must have the same superclass.

Minimal error checking, use with extreme caution.

Dependencies

An important internal mechanism in 3ds max defines the dependency relationship between 3ds max objects. For example, a material depends on its various maps, a path controller depends on its percent controller, a scene node depends on its base object, etc. The following method returns the MAXWrapper objects that depend on a specified MAXWrapper object.

refs.dependents <MAXWrapper_object>

Returns an array of the other 3ds max MAXWrapper objects depend on the specified MAXWrapper object. The specified MAXWrapper object can be any MAXWrapper object, such as a scene node, controller, material, modifier, etc.

For example:

refs.dependents $foo.material.diffuseMap

could return:

#(Material_#3, Material_#2, Map_#2:Noise, Material_#1)

which shows that the diffuseMap in $foo is referenced in material #1, material #2, material #3, and noise TextureMap #2.

The following example shows several objects being created, and sets up controllers on the objects which depend on other objects.

Script

theSphere=sphere ()                        -- create a sphere

theCone=cone radius1:0 radius2:20          -- create a cone

theHelix=helix  height:100 pos:[100,100,0] -- create a helix

theCone.target=theSphere         -- assign theSphere as target of theCone

-- a lookat controller is automatically

-- assigned to theCone

-- assign path controller to theSphere, path to follow is the helix

theSphere.position.controller=path path:theHelix

refs.dependents theSphere        -- show dependents of the sphere

refs.dependents theCone          -- show dependents of the cone

refs.dependents theHelix         -- show dependents of the helix

Output

$Sphere:Sphere02 @ [0,0,0]                      -- result line 1

$Cone:Cone02 @ [0,0,0]                          -- result line 2

$Helix:Helix02 @ [100,100,0]                    -- result line 3

$Sphere:Sphere02 @ [0,0,0]                      -- result line 4

Controller:Path                                 -- result line 8

#(Controller:Look_At, $Cone:Cone02 @ [0,0,0])   -- result line 9

#()                                             -- result line 10

-- following is output of line 11

#(Controller:Path, Controller:Position_Rotation_Scale, $Sphere:Sphere02 @ [0,0,0], Controller:Look_At, $Cone:Cone02 @ [0,0,0])

See also