Notifications
Clear all

[Closed] Strip all usedMaps() paths

Hi Guys,
I try to write a script which will strip and clean all paths in the scene. Including texture, Xref, proxies, HDRI, etc. I can very easy collect all paths in the scene using:

maps_in_scene = usedMaps()
print maps_in_scene
 
"D:\WORK\08 03 20\reflection_city.jpg"
"D:\WORK\08 03 20\city.vrmesh"
"C:\scenes	emp.max"

but is there a way to strip them at once without divide them per classes?
Thank you

19 Replies

Do you specifically want to strip the paths and only have the filenames remaining, or just clear all the paths completely?

Yes I want completly to clean the paths:

"\reflection_city.jpg"
"\city.vrmesh"
"	emp.max" 

You can use either the filenamefrompath method or pathConfig.stripPathToLeaf. Both pretty much do the same thing.

Hi, for bitmaps, you can use:

for m in getClassInstances BitmapTexture do (m.fileName=filenameFromPath m.fileName)

Thanks for reply guys. Thank you Zbuffer. Yes I can do for Textures:

for m in getClassInstances BitmapTexture do 
   	(
   		m.fileName=filenameFromPath m.fileName
   	)

for Vray proxies:

for m in getClassInstances vrayproxy do 
   	(
   		m.fileName=filenameFromPath m.fileName
   	)

But my question is there a sigle class or code for all external resuorces?

nope – although IIRC there’s some bits and pieces to get at external resource paths, there’s no way to relate those back to a reference in 3ds Max in order to change it.

Your best bet is to traverse the entire scene (remember, getClassInstances does -not- actually return all instances of that class; though it will get most) and run over parameters to see if it is a (potential) filename string, then change from there.

Traversing a scene is … frustrating, to say the least. Things like Scene States didn’t particularly make it any easier either

If you -can- get by with getClassInstances and a few choice classes, then that’s the way to go.

Edit: Last tab I opened a few minutes ago has some good reads on the scene traversal stuff: http://forums.cgsociety.org/showthread.php?f=98&t=527443 ; See also Neil Blevins’ scripts, his lib has some traversal functionality that you could make use of.

Use ATSOps, since you have access to all files (input and output) you can handle most of it there. It should also store stuff in various Scene States, environment maps, etc.

fileArray = #()
ATSOps.Refresh()
 ATSOps.GetFiles &fileArray --collect all scene files and paths
 deleteItem fileArray 1 --remove the actual scene file path
 for infile in fileArray.count to 1 by -1 do ( --remove output file paths
 	if ATSOps.IsInputFile fileArray[infile] != true do (
 		deleteItem fileArray infile
 	)
 )
 ATSOps.SelectFiles &fileArray --select files for path stripping
 ATSOps.SetPathOnSelection "" --set path to whatever you want

This should do what you want,
-Eric

Edit: Added ATSOps.Refresh() to force a refresh of the data.

It’s the “should” par that always makes me twitch.

3ds Max 2009, 32-bit. File > Reset


  -- Let's create a sphere and stick a bitmapped material on the thing.
  myObj = Sphere()
  myObj.material = Standard()
  myObj.material.diffusemap = BitmapTexture()
  myObj.material.diffusemap.filename = "c:\	emp\	est.bmp"
  
  -- now let's see what ATSOps says
  fileArray = #()
  ATSOps.GetFiles &fileArray --collect all scene files and paths
  print fileArray
  "glare_streaks_star_camera_filter.tif"
  
  -- Well that's not quite right; we'll ignore the mental ray filter thing.  But turns out that ATSOps only works properly after the file has been saved; or ATS needs to be Refreshed?  The help file only mentions refreshing a dialog, unfortunately.
  saveMaxFile "c:\	emp\	est.max"
  fileArray = #()
  ATSOps.GetFiles &fileArray --collect all scene files and paths
  print fileArray
  [color=Blue]"c:	emp	est.max"
  "glare_streaks_star_camera_filter.tif"
  "c:	emp	est.bmp"
  
  -- Much better.  So now let's change the path of these..
  ATSOps.SelectFiles &fileArray
  ATSOps.SetPathOnSelection "C:\\Documents and Settings\\My Username\\My Documents\\3dsmax\\sceneassets\\"
  [/color]false
  
  -- false?  Whoops.  Perhaps it doesn't like some file in there, but we can't tell which.  Perhaps the max file because it's in use, perhaps the filter thing.  So let's try with just our bitmap.
  
  newArray = #(fileArray[3])
  ATSOps.SelectFiles &newArray
  ATSOps.SetPathOnSelection "C:\\Documents and Settings\\My Username\\My Documents\\3dsmax\\sceneassets\\"
  false
  
  -- still false.  What gives?
  ATSOps.SelectFiles &fileArray
  ATSOps.numFilesSelected()
  [color=Blue]0
  
  -- right-o.
  

[/color]
Probably missing something obvious, but what?

You are missing:

deleteItem fileArray 1 --remove the actual scene file path

Notice that the first entry is the actual scene file path, this can’t be changed, and also disables the ability to set path on any other files. Same thing happens in the dialog if you select the scene at the top of the list. You may also need to call ATSOps.Refresh(), this updates the list.

-- Let's create a sphere and stick a bitmapped material on the thing.
myObj = Sphere()
myObj.material = Standard()
myObj.material.diffusemap = BitmapTexture()
myObj.material.diffusemap.filename = "c:\	emp\	est.bmp"

-- now let's see what ATSOps says
fileArray = #()
ATSOps.Refresh() -- refresh the ATSOps list
ATSOps.GetFiles &fileArray --collect all scene files and paths
print fileArray

1
"c:	emp	est.bmp"

-Eric

Page 1 / 2