Interface: AssetManager

The AssetManagerCore Interface introduced in 3ds Max 2010 manages the saving of Asset data into the 3ds Max scene file.

Interfaces > Core Interfaces > AssetManager

 

   

Core Interfaces - Quick Navigation

In releases prior to 3ds Max 2010, a plug-in that referenced an external file (an asset) holds the asset’s filename as a string or as a Path object, and stores the filename to the 3ds Max scene file as a string or an IParameterBlock2 TYPE_FILENAME parameter. To allow 3ds Max to identify the assets used by a plug-in, the plug-in implements an IAssetAccessor-derived class. The information provided from this class was primarily used by the Asset Tracker.

Since 3ds Max 2010, assets are handled as instances of class AssetUser . An instance of this class contains information on the asset filename, its type, and the 3ds Max scene file that depends on it (this is used for resolving external references). Access to, and lifetime management of assets is handled by the Asset Manager.

Loading and saving the Asset to the 3ds Max scene file is now done through the AssetUser and the AssetManager.

When saving a 3ds Max scene, the asset data is saved by the Asset Manager to a separate stream in the 3ds Max file. This gives the capability to external programs to access the asset data to identify the assets used by the scene and potentially modify the asset data without loading the scene file into 3ds Max.

The following methods expose the information handled by the AssetManager to MAXScript:

Methods:

Get Asset

<IObject>AssetManager.GetAsset <&TSTR>fileName <enum>assetType autoAcquire:<bool> 		

