In 3ds Max 2010 and higher, the 3ds Max scene file provides Asset Metadata in a separate stream which can be accessed and modified by external applications. The Asset data is generated and managed by the AssetManager and AssetUser objects.
The Asset Metadata inside a saved 3ds Max scene file can also be accessed by MAXScript using the following functions:
getMAXFileAssetMetadata <filename>
Returns an array of AssetMetadata_StructDef struct instances corresponding to assets defined in the specified.MAXfile.
For more information about how 3ds Max resolves the file specified by filename
, see Scene File Path Resolution
setMAXFileAssetMetadata <filename> <array of AssetMetadata_StructDef instances>
Updates the asset metadata defined in the specified .MAXfile.
If the asset ID for an existing asset is not found in the AssetMetadata_StructDef struct instances, the asset is unchanged.
If an asset ID match is found, the asset types must be the same, otherwise a runtime error will be generated.
EXAMPLE
scenefilename = @"$scenes\assetMetaDataRewriteTest.max" fileassets = #() ( resetmaxfile #noprompt gc() myteapot = teapot material:(standard diffusemap:(bitmapTexture filename:@"$maps[1]\assetFile1.tga") bumpmap:(bitmapTexture filename:@"$maps[1]\assetFile2.tga")) print "material assets:" format "%\n"myteapot.material.diffusemap.filename format "%\n"myteapot.material.bumpmap.filename format "\n" print "asset manager assets - presave:" for i = 1 to assetmanager.GetNumAssets() do ( asset = assetmanager.GetAssetByIndex i format "% : % : % \n" (asset.GetAssetId()) (asset.GetFileName()) (asset.GetType()) ) format "\n" gc light:true savemaxfile scenefilename print "asset manager assets - postsave:" for i = 1 to assetmanager.GetNumAssets() do ( asset = assetmanager.GetAssetByIndex i format "% : % : % \n" (asset.GetAssetId()) (asset.GetFileName()) (asset.GetType()) ) format "\n" gc light:true print "original scene file assets:" fileassets = getMAXFileAssetMetadata scenefilename for asset in fileassets do format "% : % : %\n" asset.assetId asset.FileName asset.Type format "\n" gc light:true fileassets[1].filename = "assetFile3.tga" setMAXFileAssetMetadata scenefilename fileassets print "modified scene file assets:" fileassets = getMAXFileAssetMetadata scenefilename for asset in fileassets do format "% : % : %\n" asset.assetId asset.FileName asset.Type format "\n" gc light:true ok ) -- error tests oldType = fileassets[1].type fileassets[1].type = #animation setMAXFileAssetMetadata scenefilename fileassets fileassets[1].type = oldType oldAssetId = fileassets[1].assetId fileassets[1].assetId = 123 setMAXFileAssetMetadata scenefilename fileassets fileassets[1].assetId = oldAssetId oldAssetId = fileassets[1].assetId fileassets[1].assetId = "123" setMAXFileAssetMetadata scenefilename fileassets fileassets[1].assetId = oldAssetId
OUTPUT:
"$scenes\assetMetaDataRewriteTest.max" #() "material assets:" C:\Program Files\Autodesk\3ds Max 2010\Maps\assetFile1.tga C:\Program Files\Autodesk\3ds Max 2010\Maps\assetFile2.tga "asset manager assets - presave:" {FFF11D6D-8F2A-417E-8D45-4FAC1B750C43} : C:\Program Files\Autodesk\3ds Max 2010\Maps\assetFile2.tga : #bitmap {7647BFE7-3E18-480D-83BC-19F378C9E185} : C:\Program Files\Autodesk\3ds Max 2010\Maps\assetFile1.tga : #bitmap {4316B891-0A3E-48A6-BACA-139E228E5899} : glare_streaks_star_camera_filter.tif : #other {38B4658B-2DB4-4145-9245-0FCDF7DCC711} : glare_streaks_star_camera_filter.tif : #bitmap {77E039AC-3830-4A55-BB7E-0B41BAFB488D} : Untitled Scene : #xref "asset manager assets - postsave:" {FFF11D6D-8F2A-417E-8D45-4FAC1B750C43} : C:\Program Files\Autodesk\3ds Max 2010\Maps\assetFile2.tga : #bitmap {7647BFE7-3E18-480D-83BC-19F378C9E185} : C:\Program Files\Autodesk\3ds Max 2010\Maps\assetFile1.tga : #bitmap {38B4658B-2DB4-4145-9245-0FCDF7DCC711} : glare_streaks_star_camera_filter.tif : #bitmap {14C3E0E5-219F-4E26-9831-0CF67D83B770} : C:\Documents and Settings\username\My Documents\3dsMax\scenes\assetMetaDataRewriteTest.max : #xref {0D502254-780D-405A-8B55-F52E720E43AD} : glare_streaks_star_camera_filter.tif : #other "original scene file assets:" {FFF11D6D-8F2A-417E-8D45-4FAC1B750C43} : C:\Program Files\Autodesk\3ds Max 2010\Maps\assetFile2.tga : #bitmap {7647BFE7-3E18-480D-83BC-19F378C9E185} : C:\Program Files\Autodesk\3ds Max 2010\Maps\assetFile1.tga : #bitmap {38B4658B-2DB4-4145-9245-0FCDF7DCC711} : glare_streaks_star_camera_filter.tif : #bitmap "modified scene file assets:" {FFF11D6D-8F2A-417E-8D45-4FAC1B750C43} : assetFile3.tga : #bitmap {7647BFE7-3E18-480D-83BC-19F378C9E185} : C:\Program Files\Autodesk\3ds Max 2010\Maps\assetFile1.tga : #bitmap {38B4658B-2DB4-4145-9245-0FCDF7DCC711} : glare_streaks_star_camera_filter.tif : #bitmap OK #bitmap #animation -- Error occurred in anonymous codeblock; filename: C:\Program Files\Autodesk\3ds Max 2010\ui\macroscripts\; position: 1590; line: 56 -- Runtime error: Incorrect asset type for assetId {38B4658B-2DB4-4145-9245-0FCDF7DCC711}; expecting: #Bitmap; got: #animation #bitmap "{FFF11D6D-8F2A-417E-8D45-4FAC1B750C43}" 123 -- Error occurred in anonymous codeblock; filename: C:\Program Files\Autodesk\3ds Max 2010\ui\macroscripts\; position: 1737; line: 61 -- Unable to convert: 123 to type: String "{FFF11D6D-8F2A-417E-8D45-4FAC1B750C43}" "{FFF11D6D-8F2A-417E-8D45-4FAC1B750C43}" "123" -- Error occurred in anonymous codeblock; filename: C:\Program Files\Autodesk\3ds Max 2010\ui\macroscripts\; position: 1892; line: 66 -- Runtime error: Cannot convert assetId string to assetId value: "123" "{FFF11D6D-8F2A-417E-8D45-4FAC1B750C43}"