View Full Version : Maxsctipt Substrings

03 March 2012, 04:35 PM
I have a function that creates a material and gives the material the same name as the maxFileName, but I'm trying to figure out how to remove the .max extension from the material name. Here's what I have so far:

ext = (findString maxFileName ".max")
matSkin = $.material = standardMaterial name:(maxFileName + ext - 4)

Using -4 isn't getting the job done. I'm not exactly sure how to properly pass the math into the naming instructions so the extension gets truncated off.

03 March 2012, 05:18 PM
You can use "getFilenameFile"

getFilenameFile maxfilename

See "File Name Parsing" in the mxs help file.

03 March 2012, 05:25 PM
Moreover, the "-4" doesn't make sense to mxs, as you're dealing with different types of variables (strings and integers).

There's other ways to do this, more or less... precise and easy.

One example, if you have a string , you could write the same thing using "substring", like :

s = "filename.max"
name = substring s 1 (a.count - 4)

See "String values" in the mxs help file.

03 March 2012, 05:40 PM
Thanks! File name parsing was exactly what I needed to read up on.

CGTalk Moderation
03 March 2012, 05:40 PM
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.