fileName is In parameter 		
assetType enums: {#Other | #Bitmap | #XRef | #Photometric | #Animation | #VideoPost | #BatchRender | #ExternalLink | #RenderOutput | #PreRenderScript | #PostRenderScript | #Sound | #Container | #MaxCreationGraph} 		
autoAcquire default value: true 	   

Returns the AssetUser Object of the asset with the specified file name and asset type.

   

<IObject>AssetManager.GetAssetByIndex <index>index 

Returns the AssetUser Object of the asset with the given index.

Use AssetManager.GetNumAssets() to get the number of Assets.

See example at the end of this topic for details.

   

<IObject>GetAssetById <&TSTR>assetid

assetid is In parameter

NEW in 3ds Max 2017: Returns the AssetUser Object of the asset with the given asset ID.

EXAMPLE:

box material:(standard diffusemap:(bitmaptexture filename:"fur.tga"))
--> $Box:Box002 @ [0.000000,0.000000,0.000000]
assetid = (assetmanager.GetAssetByIndex 1).GetAssetId(); 
--> "{DBD187ED-0BA9-4D07-9B85-BA44F5170FD9}"
assetmanager.GetFileName assetid
--> "fur.tga"	
a=assetmanager.GetAssetById assetid
--> <IObject:AssetUser>
a.GetFileName()
--> "fur.tga"

   

Get Asset ID and File Name

<TSTR by value>AssetManager.GetAssetId <&TSTR>fileName <enum>assetType 

fileName is In parameter 
assetType enums: {#Other | #Bitmap | #XRef | #Photometric | #Animation | #VideoPost | #BatchRender | #ExternalLink | #RenderOutput | #PreRenderScript | #PostRenderScript | #Sound | #Container | #MaxCreationGraph} 

Returns the asset ID of the specified file name of the given asset type.

EXAMPLE:

AssetManager.GetAssetID "Simple_Stone_Mtl_Marble_bump.jpg" #Bitmap
"{7477A3A4-0304-47AC-8427-6B490673231A}"

   

<TSTR by value>AssetManager.GetFileName <&TSTR>assetid 

assetid is In parameter 

Returns the file name of the asset with the given AssetID.

EXAMPLE:

AUIO = AssetManager.GetAssetByIndex 1--get the AsserUser with index 1
--><IObject:AssetUser>
 
AUIO.GetFileName()--get the file name
-->"Untitled Scene"
 
--This is equivalent:
AssetManager.GetFileName (AUIO.getAssetID())--get the name by AssetID
-->"Untitled Scene"

Add and Release Reference

   

<integer>AssetManager.GetNumReference <&TSTR>assetid 

assetid is In parameter 

Returns the number of the References to the Asset with the given AssetID.

   

<bool>AssetManager.AddReference <&TSTR>assetid 

assetid is In parameter 

Adds a Reference to the Asset with the given AssetID.

Returns true on success, false on failure.

   

<bool>AssetManager.ReleaseReference <&TSTR>assetid 

assetid is In parameter 

Releases the Reference of the Asset with the given AssetID.

Returns true on success, false on failure.

EXAMPLE:

AUIO = AssetManager.GetAssetByIndex 1--get the AsserUser with index 1
--><IObject:AssetUser>
 
AID =AUIO.getAssetID()--get the file name
-->"{7477A3A4-0304-47AC-8427-6B490673231A}"
 
AssetManager.GetNumReference AID--get the reference numberby AssetID
-->4
 
AssetManager.AddReference AID--add a referenceby AssetID
-->true
 
AssetManager.GetNumReference AID--get thereference numberby AssetID
-->5
 
AssetManager.ReleaseReference AID--release a referenceby AssetID
-->true
 
AssetManager.GetNumReference AID--get thereference numberby AssetID
-->4

Get Number of Assets and AssetUsers

<INT64>AssetManager.GetNumAssetUsersCreated() 

Returns the total number of AssetUser instances created during the current 3ds Max session.

   

<INT64>AssetManager.GetNumAssetUsers() 

Returns the number of AssetUser instances.

   

<INT64>AssetManager.GetNumAssetsCreated() 

Returns the total number of Assets created during the current 3ds Max session.

   

<INT64>AssetManager.GetNumAssets() 

Returns the number of Assets.

   

EXAMPLE:

AssetManager.GetNumAssetUsersCreated()
-->19862L
 
AssetManager.GetNumAssetUsers()
-->114L
 
AssetManager.GetNumAssetsCreated()
-->1080L
 
AssetManager.GetNumAssets()
-->18L

   

<bool>AssetManager.RemoveMissingAssets()

Removes any missing assets.

Returns True if missing assets were removed successfully.

Returns False if no missing assets were removed.

Available in 3ds Max 2016 and higher.

Examples:

EXAMPLE:

The following script outputs to the MAXScript Listener the ID, type, and file name of all Assets in the current scene:

--Loop through all Asset indices:
for i = 1 to AssetManager.GetNumAssets() do
(
local AUIO = AssetManager.GetAssetByIndex i--get the AssetUser IObject
local AID = AUIO.GetAssetId()--get the Asset's ID
local AType = AUIO.getType()--get the Asset's Type
local AFile = AUIO.getfilename()--get the Asset's File Name
format"ID:% Type:% File:%\n"AID AType AFile--format the info
)

POSSIBLE OUTPUT:

ID:{B6D86A17-85FF-42E2-99D4-BB2F1857C4FB} Type:#bitmap File:C:\Documents and Settings\username\My Documents\3dsMax\sceneassets\images\PlaneToBake_diffuse.tga
ID:{7477A3A4-0304-47AC-8427-6B490673231A} Type:#bitmap File:Simple_Stone_Mtl_Marble_bump.jpg
ID:{8188ACCD-A014-4B24-A3DD-697269D8BFDB} Type:#bitmap File:Simple_Concrete_Mtl_BroomStraight_pattern.jpg
ID:{B0B6A6FD-2B76-4EA0-8B34-D1F3F3596F91} Type:#bitmap File:x47645df4
ID:{CF096A5C-41C8-43FD-852F-8823B9A707C7} Type:#bitmap File:C:\Documents and Settings\username\My Documents\3dsmax\renderoutput\AssetMan_.tga
ID:{D5A9608F-EE4E-4BDC-AAB6-93D3D34E5F65} Type:#bitmap File:Simple_Concrete_Mtl_BroomCurved_pattern.jpg
ID:{30241317-2623-4628-9BF1-ED06449E3D06} Type:#bitmap File:Simple_Metal_Mtl_DiamondPlate_pattern.jpg
ID:{742F4FE3-91FC-48E7-9F3B-37CE76D37046} Type:#bitmap File:C:\Documents and Settings\username\My Documents\3dsMax\sceneassets\images\Sphere01_diffuse.tga
ID:{8BEFCD25-F133-4D5E-8678-E710F8BFBFF8} Type:#bitmap File:Simple_Metal_Mtl_CheckerPlate_pattern.jpg
ID:{21B0F246-C6D0-44D3-9ECE-87D7BF8AFF14} Type:#bitmap File:Simple_Metal_Mtl_Break_pattern.jpg
ID:{B5BB9B91-DBB4-486B-835A-A107F9F4783F} Type:#bitmap File:C:\Documents and Settings\username\My Documents\3dsMax\sceneassets\images\PlaneToBake_lighting.tga
ID:{65CAE8F4-F0DF-4CC3-A05C-733CC0285CF4} Type:#bitmap File:C:\Program Files\Autodesk\3ds Max 2010\CachedThumbnails\1000000000000003.bmp
ID:{5FF857B0-D2E0-4DCC-B4F7-97248CBC6FC5} Type:#bitmap File:C:\Documents and Settings\username\My Documents\3dsMax\sceneassets\images\Sphere01LightingMap.tga
ID:{31FE4D48-12B5-422E-A5D2-3A2979D773CD} Type:#bitmap File:C:\Documents and Settings\username\My Documents\3dsMax\sceneassets\images\Sphere01_lighting.tga
ID:{6AC17983-685D-42A8-8269-DBEA5FECB0DB} Type:#bitmap File:C:\Documents and Settings\username\My Documents\3dsMax\sceneassets\images\Plane01_lighting.tga
ID:{9BEAD40C-2562-42CF-A95D-E13E0EBD526D} Type:#bitmap File:C:\Program Files\Autodesk\3ds Max 2010\CachedThumbnails\1000000000000004.bmp
ID:{2253E2F5-82FE-46B1-B012-BC5FA100D86A} Type:#bitmap File:C:\Documents and Settings\username\My Documents\3dsMax\sceneassets\images\Sphere01DiffuseMap.tga
ID:{42B8F3F4-0D38-49D9-A9D9-598288A4E674} Type:#renderoutput File:C:\Documents and Settings\username\My Documents\3dsmax\renderoutput\AssetMan_.tga
ID:{AC8AF90A-44DB-42C9-AC9E-7C35A7EBFF1A} Type:#bitmap File:C:\Documents and Settings\username\My Documents\3dsMax\sceneassets\images\Plane01_diffuse.tga
ID:{A9742E5A-4AB4-471D-A440-DE47F5262EF9} Type:#bitmap File:Simple_Stone_Mtl_Granite_bump.jpg
ID:{8EC0A624-D996-48D7-9AA8-775ACA1652B9} Type:#xref File:C:\Documents and Settings\username\My Documents\3dsmax\scenes\RENOIR\AssetManagerTest.max
ID:{B51DCC8A-57C6-4308-B5B8-00FE0A105A29} Type:#bitmap File:Simple_Stone_Mtl_StoneWall_bump.jpg
ID:{16544B6C-5D81-4E96-9B4D-550BFD4111E3} Type:#bitmap File:Simple_Metal_Mtl_Brush_pattern.jpg

See also

Accessing AssetManager, AssetUser and Asset Metadata in MAX Files

IObject:AssetUser

MAX File Asset Metadata Stream Access

Interface: FileResolutionManager