[Closed] Find material by bitmap name
im not sure if you’ve pasted it wrong, but i can see that you defined your funcion as “scanslots” with an “s”, but you called it inside “Scanslot” recursively without an “s”… that might be the cause of problem.
Hello Galagast
yes i made a wrong paste. i put a good here.
I don’t understand why it doesn’t work. its your code i just change the name. I test your code alone and it work perfectly.
That’s a bit weird. :surprised
fn scanslots mat =
(
-- Search in Blend Material
if matclassid == "#(592, 0)" do
(
Global BlendSubMatCount = try(getnumsubmtls mat) catch(0)
if BlendSubMatCount != 0 do
(
for i in 1 to BlendSubMatCount do
(
global BlendSubMat = getsubmtl mat i
if BlendSubMat != undefined do
(
--print (getsubmtl mat i)
scanslots BlendSubMat
)--end if
)--end for
)--end if
)--end if
)--end fn scanslots
Thanks for your help galagast
OH NOOOOO !!! :surprised :surprised :surprised
I find the way.
In fact, i made a big function with a lot of “if” and in each “if” i recall the “scanslots” function. It seem that a function can only have one recalling to make it recursively.
This is my function:
fn scanslots mat =
(
global matclassid = (mat.classid as string)
-- Search in Standard Material
if matclassid == "#(2, 0)" do
(
global MatSubMaps = getnumsubtexmaps mat
global SimilarMaps = for i = 1 to Matsubmaps where mat.maps[i] != undefined and pathdisp.text == mat.maps[i].filename do
(
append CorrespMats (mat as string)
)--end for
)--end if
-- Search in Raytrace Material
if matclassid == "#(655953908, 849023086)" do
(
global RayMatSubMaps = getnumsubtexmaps mat
global RaySimilarMaps = for i = 1 to RayMatSubMaps where mat.maps[i] != undefined and (mat.maps[i].classid as string) == "#(576, 0)" and pathdisp.text == mat.maps[i].filename do
(
append CorrespMats (mat as string)
)--end for
)--end if
-- Search in Blend Material
if matclassid == "#(592, 0)" do
(
Global BlendSubMatCount = try(getnumsubmtls mat) catch(0)
if BlendSubMatCount != 0 do
(
for i in 1 to BlendSubMatCount do
(
global BlendSubMat = getsubmtl mat i
if BlendSubMat != undefined do
(
--print (getsubmtl mat i)
scanslots BlendSubMat
)--end if
)--end for
)--end if
)--end if
-- Search in MultiSub Material
if matclassid == "#(512, 0)" do
(
Global MultiSubMatCount = try(getnumsubmtls mat) catch(0)
if MultiSubMatCount != 0 do
(
for i in 1 to MultiSubMatCount do
(
global MultiSubMat = getsubmtl mat i
if MultiSubMat != undefined do
(
--print (getsubmtl mat i)
scanslots MultiSubMat
)--end if
)--end for
)--end if
)--end if
)--end fn
If i delete one of the two “scanslots” recall the function works. If i let the two, it makes me an error.
This is a function to scan all slot in a material and if the material is a multimat it scan the slot to find a standard or a raytrace mat. If it find a multimat or a blendmat in the slot, it recall the function to rescan all the slot.
if the user put 50 submultimats the function is able to find it.
But if a can’t put two or more recalling of the function it this one, its a problem for me. Because if in a slot of a multimat, there is a blend mat, the function don’t see it because it search only a multimat.
I know it for after