Notifications
Clear all

[Closed] Setting render output path via Metadata Stream

Hi,

I would like to set the render output path of max files without opening the max files as the files might be large and it doesn’t make sense to load up files just to set render output path.

Is it possible to set it by altering the metadata stream? I am able to load the bitmap assets with getMAXFileAssetMetadata and then alter and write them back with setMAXFileAssetMetada. However this changes all the paths of all bitmaps including the render output path of completed renders. Is there some way to change only the renderoutput path without affecting the rest of the assets?

Many thanks

11 Replies
2 Replies
 MZ1
(@mz1)
Joined: 1 year ago

Posts: 0

3dmax do not have a good metadata!, I always use a callback to write all data to a text file. by using 3dsmaxcmd you can render a file by your own render settings include output path, preset, output size, frame range,… without opening max file.

(@sarboon)
Joined: 1 year ago

Posts: 0

Are you manually starting the renders with 3dsmaxcmd or are you using a rendermanager?

I have finally managed to repath all the assets on the max file to realize 3dsmaxcmd doesnt seem to like paths set my setassetmetadata. I need to load up the max file, save it again before 3dsmaxcmd seem to recognize the updated path.

Anyone else seem to notice that behavior with 3dsmaxcmd and setassetmetadata?

Hi, it depends, some of the output files have #RenderOutput type but render elements and other output types are just #Bitmap – however checking if the file at path (either original or replaced) exists (for example using doesFileExist function) should give you enough information to make the decision.

2 Replies
(@sarboon)
Joined: 1 year ago

Posts: 0

doesFileExist simply returns either true of false and it only queries the current open scene?

I am new to maxscript and am trying very hard to wrap my head around it.

Thanks in advance for the patience

(@sarboon)
Joined: 1 year ago

Posts: 0

What if I managed to get the asset ID of the file to repath. How would one go about altering the path of just that particular file with setMAXFileAssetMetadata?

That’s okay, doesFileExist <filename_string> checks whether the string you pass to it is a valid file or directory (any file or directory, no relationship to the current scene or 3ds max at all). Output files that are not rendered yet don’t exists, whereas texture bitmaps (for example) do exist (if they don’t there’s a problem, anyway).

1 Reply
(@sarboon)
Joined: 1 year ago

Posts: 0

Thanks for that. It definitely pointed me in the right direction and was a good way to go about handling the problem that I didn’t think of. Let me give it a try first. I’ll probably get stuck but at least I am headed in the right direction.

Then it’s simple:

outputData = for data in assetMetadata where data.assetId == assetId do exit with data

Repath it, set the asset metadata and you’re done.

Okay that took me a while to work through. But more specifically, after the metastream is loaded into an array, how would one go about altering the path of the bitmap that matches the asset ID?

I have gotten the metadatastream loaded into the array. I can only set path of the current open scene with asset ID. What do I look at to alter the array? Is it a case of looping it to another array and checking at each loop for a matching assetID? and then if there is a match replace the path and store it in the new array?

(AssetMetadata_StructDef assetId:"{A5F0CDC8-DBA7-4E27-A452-71F142398860}" filename:"c:	emp\picture1.jpg" type:#bitmap), (AssetMetadata_StructDef assetId:"{038B1AA9-27F4-4552-A5FB-91644ADB9E1D}" filename:"c:	emp\picture2.jpg" type:#bitmap), (AssetMetadata_StructDef assetId:"{0860F962-85BD-4F08-9480-2421D77E6029}" filename:"c:	emp\picture3.jpg" type:#bitmap))

Just reread my last reply, it still applies. Example code would then be:

(
	local file = maxFilePath + maxFileName
	local assetMetadata = getMAXFileAssetMetadata file
	local elementMgr = maxOps.getCurRenderElementMgr()
	local elementMax = elementMgr.numRenderElements()

	for element = 0 to elementMax do
	( 
		local filename = elementMgr.getRenderElementFilename element
		local asset = filename as AssetUser
		local assetID = asset.getAssetId()
		local outputData = for data in assetMetadata where data.assetId == assetId do exit with data
		
		outputData.filename = substituteString outputData.filename "C:" "D:" -- for example
	)
	setMAXFileAssetMetada file assetMetadata
)

Not at max now to test it so the way I’m getting assetID there might not work as I expect it to (I recall being able to get AssetUser from .filename property of a bitmapTexture but no luck with it when using the exact same string coming from elsewhere) but as you already have that part working, just plug it in.

Of course you could collect all the render elements’ filenames in advance and then loop the assetMetadata once, this is just a sample to get you going.

 MZ1

I know using command-line(cmd) is a little tricky, you can use hiddendoscommand inside maxscript to execute command-line. if you want to render a file by specific outputpath then run this functions:

fn QMark Txt = “””+Txt+”” “

fn CMDRender MaxFile:”” OutputName:”” =
(
Str = QMark ((getdir #maxroot)+“3dsmaxcmd”)
Str+= QMark MaxFile
Str+= “-outputName:”+(QMark OutputName)
hiddendoscommand Str
)
–Example:
CMDRender MaxFile:“C:\CMDTest.max” OutputName:“C:\CMDTest.avi”

For more information about command-line just take a look at 3dmax help:

http://docs.autodesk.com/3DSMAX/15/ENU/3ds-Max-Help/index.html?url=files/GUID-B30BA517-B3C1-4D7C-AFB6-B220C2EDC529.htm,topicNumber=d30e452436

http://docs.autodesk.com/3DSMAX/15/ENU/3ds-Max-Help/index.html?url=files/GUID-B30BA517-B3C1-4D7C-AFB6-B220C2EDC529.htm,topicNumber=d30e452436