MAXScript provides a number of built-in functions that display information about the classes that are accessible in your particular 3ds Max installation. These functions are useful as an online reference for the core 3ds Max classes and provide the only way of determining what properties in third-party plug-in classes are accessible.
The apropos() function is used to search for and print out information about global variables by name pattern and class of contents.
The <pattern_string> argument is a string containing a wild-card pattern for matching against global variables.
that is, a global variable name pattern optionally followed by a ':' and a class name pattern.
If the optional class name pattern is given, it restricts the printout to globals containing values of the specified classes.
The apropos() function assumes a wild-card '*' at the start and end of each pattern, implying a 'contains' pattern match.The pattern strings can contain name characters and '*'s and '?'s.
The output consists of the global variable name, a tag in () indicating if the variable is a system or const (unchangeable) variable and the class of the value currently in it, followed by a printed representation of that value.
To make scripting easier to teach and use everyday, a ScriptTool function for Help has been added. It is an alias for apropos.
Typing Help "Box", will show all the commands using the name BOX.
The showClass() function prints information about a specified 3ds Max class or classes. It has the following form:
where <pattern_string> is a string containing a wild-card pattern to match against 3ds Max class names, superclass names and property names, and the optional to:<stream> keyword argument specifies a Stream Value to output the display to.
The pattern string has this form:
In the output from the last example, the controllers include 3ds Max's core controllers and any 3rd-party plug-in controllers. In some cases, embedded controllers for some complex plug-ins may be visible in the showClass() listing (such as for Character Studio Bipeds). You should not attempt to create and use these controllers individually, this may result in system exceptions.
If you leave out the superclass pattern (the ':' part), it matches all superclasses. If you leave out the property pattern (the '.' part), you only get class names printed.
The following shows examples of the output of showClass() :
The showProperties() function is used to display the properties for a specific object that is an instance of one of the MAXWrapper classes. It can be used in place of showClass() in situations where you have an actual object in hand. Unlike showClass() , it can display the dynamic properties that may appear in individual objects as you work on them in the scene, such as the sub-controllers in a list controller or the animated control points in an FFD modifier.
The showProperties() function has the form:
where <maxwrapper_object> is the 3ds Max entity to be inspected, the optional <property_pattern> is a wild-card pattern that names the properties to be inspected, and the optional to:<stream> keyword argument specifies a Stream Value to output the display to.
If the property name pattern is not supplied, all properties are listed.
When the 3ds Max entity specified is a node (for example $box01), this function only displays the properties of base object. It does not show the properties of the transform controllers, modifiers, or materials applied to the object. To display the properties for one of these objects, that object must be specified as the 3ds Max entity as shown in the above examples.
showProperties includes properties defined by FPS interfaces in 3ds Max 8 and higher. See Inspecting Interface Properties for an example.
The following shows examples of the output of showProperties :
To make scripting easier to teach and use everyday, a ScriptTool function for "Show" has been added.
Show is the short way of typing ShowProperties
The getPropNames() function is similar to showProperties() , except it returns the property names for a specific object as an array. Unlike showProperties() , you can specify whether to return only the names of dynamic properties of the object.
The getPropNames function has the form:
The getPropNames() function returns an array of the property names accessible on the object.
FOR EXAMPLE: |
if a FFD(Box) modifier with animated control points is applied to a sphere, |
could yield: |
When the 3ds Max entity specified is a node (for example $box01), this function only returns the properties of base object. It does not return the properties of the transform controllers, modifiers, or materials applied to the object. To return the properties for one of these objects, that object must be specified as the 3ds Max entity as shown in the above examples.
getPropNames includes properties defined by FPS interfaces in 3ds Max 8 and higher. See Inspecting Interface Properties for an example.
If you call getPropNames() on MAXWrapper classes such as Box, Line, or Bend, it will return the properties common to all instances of that class. If you call getPropNames() on a 3ds Max entity, it will return the properties currently defined for that entity. If you add the optional keyword #dynamicOnly to the getPropNames() call for an entity, it returns the dynamic properties unique to that instance.
FOR EXAMPLE: |
if a FFD(Box) modifier with animated control points is applied to a sphere, |
could yield: |
As a special case, you can also call getPropNames() on the superclass 'Node' to get the list of properties common to all scene nodes such as .position , .name , or .wireColor .
The getPropNames method has been extended to work with the various interface values. The method will return the names of properties exposed by the interface.
The getProperty() and setProperty() functions allow you to access and set properties using computed property names.
The forms for each of these functions are:
The property name can be either a name, for example #length , or a string, for example "length" , so you can construct property names with string operations.
The getPropNames() function can be used in conjunction with the getProperty() function to implement object 'dumping’ tools that can iterate over all the properties of an arbitrary object and output them as required.
Similar functions for accessing and setting the values of property-assigned controllers are:
getPropertyController <value> <string_or_name> setPropertyController <value> <string_or_name> <controller>
Get and set the controller assigned to the named property of the value. If no controller has been assigned to the property, a value of undefined is returned.
The hasProperty() function allows you to test whether an object has a specified property name. Unlike isProperty(), the property name string supports wildcard patterns.
Returns true if the object has the given property or has properties matching the string pattern.
The isProperty() function allows you to test whether an object has a specified property.
isProperty() returns true if the specified property is a property of the MAXWrapper object, false otherwise. The property name can be either a name, for example #length , or a string, for example "length" , so you can construct property names with string operations.
hasProperty and isProperty do entirely different things.
hasProperty uses the same code as showPropeties() , but instead of returning a list of the properties found, it returns true on the first property name that matches the specified pattern. showProperties is looking at just the box base object and its MAXClass definition. It does not look at any higher level properties (and in versions prior to 3ds Max 8 it does not look at any of the FPS interface exposed properties).
isProperty on the other hand actually tries to access the specified object with the specified name and to detect whether the access succeeded or failed.
Returns true if the property is found and is animatable. Returns false if the property is not found or is not animatable.
3ds Max stores all of properties for objects in structures called subAnims. In some cases, a subAnim will contain nested subAnims. An example of this can be seen with the Standard material. If you apply a Standard material to an 3ds Max object, and then expand the object's tracks in Track View to display the material, you will see three Track View nodes - Parameters, Maps, and Shader. Each of these nodes is a subAnim defined in the Standard material’s class. Expanding the tracks for these three nodes, you will see various properties listed. These properties are defined in each of the nested subAnims in a structure called a ParamBlock.
MAXScript automatically finds animatable properties in all ParamBlocks associated with an object. To access these properties, you use the same nesting as shown in Track View when referencing those properties in MAXScript.
For more information about accessing animatable properties in MAXScript, see also Indexed Access to Animatable Properties in 3ds Max Objects.
The properties accessible on the various kinds of values is documented for each class. Many of the foundation classes in MAXScript (such as point3, color, etc.) support a special kind of nested-property assignment which allows sub-properties on object properties, such as the .x , .y , and .z coordinates in a node's .position property, to be individually and directly set. See Nested Object Properties for details.