[Closed] Retarget un-common root
I’ve got a bit of a problem which can be fixed with Maxscript however I could do with a few pointers to get me started.
The problem is that I have a library of .max scenes of 3d objects with maps. The maps are replicated in a few places and I’m going to consolidate everything as it’s starting to get out of hand :shrug:
for example; the map concrete.jpg could be in any of the following locations;
\mapserver\maps\concrete\concrete1.jpg
\fileserve1\maps\concrete\concrete1.jpg
\fileserve1\resources\maps\concrete\concrete1.jpg
M:\concrete\concrete1.jpg
note: there is a chance that not all the maps still exist in their original locations (therefore a resolve to unc path for these would not be possible). Also this is only for maps, the .max scenes won’t contain other external files such as pointcache, xrefs etc.
So basically what I’d like some help with is how to strip the last part – the common section of the path (…\concrete\concrete1.jpg) – and replace the start so all of the paths read as;
\md3000\concrete\concrete1.jpg
Can anyone offer any advice on how to go about this in maxscript? I’ve had a dig around these forums and found many path replacement script snippets but they generally all rely on repathing the common root (these files don’t have a common root!) or they rely on all of the map paths being the same location.
Cheers,
Rob
Well, what you want to do is just STRIP the complete path from ALL your maps.
If these maps are located in ANY of the Map Paths defined in the Customize>Configure User Paths dialog, Max will add the common root automatically based on wherever it found the map.
In fact, you you do a consolidation of your maps and put them all in the same place, then delete the old directoreis, set the new common path in the Customize… paths dialog so Max can “see” it and open your file, it will automatically repath all maps without even asking and with no scripts at all…
Hi Bobo,
Whilst the method you have suggested is correct, for my case this would not be appropriate.
These 3d scenes are our 3d furniture/resources library and there are a few thousand objects (with each object having many maps) each in individual scenes which we merge in to the shots as needed.
I’d have to add the new bitmap maps location folder and all of its subfolders (at least few hundred) as custom paths in Max across many computers and things would slow down a lot when max started searching for these missing files. Since we might be merging many 3d assets into each shot, I think it would be better to have hard coded paths for the bitmaps in this case (it also means that our asset tracking system would work properly!).
I’ve already devised an automated system for recursively opening all of these max files and running a maxscript, I just need the script!
I was hoping that I might be able to do a regular expression substring analysis to determine where the map was originally located, then use a series of switchs / if statements to then replace the first X number of characters depending on the original location. Since I know that there will only be maybe 3 or 4 locations that the files would be coming from, this wouldn’t be too much of a chore.
I’m not that familiar with the maxscript syntax/functions so I’m not sure if the above is possible… what do you think?
Many thanks,
Rob
just have a look at the File Name Parsing and pathconfig struct help topics… searching for getFilenameFile and pathconfig respectively
Look upi the ATSOps Interface, it should give you access to what you need. One note on the ATSOps.GetFiles the first file will always be the loaded 3ds Max scene (if it has been opened or saved). So you will need to remove the first item from the FileList array otherwise your repathing will fail since you can’t repath the current scene file. Example, this code will repath all files, excluding the current max scene, to whatever you set in the ATSOps.SetPath line:
fileArray = #()
ATSOps.getFiles &fileArray
deleteItem fileArray 1
ATSOps.SelectFiles &fileArray
ATSOps.setpath “<path for selected files>”
-Eric