[Closed] Get texture absolute path?
How to get texture absolute path like what we see in summary info?
The filename in bitmap info isn’t correct
This might be helpful:
http://docs.autodesk.com/3DSMAX/16/ENU/MAXScript-Help//index.html?query=atsops
<bool>[i]ATSOps.ResolveSelectionToAbsolute/i Converts the paths of one or more assets selected in the Asset Tracker dialog to absolute paths. At least one of the selected assets must have a relative path.
If the asset is [i]found[/i] (meaning that it is found in the search path), then the absolute path will point to the found location. If not, then the relative path is converted to an absolute path relativeto the current Project Folder setting.
Returns true if one or more assets have been resolved to absolute paths.
Available in [i]3ds Max 9[/i] and higher.
I’ve never used this before – but it doesn’t appear to work for custom shaders. And it converts relative paths to oddly formed absolute paths for standard materials: (Max 2014sp5)
$.material.diffusemap.filename
> “… est.tga
($.material.diffusemap.filename as AssetUser).getFullFilePath()
>“d:\exper extures\a\b… est.tga”
Could you provide an example please? It should work with all strings.
Yep that’s the way the internal c++ class handles paths. One could use the pathConfig.normalizePath function to normalize the returned path.
the previous post should give you the full path also but it looks like you using the default max project?
If you are or you are managing the project that you are currently using you could use
pathConfig.getCurrentProjectFolder() + "\\" + $.material.diffusemap.filename
This isn’t reliable because the texture could also be in the #Images folder, or any of the External Files directories defined in Configure User Paths.
This function searches all of those directories.
mapPaths.getFullFilePath $.material.diffusemap.filename
+1 to using ATSOPs interface for path wrangling.
Not because it’s the simplest to use
but because it seems to be the most effective approach
At least in my experience
I found that these one is good
- ($.material.diffusemap.filename as AssetUser).getFullFilePath()
- mapPaths.getFullFilePath $.material.diffusemap.filename
I also found this one is good too
pathConfig.convertPathToAbsolute $.material.diffusemap.filename
I think pathConfig look like the best one, there’s all thing relate to path/filename
http://docs.autodesk.com/3DSMAX/16/ENU/MAXScript-Help/index.html?url=files/GUID-7F26EC19-6C56-4580-B6C3-C51ACC8E4356.htm,topicNumber=d30e709842
This one ATSOps.ResolveSelectionToAbsolute(), I don’t know how to use
Anyway, thanks all!
It’s ok for 1 texture now
But how to convert all texture in scene to absolute path?
I don’t know how to collect all texture
getClassInstances BitmapTex
That might work for scene textures.
But if you have other images not used in the viewport you’ll want to check out EnumerateFiles or ATSOps.
I had the same issue of the full paths in ATSOps been shown as a relative path and I wanted to edit the selected bitmap nodes in SME and came across this post to get the right full normalized filepath.
To resolve bitmap paths to get the full normalized filepath you can use the following.
N.B: The Assest manager needs to be open for it to work so this script will open and close it if neccesary.
--RESOLVE PATHS
fn resovlepaths =
(
ATSOps.ExcludeOutputFiles = true
actionMan.executeAction -841213575 "2" -- Asset Tracking System: Highlight Editable Assets
actionMan.executeAction -841213575 "16" -- Asset Tracking System: Make Path Relative to Project Folder
actionMan.executeAction -841213575 "2" -- Asset Tracking System: Highlight Editable Assets
actionMan.executeAction -841213575 "17" -- Asset Tracking System: Make Path Absolute
ATSOps.ClearSelection()
atsops.refresh()
gc()
)
fn closeOpenATSops =
(
if ATSOps.Visible == false then
(
ATSOps.Visible = true
resovlepaths()
ATSOps.Visible = false
print "Resolved Paths Done"
)
else
(
resovlepaths()
print "Resolved Paths Done"
)
)
closeOpenATSops()
But to bypass this and get the full normalized filepath you require wheather they’re absolute or relative this code snippet should get you going.
MaxBitmaps = for i in getClassInstances BitmapTex collect i
MaxBitmapsFilenames = for m in MaxBitmaps where doesFileExist ((m.filename as AssetUser).GetFullFilePath()) == true collect pathConfig.normalizePath ((m.filename as AssetUser).GetFullFilePath())
Google all those keywords such as doesFileExist, AssetUser, GetFullFilePath() & pathConfig.normalizePath to see more about them. MXS is like a puzzle sometimes