EDIT (2014-07-11): Antomor replied with a version reduced to just 2 lines. This will give you a string array of file paths rather than the actual bitmap instances, though. Use Anubis' getClassInstances version below for bitmapTexture instances.
for obj in selection do join ff (usedMaps obj)
ff = makeUniqueArray ff
print ff
============================
EDIT (2011-12-20): As Anubis pointed out there is a much much better way to do this. Really to the point where there isn't any reason to make a function for it, but here is a better version anyway:
(
fn GetBitmapTextures theObjects =
(
texMaps = #()
for obj in theObjects do
(
join texMaps (getClassInstances bitmapTexture target:obj asTrackViewPick:off)
)
makeUniqueArray texMaps
)
texMaps = (GetBitmapTextures selection)
for texMap in texMaps do print (texMap.filename)
OK
)
============================
ORIGINAL:
-- DON'T USE THIS. Keeping for search keywords.
Hey all,
I wrote a quick function for getting all the textures associated with an object. It seems like something a lot of other people might also need so thought I'd post it up. I've seen a couple similar functions out there, but non of them really seem to take into account either MultiMaterials, or maps that might contain submaps (like normal maps).
Thanks to the-generalist.com for posting this resource, which didn't do what I wanted, but still was a great starting point.
Just do GetBitmapTextures [object] and it will return an array of bitmapTexture maps. From there you can get/set any of the properties.. like returnedArray[1].filename for instance.
-- DON'T USE THIS. Keeping for search keywords.
fn GetBitmapTextures theObjects =
(
-- Because some submaps can also contain submaps we have to collect materials first, and then still append subMapContainers in the loop bitmapTextureMaps loop
subMapContainers = #()
for obj in theObjects do
(
if obj.material != undefined then
(
submatcount = getNumSubMtls obj.material
for i in 1 to submatcount do
(
append subMapContainers (getSubMtl obj.material i)
)
append subMapContainers (obj.material)
)
)
bitmapTextureMaps = #()
for subMapContainer in subMapContainers do
(
subtexcount = getNumSubTexmaps subMapContainer
for i in 1 to subtexcount do
(
theSubTexMap = (getSubTexMap subMapContainer i)
if theSubTexMap != undefined then
(
if (getNumSubTexmaps theSubTexMap) > 0 then
(
append subMapContainers theSubTexMap
)
else if classof theSubTexMap == bitmapTexture then
(
append bitmapTextureMaps theSubTexMap
)
)
)
)
makeUniqueArray bitmapTextureMaps
)
texmaps = (GetBitmapTextures selection)
for texmap in texmaps do print (texmap.filename)
By MattOstgard · 2011-12-20
antomor · 2014-07-11
barigazy · 2014-09-04
Anubis · 2011-12-21