31
[Max] I need help! / Working MXS code to remove .hdc file
« on: 2018-05-09, 20:25:32 »
I've managed to get that working. Here's the code to remove that asset completely from the metadata and ATSOps in the time it takes to save the file. Comments in the code.
No reopening is necessary.
No reopening is necessary.
Code: [Select]
/* Script to remove the *.hdc file from corona renderer whether missing or not.
Written by 3dwannab
v1.0 - 09/05/20018
*/
-- clearlistener()
if classof renderers.current == CoronaRenderer then (
-- Clear from render settings
renderers.current.gi_uhdCache_file = ""
--update asset tracking
ATSOps.refresh()
-- Get current maxfile
current_filename = (maxFilePath + maxFilename)
-- Create empty array
fileassets = #()
-- Retrieves all fileassets from current_filename var
fileassets = getMAXFileAssetMetadata current_filename
-- Search in above array where there's a string matching "*filename:\"*.hdc\" type:#animation resolvedFilename:\"*\"*" and collect it
ReleaseReference_Id = (for i in fileassets where matchpattern (i as string) pattern:"*filename:\"*.hdc\" type:#animation resolvedFilename:\"*\"*" collect i.assetId)[1]
-- ReleaseReference_Filename = (for i in fileassets where matchpattern (i as string) pattern:"*filename:\"*.hdc\" type:#animation resolvedFilename:\"*.hdc\"*" collect i.FileName)[1]
-- Releases the reference found in ReleaseReference_Id array
try(AssetManager.ReleaseReference ReleaseReference_Id)catch(print "No cache file found...")
-- Needed to update file only if ReleaseReference_Id not undefined
if ReleaseReference_Id != undefined then (
savemaxfile current_filename
-- Garbage collection
gc light:true
)
)