VERY SIMPLE SCRIPT! HELP!!!

Hi everyone, I absolutely need a script that loops all the texture maps in the scene and make the bitmap file path relative. This is a simple script and I'm a total noob in MAXScript. Cuz I don't know anything about MAXscript and since the language is awfully documented, I've tried for several hours but I can't learn the language. I always get some kind of totally undescriptive errors.

In a normal programming language, that would be something like:

For Each map In SceneMaps
s1 = map.filename
's1 would be for example: "C:\Users\zxcvdxa\project1\Textures\Texture1.jpg"
'Replace the string and make it relative
s1 = s1.Replace("C:\Users\zxcvdxa\Textures", "..\Textures")
map.filename = s1
Next

Simple as that! I want to publish my model and make the path relatives. How do I translate this for MAX?.

Thanks for any help.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Marco Brunetta's picture

I wouldn't say the language

I wouldn't say the language is awfully documented...
However, it would start by looking at the pathconfig struct (if you need more info just look in the help file):

"The PathConfig struct provides methods to access and manage Project paths, System paths, manipulate paths and convert between UNC, absolute and relative paths and so on."

In your case you probably want to use:

"pathConfig.convertPathToRelativeTo <path1>
<path2>
Converts the first path argument to a relative path with respect to the second path argument."

 

Besided that you might want to check out the sceneMaterials system global. Keep in mind it is a bit quirky

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.