get descendant bitmap of diffuse input

Whats the best way to get the first descendant bitmap of a material's diffuse property?

So for example if the diffuse has bitmap plugged into a color correction node, which in turn is plugged into a mix map, how would I find the bitmap? Would I need to loop through each parameter of each child, and then the childs child and so on?

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jahman's picture

.

getClassInstances bitmapTexture target:$.material.diffusemap

3di's picture

brilliant

That's great, thanks for the info.

here's the usage incase it's useful to anyone. It returns an array of all bitmapTexture maps plugged into the redshift diffuse_color_map parameter.

fn GetTheBitmapsFromTheTree Diff =
(
return getClassInstances bitmapTexture target:Diff
)

--main function

Sel = selection as array
count = 0
for TheGeo in Sel do
if classof TheGeo.material == Multimaterial then
(
--print(“multisub \n”)
for m = 1 to TheGeo.material.numsubs do
(
connectedToMultiMat = TheGeo.material[m]
if classof connectedToMultimat == Subanim do continue
c = classof connectedToMultimat as string

)

)
else(
--gets the full array of maps
--print (ReadAllMaps(TheGeo.Material))

--gets just the specified map

--ListPropsAndValues(TheGeo.Material)
TheBitmaps = #()
TheBitmaps = GetTheBitmapsFromTheTree(TheGeo.Material.diffuse_color_map)
cnt = 0
for bitmap in TheBitmaps do
(
print(bitmap)
cnt = cnt + 1
)
)

Damn you computer.

miauu's picture

.

Two advices:
1- put your code inside
["code"]
-- your code
["/code"].
Do not type the quotes. :)
2- do not use "return" when you want the function to return what it have to return. In maxscript, most of the time, all functions returns the last expression/variable.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.