PDA

View Full Version : Modify MD5Export script for Max to Name File.


TechnicallyArtistic
07-18-2011, 07:38 PM
I'm trying to modify the md5export script to get the file name when it's exporting to save myself some file naming nightmares.

I'm not really familiar with Max Script but am familiar with Mel Script so I'm kind of blind of what part I'm looking for here.

I assume I'm using something like

getFileNameFile()

Here is the chunk of code I think it goes into from what I can tell. Can anybody see how this chunk might be modified to get the file name to name this export file so I don't have to type it in each time I export out a file? It just needs to be the same name as the .max file but with the .md5 extension instead.

function md5export = (
cursel = GetCurrentSelection()
mesh = cursel[1]
if mesh == undefined do
(
messagebox "no object selected"
return undefined
)
if (((classof mesh.baseobject) as string) != "Editable_mesh") do
(
messagebox "selected obj is not an editable_mesh"
return undefined
)
if g_export_anim_only then
(
animfilename = getsavefilename caption:"Save MD5anim" types:"MD5anim (*.md5anim)|*.md5anim"
if animfilename != undefined do
(
animfile = createfile animfilename
if (animfile != undefined) do
(
md5 = md5exportobj mesh
-- format "%" (md5[1] as string) to:outfile
format "%" (md5[2] as string) to:animfile
-- format "%\n" (md5[1] as string)
-- format "%\n" (md5[2] as string)
-- close outfile
close animfile
)
)

)
else
(
outfilename = getsavefilename caption:"Save MD5" types:"MD5mesh (*.md5mesh)|*.md5mesh"
if outfilename != undefined do
(
outfile=createfile outfilename
animfilename = copy outfilename
endindx = findstring animfilename ".md5mesh"
animfilename = replace animfilename endindx 8 ".md5anim"
animfilename = getsavefilename caption:"Save MD5anim" filename:animfilename types:"MD5anim (*.md5anim)|*.md5anim"
if animfilename != undefined then animfile = createfile animfilename
if (outfile!= undefined and animfile != undefined) do
(
md5 = md5exportobj mesh
format "%" (md5[1] as string) to:outfile
format "%" (md5[2] as string) to:animfile
-- format "%\n" (md5[1] as string)
-- format "%\n" (md5[2] as string)
close outfile
close animfile
)
)
)
)

Also, if that's not it any anybody wanted to see the whole file, it can be downloaded here:
http://home.mnet-online.de/der/3dsmax-md5exporter.zip

stigatle
07-18-2011, 09:07 PM
Hope this helps:

TempFilenameOnly = getFilenameFile (maxFilePath + maxFileName)
fullPath = ( maxFilePath + TempFilenameOnly + ".md5")
print fullPath

so you should do:

outfilename = fullPath

TechnicallyArtistic
07-18-2011, 10:07 PM
Well, that's slightly helpful in that getting the code is a bit clearer. But I still haven't been able to figure out how that goes into the actual script there so that when I click the export button the save window comes up with the file name already loaded in it.

I've tried inserting some of that stuff into there, but I don't seem to be getting the name to show up how ever I try it. Any chance you could get an example within that export script?

stigatle
07-18-2011, 10:27 PM
sorry, my bad, i thought you wanted to avoid the box showing up - and just save to the file directly.
here's how you set the name in the dialog:

TempFilenameOnly = getFilenameFile (maxFilePath + maxFileName)
animfilename = getsavefilename filename:tempFilenameOnly caption:"Save MD5anim" types:"MD5anim (*.md5anim)|*.md5anim"

TechnicallyArtistic
07-18-2011, 10:37 PM
Ah! Awesome. Ok, I see what you were doing before now. I didn't want to replace that whole line because I thought it would affect the window, so I was adding the last line into that string.

Anyway, that worked perfectly. Thanks so much for your help!

TechnicallyArtistic
07-19-2011, 12:29 AM
Ok, been modifying this still and got most of the things I want, but there's one more thing I want to see if I can do.

Is there anything like Tokenize in Max?

I have a max file name that's like pig_Neutral_RunCycle1_4_0611 And all the files end in some serious of numbers like that as some sort of version numbering, or some are like _v3855. But when I export out the animation file I just want pig_Neutral_RunCycle1_4 without the version number on the end. And I don't know that the length of characters is the same at the end of all these files or that even all of them have it.


So it there a way to break it up by the underscores and then string it back together without the version part on the end?

CGTalk Moderation
07-19-2011, 12:29 AM
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.