Working with Values

The print() and format() functions are straightforward.

The format function is used when any formatting of the output is desired, or if you want to print multiple values on a line.

When printing a value using either of these functions, a string representation of the value is printed. This is not the object name for those objects with names (for example a 3ds Max object or material).

In the following example, variable b contains a reference to a 3ds Max Box object that has a material applied:

FOR EXAMPLE

   print b
   print b.name
   print b.material
   print b.material.name

OUTPUT:

   $Box:Box01 @ [-74.353745,0.000001,-19.931978]
   "Box01"
   Material #1:Standard
   "Material #1"

The printed results above also reflect the result of a <value> as string operation, that is the result is a string representation of the object rather than the object name.

classOf, superClassOf, and isKindOf

The following table shows the hierarchy of classes and superclasses for a variable that contains a reference to a 3ds Max Box object (i.e., b=box() ).

ClassOf SuperClassOf
b Box GeometryClass
box GeometryClass Node
GeometryClass Node MAXWrapper
Node MAXWrapper Value
MAXWrapper Value Value
Value Value Value

The isKindOf() and classOf() functions are useful for filtering objects from a set.

FOR EXAMPLE

either of the following will collect all objects of class box into variable allBoxes :

   allBoxes=for obj in $* where (isKindOf obj box) collect obj
   allBoxes=#()
   for obj in $* do (if classOf obj == box then append allBoxes obj)

One of the named parameters to the interactive node selection functions is filter , which allows you to specify a function that returns a value of true if an object can be selected.

The classOf , superClassOf , and isKindOf functions are frequently used in these functions.

FOR EXAMPLE

the following function limits the choices to shape objects:

   fn shape_filt obj = isKindOf obj Shape

For an example of such a usage, see Pickbutton.