ScriptSpot

Forum topic · General Scripting

Collect Images in material

By JokerMartini · 2011-11-14

Description

Is there an easy way to collect all the images used within a material?

for example:

source_mtl=meditMaterials[1]
- diffuse = image.jpeg
- bump = image2.png
- opacity = images5.png

Comments (7)

delete

JokerMartini · 2011-11-15

is there a way I can delete it?


bitmapsArr = getClassInstances BitmapTexture asTrackViewPick:on

for tx in bitmapsArr where doesFileExist tx.anim.filename != true do
(
--delete tx since the image is invalid
)

Anubis · 2011-11-15

here is a function posted by Denis.

fajar · 2011-11-14

anubis : are you bobo in 2011, many usefull post posted by you ....im gratefull for that.

thanks anubis.

thanks for the nice words!

Anubis · 2011-11-14

haha, many thanks! but bobo is titan and i think i not yet deserve so high praise :)

JokerMartini · 2011-11-14

Thank you Anubis for the quick response. I'm working on a easier way of duplicating a shader and swatching out images randomly from a desired folder.

Thanks

mjbg · 2011-11-14

havent tryied this much but this should do it


source_mtl = meditMaterials[1]
arrayImages = #()

for o in 1 to (getNumSubTexmaps source_mtl) do
(
	if classof (getSubTexmap source_mtl o) == Bitmaptexture do
	append arrayImages ((getSubTexmapSlotName (source_mtl) o)+" = "+((getSubTexmap source_mtl o).filename))
)

getClassInstances

Anubis · 2011-11-14

mat = meditMaterials[1]
btxs = getClassInstances BitmapTexture target:mat asTrackViewPick:on
imgs = for tx in btxs where doesFileExist tx.anim.filename collect tx.anim.filename

you can check this topic as well.