Setting render output path via Metadata Stream

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 02 February 2013   #1
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
 
Old 02 February 2013   #2
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.
__________________
Scripts :: linkedin
 
Old 02 February 2013   #3
Originally Posted by Swordslayer: 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.


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

Last edited by sarboon : 02 February 2013 at 06:27 AM.
 
Old 02 February 2013   #4
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).
__________________
Scripts :: linkedin
 
Old 03 March 2013   #5
Originally Posted by Swordslayer: 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).


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.
 
Old 03 March 2013   #6
Originally Posted by Swordslayer: 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.


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?
 
Old 03 March 2013   #7
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.
__________________
Scripts :: linkedin
 
Old 03 March 2013   #8
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:\temp\picture1.jpg" type:#bitmap), (AssetMetadata_StructDef assetId:"{038B1AA9-27F4-4552-A5FB-91644ADB9E1D}" filename:"c:\temp\picture2.jpg" type:#bitmap), (AssetMetadata_StructDef assetId:"{0860F962-85BD-4F08-9480-2421D77E6029}" filename:"c:\temp\picture3.jpg" type:#bitmap))
 
Old 03 March 2013   #9
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.
__________________
Scripts :: linkedin
 
Old 03 March 2013   #10
Originally Posted by sarboon: 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.



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.
__________________
http://3dcutout.com/
 
Old 04 April 2013   #11
Originally Posted by MZ: 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.


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?
 
Old 04 April 2013   #12
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/...mber=d30e452436

http://docs.autodesk.com/3DSMAX/15/...mber=d30e452436

--
__________________
http://3dcutout.com/
 
Old 04 April 2013   #13
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 03:54 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.