Container : Helper

Container - superclass: helper; super-superclass:node - 10:0 - classID: #(1848947859, -473657791) 

In 3ds Max 2010 and higher, a Container is a helper object in a scene that is used to group self-contained content together and manage, publish, and inherit the content including the ability to unload the content objects from memory.

See Containers and Interface: Containers for more information.

Constructors:

Container ... ContainerHelper ... 

See also Containers.CreateContainer() in Interface: Containers.

Local Content (Left) and Inherited Content (Right) - Quick Navigation

Properties:

Manage Container Properties

<Container>.unloaded BooleanClass default: false -- boolean;   

Get/set the unloaded state of the container.

When set to *true* , the container is unloaded by saving the content to the disk and removing it from the scene.

When set to *false* , the container is loaded by loading the content from the disk and showing it in the scene.

See also UnloadContainer and LoadContainerMethods for related methods.

<Container>.autoUpdateClosed BooleanClass default: false -- boolean; AutoUpdate_when_Closed 

Get/set whether to update the content automatically when the container is closed.

Corresponds to the "Auto Update when Closed" checkbox in the Container's UI.

<Container>.duplicateMatchingLayers     BooleanClass    default: true   --  boolean; Match_Layers_by_Parent

Get/set the state of the "Match Layers by Parent" checkbox.

Local Content Properties

<Container>.localDefinitionFilenameString default: "" -- filename; Local_Definition_Filename 

Get/set the "Local Definition" file name.

Definition files have the format of a 3ds Max scene file, but use a different .MAXC file extension. This is to allow users to distinguish container definitions from regular max scenes when browsing folders and prevent accidental edits of container definitions. It is possible to rename the container definition and open it as a .MAX file.

Local containers use a local definition file.

Inherited containers reference a source definition file .If the container is inherited, the name is empty.

Inherited Content Properties

<Container>.sourceDefinitionFilename String default: "" -- filename; Source_Definition_Filename 

Get/set the "Source Definition" filename. If the container is local, the name is empty.

Definition files have the format of a 3ds Max scene file, but use a different .MAXC file extension. This is to allow users to distinguish container definitions from regular max scenes when browsing folders and prevent accidental edits of container definitions. It is possible to rename the container definition and open it as a .MAX file.

Inherited containers reference a source definition file.

Local containers use a local definition file.

Proxies Properties

<Container>.alternateDefinitionFilename ArrayParameter default: #() -- filename array; Alternate_Definition_Filename; SubAnim 

Get/set the alternate (Proxy) definition filenames list.

Available in 3ds Max 2011 and higher.

<Container>.currentAlternateDefinition Integer default: 0 -- integer; Current_Alternate_Definition 

Get/set the index of the current Proxy definition used from the file list.

Available in 3ds Max 2011 and higher.

<Container>.proxyType Name default: #none -- enum 

Get/set the state of the radio button controlling the use of Proxies.

Possible values are:

#none - Do not use a Proxy file.

#alternate - Use the Proxy file specified by the previous two properties.

Available in 3ds Max 2011 and higher.

Content RulesProperties

The content rules are stored with the .MAXC asset file and control how the content will behave when inherited by a container.

<Container>.allowInPlaceEditing BooleanClass default: false -- boolean; Allow_In_Place_Editing 

Get/set the In Place Editing Container Rule.

Corresponds to the state of the "Allow In-Place Editing" checkbox in the Container's UI.

When set to *false* (default), the content can be inherited, but not edited in place.

When set to *true* , the content can be inherited and edited in place, resulting in overwriting of the content in the original asset file.

<Container>.accessContent BooleanClass default: false -- boolean; Allow_Content_Access 

Get/set the state of the Access Content Rule.

This Rule is not exposed to the User Interface and is considered only when *.AllowInPlaceEditing* is set to *false* . When In Place Editing is allowed, the content of a closed container will not be accessible regardless of this Rule.

When set to *false* (default), the content will not be accessible when inherited. The content cannot be selected, modified or accessed using MAXScript.

