Notifications
Clear all

[Closed] How to determine which material slot a texture is attached to?

How to determine which material slot a texture is attached to?
Something like:

vbm = getclassinstances VrayBitmap

for i in vbm do
(
if i connected to Vraymat.texmap_diffuse then ()
else ()
)

Thanks in advance

6 Replies

use refs.dependents to get all dependents of a particular texturemap, then iterate over depenent’s properties to know which one is the one, but keep in mind that there could be multiple props assigned this texturemap

for dep in refs.dependents my_texmap collect
(
    #( dep, for prop in getPropNames dep where (getProperty dep prop) == my_texmap collect prop )
)

this should return an array of dependents and thier props that have this texmap assigned

didn’t understand how i can use it

You wanted slot i.e. property name that uses the texmap. This is how you can find which props use the map. Pretty straightforward

Blockquote[quote=“miauu, post:5, topic:2068502, full:true”]
Download and check this script: http://www.scriptspot.com/3ds-max/scripts/bitmap-list-net

No it’s too complicate for me, did not master.
I made it easier for myself, but dumber and a lot of code.

By the way, the script at the link is great, but does not work with VrayBitmap

fn findTextureSubAnims txt =
(
	cls = classof txt
	deps = getclassinstances cls astrackviewpick:on
	for t in deps where t.anim == txt collect #(refs.dependents t.client immediateOnly:on, t.client, getsubanim t.client t.subnum)
)

delete objects
sc_tx = Stucco()
ch_tx = Checker()

b = box material:(MultiMaterial name:#multi_test numsubs:6)
b.mat[1] = Standard name:#multi_1 diffusemap:sc_tx
b.mat[2] = Standard name:#multi_2 opacitymap:sc_tx diffusemap:ch_tx

m = meditmaterials[2] = Blend name:#blend_test 
m.map1 = Standard name:#blend_1 diffusemap:ch_tx
m.map2 = Standard name:#blend_2 specularmap:sc_tx

scs = findTextureSubAnims sc_tx
chs = findTextureSubAnims ch_tx