Notifications
Clear all

[Closed] Maxsctipt Substrings

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.

3 Replies

You can use “getFilenameFile”


getFilenameFile maxfilename

See “File Name Parsing” in the mxs help file.

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.

Thanks! File name parsing was exactly what I needed to read up on.