recursive loop
Hi
I'm quite new to scripting and wonder if its possible to write a function that will search through multiple nested vray blend materials.
For example
myBall has a blendMaterial and within this is another BlendMaterial and within this another.
At the moment I can use a for loop to keep goin through each array but this gets messy as the number of blendMaterials increases.
e.g
for i in 1 to ($.material.coatMtl.count) where classof $.material.coatMtl[i] == vrayBlendMtl do
(
for j in 1 to ($.material.coatMtl[i].coatMtl.count) where classof $.material.coatMtl[i].coatMtl[j] == vrayBlendMtl do
(
for h in 1 to ($.material.coatMtl[i].coatMtl[j].coatMtl.count) where classof $.material.coatMtl[i].coatMtl[j].coatMtl[h] == VrayBlendMtl do
"keep goin for all existing nested BlendMaterials"
)
)
I want to be able to search through and access all the vray materials that may populate these slots and for any given number of BlendMaterials that may exist.
if anyone could shed some light or point me in the right direction i'd appreciate it cheers

Comments
getClassInstances x
getClassInstances x
Raphael Steves
Thanks
This is perfect thank you so much :)
Thanks
Hi Garp
yea this seems to be what I need, excuse my lack of knowledge here:)
This gives me access to the an array of all the blends, how can I add all the vrayMtls that might populate the other 8 .coatMtl slots.
The idea here is to be able to find all vrayMtls in a scene no matter how deep in various blendMtl multiSub vray2SidedMtl etc
cheers
Somthing like this?