When set to *true* , the content will be accessible when inherited. Any local modification to such content will be LOST when Unloaded.

<Container>.accessPublishedContent BooleanClass default: false -- boolean; Allow_Published_Content_Access 

Get/set the state of the Access Published Content Rule.

This Rule is not exposed to the User Interface.

Display- ContainerProperties

<Container>.displayLabel BooleanClass default: false -- boolean; Display_Label 

Get/set the state of the Name checkbox. (called "Label" in 3ds Max 2010).

When set to *true* , a text label appears next to the Container to show its Name.

<Container>.displayStatus BooleanClass default: false -- boolean; Display_Status 

Enable/disable the display of the Container's Status.

Available in 3ds Max 2011 and higher.

<Container>.editingUser String default: "" -- string; Editing_User; 

Get/set the name of the user editing the Container.

Available in 3ds Max 2011 and higher.

<Container>.contentBoundingBox BooleanClass default: false -- boolean; Content_Bounding_Box 

Get/set the state of the Expand Bounding Box checkbox.

When set to *true* , a bounding box of the container will expand to enclose the content.

<Container>.size Float default: 10.0 -- animatable; worldUnits 

Get/set the Size value controlling the size of the Container's icon.

<Container>.updateNeeded BooleanClass default: false -- boolean; Update_Needed 

Contains true if the Container needs an update. Reflects the state of the icon next to the Update button.

Read-only.

Available in 3ds Max 2011 and higher.

Display -ContentsProperties

<Container>.overrideNodeProperties BooleanClass default: false -- boolean; Override_Object_Properties 

Get/set the state of the "Override Obj Properties" checkbutton.

When set to *true* , the content will display using the Container's display properties including wireframe color, visibility settings, and so on. If the content is set to use properties By Layer, the Container's Layer will be used instead of the content's Layers.

When set to *false* , the content will display using its own display properties.

Container interfaces:

Interface:IContainerObject 

Properties:

