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\temp.max" but is there a way to strip them at once without divide them per classes?
Thank you

erilaz

05 May 2008, 02:12 AM

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

kamel47

05 May 2008, 02:25 AM

Yes I want completly to clean the paths:

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

erilaz

05 May 2008, 02:30 AM

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

Zbuffer

05 May 2008, 06:37 AM

Hi, for bitmaps, you can use:

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

kamel47

05 May 2008, 11:03 AM

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?

ZeBoxx2

05 May 2008, 11:23 AM

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.

PiXeL_MoNKeY

05 May 2008, 04:14 PM

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 wantThis should do what you want,
-Eric

-- 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:\\temp\\test.max"
fileArray = #()
ATSOps.GetFiles &fileArray --collect all scene files and paths
print fileArray
"c:\temp\test.max"
"glare_streaks_star_camera_filter.tif"
"c:\temp\test.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\\"
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.

You are missing:deleteItem fileArray 1 --remove the actual scene file pathNotice 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:\\temp\\test.bmp"

What happened, other than -not- selecting the third item in the original array?
I take it you need the refresh; which the help states refreshes a dialog (which to me would imply it makes sure a GUI element gets updated to reflect the internal state) but I guess would actually mean "make sure the internal state actually -is- what you just told it to be"?

Let's try the original example (with your added refresh) and add some prints and refreshes... I'll give output per line.

Thanks for this code PiXeL_MoNKeY but it really works partially. It does strip the path of the bitmaps and HDRIs but doesn't with proxies, point chashe, xref (it change the path of the first one only)
Please have a look at the print screen of the AT after I run the script. Green - it did. Red - it didn't.
http://www.artray.co.uk/temp_for_forums/assettrack.gif

PiXeL_MoNKeY

05 May 2008, 10:42 PM

Ill look at it later, but the script I posted worked on a file with 180 files, and stripped the path of 178 files (the other being an output path and the actual scene file that is open). When I ran it I had the ATS dialog open, which may be the difference.

-Eric

PiXeL_MoNKeY

05 May 2008, 10:44 PM

kamel47, you may try removing the IsInputFile check. As Richard stated in another thread the file can give a false negative if the file can be an input and output file.

-Eric

Edit: If you literally want everything to have its path stripped try just this one line:ATSOps.SetPath ""

ZeBoxx2

05 May 2008, 11:27 PM

When I ran it I had the ATS dialog open, which may be the difference.

:lightbulb Turns out that it is. So..

ATSOps.visible = true
-- work with the bugger
ATSOps.visible = false

Next up, change the path in one map, but not in another ;)

kamel47

05 May 2008, 11:51 PM

PiXeL_MoNKeY I did try ATSOps.SetPath "" but still I had the same rezolt. Only one of the Xrefs was stripped.

PiXeL_MoNKeY

05 May 2008, 02:22 PM

I have no idea what is going on, kinda hard to diagnose without having a scene that exhibits the problems you are seeing. Did you run the Maxscript commands with the dialog open or closed? Did you also call ATSOps.Refresh() to refresh the list?

-Eric

kamel47

05 May 2008, 03:13 PM

It is very strage. Works fine on my workstation 32 and 64bit, but on laptop or low spec machine dosen't.

PiXeL_MoNKeY

05 May 2008, 04:37 PM

It appears that you need to have the dialog open for some of the maxscript ATSOps commands to work. So try something like:ATSOps.visible = true
ATSOps.Refresh()
ATSOps.SetPath ""
ATSOps.visible = falseNext up, change the path in one map, but not in another ;)That should just be a matter of extracting the paths from the filelist array and running ATSOps.SetPathOnSelection "NewPath" on the desired path(s).

-Eric

ZeBoxx2

05 May 2008, 02:03 AM

That should just be a matter of extracting the paths from the filelist array and running ATSOps.SetPathOnSelection "NewPath" on the desired path(s).

I was just being difficult - and not clear enough at that :)

If you have two maps, both pointing to "c:\temp\test.bmp", and you want to change the path for just one of those two maps, would have been the challenge.
The asset tracker just sees it as a single asset, and you can't get what's actually referencing that asset out of it.

And yes, I know, .RetargetAssets :) That only helps if you already know which MaxObject you want to poke at, though.

CGTalk Moderation

05 May 2008, 02:03 AM

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.

Follow Us On:

The CGSociety

The CGSociety is the most respected and accessible global organization for creative digital artists. The CGS supports artists at every level by offering a range of services to connect, inform, educate and promote digital artists worldwide. More about us on TheArtSociety.com