Share

Interface: InstanceMgr

The Instance Manager Core Interface provides access to properties and methods related to Instanced Nodes. It provides means for collecting instances, managing material propagation to instances, making instanced modifiers, controllers and nodes unique etc.

Properties:

InstanceMgr.autoMtlPropagation : boolean : Read|Write      

When set to True , Materials assigned to an object will propagate automatically to all its instances.

Methods:

<integer>InstanceMgr.GetInstances <node>source <&node array>instances   

instances is Out parameter 

Returns the number of instances of the specified source node and the list of all instances in the by-reference Out parameter.

FOR EXAMPLE:

tp = Teapot() --create a teapot
--> $Teapot:Teapot01 @ [0.000000,0.000000,0.000000]
tp1 = instance tp --instance the teapot
--> $Teapot:Teapot02 @ [0.000000,0.000000,0.000000]
tp2 = instance tp --instance it again
--> $Teapot:Teapot03 @ [0.000000,0.000000,0.000000]
tp3 = copy tp --copy the teapot
--> $Teapot:Teapot04 @ [0.000000,0.000000,0.000000]
InstanceMgr.GetInstances tp &instances -- get the instances of the original
--> 3
instances --show the returned array- all instances are there, the copy isn't
--> #($Teapot:Teapot03 @ [0.000000,0.000000,0.000000], $Teapot:Teapot02 @ [0.000000,0.000000,0.000000], $Teapot:Teapot01 @ [0.000000,0.000000,0.000000])
InstanceMgr.GetInstances tp3 &instances --get the instances of the copy
--> 1
instances -- show the returned array - the copy is the only object in it
--> #($Teapot:Teapot04 @ [0.000000,0.000000,0.000000])
Note: This function also considers objects to be instances when they share the same styles or categories as defined in AutoCAD Architecture, or the same families and types as defined in Autodesk Revit, when a scene is imported or linked from a DWG file. In this case, the function works like the Select Similar command. In this case, to select only 3ds Max instances, use:
-- Note that this code works only if the selection set ($) is not empty
InstanceMgr.GetInstances $ &rptInstances 
trueInstances = for n in rptInstances where (areNodesInstances $ n) collect n
<integer> InstanceMgr.SetMtlOnInstances <node>source <material>newMtl 

Propagates the supplied new material to all instances of the specified source node. Normally, instances can have independent materials. Using this method, all instances can be updated to use the same material. Returns the number of instances.

FOR EXAMPLE:

tp = Teapot() --create a teapot
--> $Teapot:Teapot01 @ [0.000000,0.000000,0.000000]
tp.material = standard diffuse:(color 255 0 0) --assign a red material
--> Standardmaterial:Standard
tp1 = instance tp --create an instance
--> $Teapot:Teapot02 @ [0.000000,0.000000,0.000000]
tp1.pos = [100,0,0] --move the instance
--> [100,0,0]
tp1.material = standard diffuse:(color 0 255 0) --assign a green material
--> Standardmaterial:Standard
tp2 = instance tp --create another instance
--> $Teapot:Teapot03 @ [0.000000,0.000000,0.000000]
tp2.pos = [200,0,0] --move the instance
--> [200,0,0]
tp2.material = standard diffuse:(color 0 0 255) --assign a blue material
--> Standardmaterial:Standard
newMaterial = standard diffuse:(color 250 255 255) --create a white material
--> Standardmaterial:Standard

InstanceMgr.SetMtlOnInstances tp newMaterial --assign to all instances 3 --3 object affected! 
<boolean>InstanceMgr.MakeObjectsUnique <node array>nodes <enum>multiNodeOption
       multiNodeOption enums: {#prompt|#individual|#group}

Makes the objects passed by-reference unique. Returns True on success.

FOR EXAMPLE:

tp = Teapot() --create a teapot
--> $Teapot:Teapot01 @ [0.000000,0.000000,0.000000]
tp1 = instance tp --instance the trapot
--> $Teapot:Teapot02 @ [0.000000,0.000000,0.000000]
tp2 = instance tp --instance it once again
--> $Teapot:Teapot03 @ [0.000000,0.000000,0.000000]
InstanceMgr.GetInstances tp &instances --get all instances
--> 3
--make the instances unique. Show a prompt to confirm the operation
InstanceMgr.MakeObjectsUnique &instances #prompt
--> true
--Check that every object is an instance of itself only.
InstanceMgr.GetInstances tp &instances
--> 1
InstanceMgr.GetInstances tp1 &instances
--> 1
InstanceMgr.GetInstances tp2 &instances
--> 1
<boolean>InstanceMgr.CanMakeObjectsUnique <node array>nodes

Returns True when the specified nodes can be made unique, False otherwise.

FOR EXAMPLE:

tp = Teapot() --create a teapot
--> $Teapot:Teapot01 @ [0.000000,0.000000,0.000000]
tp1 = instance tp --instance the teapot
--> $Teapot:Teapot02 @ [0.000000,0.000000,0.000000]
tp2 = copy tp --copy the teapot
--> $Teapot:Teapot03 @ [0.000000,0.000000,0.000000]
--Check if the two instances can be made unique - they can
InstanceMgr.CanMakeObjectsUnique #(tp,tp1)
--> True
--Check the original and the copy - not instances, cannot be made unique
InstanceMgr.CanMakeObjectsUnique #(tp,tp2)
--> False
<boolean>InstanceMgr.MakeModifiersUnique <node array>nodes <maxObject array>modifiers <enum>multiNodeOption
       multiNodeOption enums: {#prompt|#individual|#group}

Makes the specified modifiers of the supplied nodes unique. Returns True on success.

<boolean>InstanceMgr.CanMakeModifiersUnique <node array>nodes <maxObject array>modifiers

Returns True when the specified modifiers of the supplied nodes can be made unique, False otherwise.

<boolean>InstanceMgr.MakeControllersUnique <node array>nodes <maxObject array>controllers <enum>multiNodeOption
       multiNodeOption enums: {#prompt|#individual|#group}

Makes the specified controllers of the supplied nodes unique. Returns True on success.

<boolean>InstanceMgr.CanMakeControllersUnique <node array>nodes <maxObject array>controllers

Returns True when the specified controllers of the supplied nodes can be made unique, False otherwise.

Was this information helpful?