.proxyType: enum : Read|Write 
proxyType enums: {#none|#alternate} 

Get/set the state of the radio button controlling the use of Proxies.

Possible values are:

#none - Do not use a Proxy file.

#alternate - Use the Proxy file specified by the previous two properties.

Available in 3ds Max 2011 and higher.

Methods:

Manage ContainerMethods

<boolean><Container>.LoadContainer() 

Loads the Container's content from its definition and local modifications. Only available when unloaded.

Corresponds to pressing the "Load" button in the Container's UI when the Container is in Unloaded state (see .unloaded property for querying this state). The button will change to "Unload".

Returns *true* on success, *false* otherwise.

<boolean><Container>.UnloadContainer() 

Unloads the Container by saving the local definition and deleting the content from the scene.

Corresponds to pressing the "Unload" button in the Container's UI when the Container is in the Loaded state (see .unloaded property for querying this state). The button will change to "Load".

Returns *true* on success, *false* otherwise.

<boolean><Container>.SetOpen <boolean>open 

When the argument is *true* , opens the Container, equivalent to pressing the "Open" button in the Container's UI.

When the argument is *false* , closes the Container, equivalent to pressing the "Close" button in the Container's UI.

<boolean><Container>.IsOpen() 

Returns *true* if the Container is open, *false* otherwise. See previous method for controlling the open state.

<boolean><Container>.UpdateContainer() 

Updates the content of the Container, preserving local modifications. Corresponds to the "Update" button in the Container's UI.

Returns *true* on success, *false* otherwise.

<boolean><Container>.MakeUnique() 

Merges the Container's source and recursively merges any nested containers among its content.

Corresponds to pressing the "Make All Content Unique" button in the Container's UI.

<boolean><Container>.IsUnique() 

Returns *true* if the content is unique, *false* otherwise.

Access Type Control Methods

<void>SetAccessType <enum>accessType 
accessType enums: {#noAccess|#onlyEditInPlace|#onlyAddNewObjects|#anythingUnlocked} 

Sets the access type to the given enum value.

Available in 3ds Max 2011 and higher.

<enum>GetAccessType() 
GetAccessType enums: {#noAccess|#onlyEditInPlace|#onlyAddNewObjects|#anythingUnlocked} 

Returns the access type as an enum value.

Available in 3ds Max 2011 and higher.

<enum>InheritedAccessType() 
InheritedAccessType enums: {#noAccess|#onlyEditInPlace|#onlyAddNewObjects|#anythingUnlocked} 

Returns the inherited access type as an enum value.

Available in 3ds Max 2011 and higher.

<void>SetLockedContents<enum>lockedType <boolean>clear 
lockedType enums: {#lockAllMaterials|#lockAllModifiers|#lockAllAnimation|#lockAllObjects} 

Sets the lock for the content component specified by the first argument's enum to the Boolean value of the second argument.

Available in 3ds Max 2011 and higher.

<boolean>IsLockedContents <enum>lockedType 
lockedType enums: {#lockAllMaterials|#lockAllModifiers|#lockAllAnimation|#lockAllObjects} 

Returns true if the content component specified by the argument is locked, false if it is unlocked.

Available in 3ds Max 2011 and higher.

EXAMPLES:


   c = container()
   --Check the Modifiers Lock:
   $Container001.IsLockedContents #lockAllModifiers
   --> false 
   --Lock theModifiers:
   $Container001.SetLockedContents #lockAllModifiers true
   --> OK 
   --Check the Modifiers Lock:
   $Container001.IsLockedContents #lockAllModifiers
   --> true 
   --Unlock the materials:
   $Container001.SetLockedContents #lockAllMaterials false
   --> OK 
<void>ClearLockedContents() 

Clears the locked contents of the Container.

Available in 3ds Max 2011 and higher.

<string>GetStatusString() 

Returns the status string of the Container. This is the same string displayed in the viewport label if the .displayStatus property is set to true.

Available in 3ds Max 2011 and higher.

EXAMPLES:


   $Container001.GetStatusString()
   --> "No Access"
   $Container001.UnloadContainer()
   --> true
   $Container001.GetStatusString()
   -->"Unloaded"
   $Container001.MakeUnique()
   --> true
   $Container001.GetStatusString()
   --> "Unsaved" 

Manage Container - Edit In PlaceMethods

The"Edit In Place"checkbutton performs two operations internally depending on its state:

<boolean><Container>.CanEditInPlace() 

Returns *true* if the container can be edited in-place, *false* otherwise.

The container rule controlling whether the content can be edited in place when inherited is set using the allowInPlaceEditing property in the local container whose content is being inherited.

The content file must have been saved with that rule set to true to allow other containers inheriting that content to edit it in place.

Local ContentMethods

<boolean><Container>.AddNodeToContent <node>node 

Adds the specified node and its children/dependents to the Container's content.

The container node becomes the parent of the content node. Some nodes are automatically added to the local content along with the input node:

Returns *true* on success, *false* otherwise.

<boolean><Container>.AddNodesToContent <&node array>nodes

nodes is In and Out parameter 

Adds the provided array of nodes and all their children and dependents to the Container's content. See previous method for details.

Returns *true* on success, *false* otherwise.

EXAMPLES:

   b = Box()
   -->$Box:Box01 @ [0.000000,0.000000,0.000000]
   s = Sphere pos:[100,0,0]
   -->$Sphere:Sphere01 @ [100.000000,0.000000,0.000000] 
   --Will be created at the origin unless position is provided.
   --Compare to Containers.CreateContainer() which creates
   --at the average position of all content nodes
   c = Container()
   -->$Container:Container01 @ [0.000000,0.000000,0.000000] 
   c.addNodeToContent b--adding single node
   -->true
   c.addNodesToContent #(s)--adding an array of one or more nodes
   -->true 
   c.GetContentNodes false &theNodes
   --> OK
   theNodes
   --> #($Box:Box01 @ [0.000000,0.000000,0.000000],$Sphere:Sphere01 @ [100.000000,0.000000,0.000000]) 
<void><Container>.GetContentNodes <boolean>nestedContainerNodes<&node array>contentNodes 

contentNodes is Out parameter 

Returns an array of the content nodes of the container into the second by-reference parameter.

If the first argument is passed as *true* , nested containers are also processed.

If the first argument is passed as *false* , only the content of the current container is returned.

<boolean>IsNodeInContent <node>node <boolean>nestedContainerNodes 

Returns *true* if the specified node is in the content.

If the second argument is *true* , nested containers in the inherited content are also searched.

If *false* , only the current container is searched.

<boolean><Container>.RemoveNodeFromContent <node>node <boolean>detach 

Removes the node specified as first argument from the Container's content.

If the second argument is specified as *true* , unlinks the node from the Container. If *false* , the node will remain a child of the Container but will not be in the content of the Container anymore.

<boolean><Container>.SaveContainer <boolean>newFileNamesaveAsVersion:<integer> 

saveAsVersion default value: 0

Saves the content and rules of the Container as the new definition.

Returns true on success, false otherwise.

If the newFileName argument is *true* , a save file dialog is shown to specify a new file name, making the method behave like the "Save As" button in the UI.

If the newFileName argument is *false* , the current file name is used. If the file name is not defined, the save file dialog is shown. This makes the method behave like the "Save" button in the UI.

In 3ds Max 2011 and higher, if the saveAsVersion: optional keyword argument is supplied, is different than 0 and equals a supported version number, the MAXC file is saved in that format. If the argument is unsupplied or 0, the MAXC file is saved in the format of the current 3ds Max Version.

Valid value is 2010 in 3ds Max 2011, and 2011 in 3ds Max 2012

<boolean><Container>.ReloadContainer() 

Reloads the Container. Same as LoadContainer(), but does not depend on the state of the .unloaded property and is thus always available. Discards unsaved changes.

Corresponds to pressing the "Reload" button in the Container's UI.

Returns *true* on success, *false* otherwise.

Inherited ContentMethods

<boolean><Container>.MergeSource() 

Turns an inherited container into an unsaved local container content, merging its content into the scene. Does not merge nested container's content.

Corresponds to pressing the "Merge Source Definition" button in the Container's UI.

Returns *true* on success, *false* otherwise.

EXAMPLE:

   ( -- start script

   -------------------------Creating a Container:-----------------------
   resetMaxFile #noprompt --reset the scene
   cnt01 = container size:50 name:"LocalContent" --create a container
   cnt01.displaylabel = true --display its label
   cnt_filename = getDir #scene + "\\_Container01.maxc" --define file name
   cnt01.localDefinitionFilename = cnt_filename --assign the file name
   cnt01.accessContent =true --enable access to inherited content
   cnt01.allowInPlaceEditing = false --disallow in-place editing 
   --------------------------Creating some Content:------------------------
   obj01 = Teapot wirecolor:blue --create a blue teapot
   cnt01.AddNodeToContent obj01 --add to content
   cnt01.SaveContainer false --save to the current file name 
   -------------------------Display and Wait...:-----------------------
   max modify mode --switch to modify panel
   max views redraw --update the viewports
   select cnt01 --select the container
   sleep 2 --and wait for two seconds 

   -------------------------Inherit the Content:-----------------------
   cnt02 = containers.CreateInheritedContainer cnt_filename --inherit file
   cnt02.name ="InheritedContent" --name the container
   cnt02.pos = [0,60,0] --move it to the side
   cnt02.size = 50 --set the size of the icon
   cnt02.displayLabel = true --and display the label 
   -------------------------Display and Wait...:-----------------------
   max tool zoomextents all --zoom the viewports
   select cnt02 --select the inherited container
   max views redraw --update the viewports
   sleep 2 --wait for two seconds 

    --------------------------Adding MoreContent:------------------------
   obj02 = Sphere radius:15 pos:[50,0,15] wirecolor:green --green sphere
   obj03 = Box pos:[100,0,0] wirecolor:blue --blue box
   cnt01.AddNodesToContent #(obj02, obj03) --add nodes array to content
   obj01.wirecolor = red --change the teapot to red
   cnt01.SaveContainer false save to update the container definition 
   -------------------------------Updating Inherited Content:-----------------------------
   cnt02.updateContainer() --update the inherited container from disk
   format "\nCurrently In The Scene: % objects\n" objects.count
   print objects --print scene objects - inherited content is there! 
   -->Currently In The Scene: 8 objects
   -->$Container:LocalContent @ [0.000000,0.000000,0.000000]
   -->$Teapot:Teapot01 @ [0.000000,0.000000,0.000000]
   -->$Sphere:Sphere01 @ [50.000000,0.000000,15.000000]
   -->$Box:Box01 @ [100.000000,0.000000,0.000000]
   -->$Container:InheritedContent @ [0.000000,100.000000,0.000000]
   -->$Teapot:Teapot01 @ [0.000000,100.000000,0.000000]
   -->$Sphere:Sphere01 @ [50.000000,100.000000,15.000000]
   -->$Box:Box01 @ [100.000000,100.000000,0.000000] 
   max views redraw --update the viewports
   sleep 2 --wait for two seconds 

    --------------------------Changing Access Rules:------------------------
   cnt01.accessContent =false --disallow the access to inherited content
   cnt01.SaveContainer false --resave to update the rules
   cnt02.updateContainer() --update the inherited container from disk
   format "\nCurrently In The Scene: % objects\n" objects.count
   print objects--print scene objects - inherited content is not there! 
   -->Currently In The Scene: 5 objects
   -->$Container:LocalContent @ [0.000000,0.000000,0.000000]
   -->$Teapot:Teapot01 @ [0.000000,0.000000,0.000000]
   -->$Sphere:Sphere01 @ [50.000000,0.000000,15.000000]
   -->$Box:Box01 @ [100.000000,0.000000,0.000000]
   -->$Container:InheritedContent @ [0.000000,100.000000,0.000000]  
   max views redraw --update the viewports
   sleep 2 --wait for two seconds 

    ----------------------------------Unloading Inherited Container:--------------------------------
   cnt02.UnloadContainer()
   max views redraw --update the viewports
   sleep 2 --wait for two seconds 

   -------------------------------------Making Inherited Container Local:-----------------------------------
   cnt02.MakeUnique() --make the content unique
   format "\nCurrently In The Scene: % objects\n" objects.count
   print objects --print scene objects - the content is now local!
   -->Currently In The Scene: 8 objects
   -->$Container:LocalContent @ [0.000000,0.000000,0.000000]
   -->$Teapot:Teapot01 @ [0.000000,0.000000,0.000000]
   -->$Sphere:Sphere01 @ [50.000000,0.000000,15.000000]
   -->$Box:Box01 @ [100.000000,0.000000,0.000000]
   -->$Container:InheritedContent @ [0.000000,100.000000,0.000000]
   -->$Teapot:Teapot01 @ [0.000000,100.000000,0.000000]
   -->$Sphere:Sphere01 @ [50.000000,100.000000,15.000000]
   -->$Box:Box01 @ [100.000000,100.000000,0.000000] 
   cnt02.localDefinitionFilename = cnt_filename --set the same file name
   cnt02.name ="AlsoLocal"--rename the object, too 
   for i = 1 to cnt02.children.count do --Stack the content vertically
     cnt02.children[i].pos = cnt02.pos + [0,0,(i-1)*50]
   cnt02.SaveContainer false --and save, overwriting the original asset 
   max views redraw --update the viewports
   sleep 2 --wait for two seconds

   -------------------------------------------------Reloading The New File In Original Container:-----------------------------------------------
   cnt01.ReloadContainer() --reload the content from file
   cnt01.SetOpen false --close the container

   )--end script