Notifications
Clear all

[Closed] Why doesn't this work?

Simpliflied example…

fn thefunction m = 
(
Replaceinstances m (VrayMtl())
m.texmap_opacity = checker

)

thefunction scenematerials[1]

Error:

thefunction()
-- Error occurred in thefunction()
--  Frame:
--   m: Standardmaterial:Standard
-- Unknown property: "texmap_opacity" in Standardmaterial:Standard
OK

I’ve replaced my standard material with a Vray material in the function but on the next line it thinks the material is still a Standardmaterial when infact it’s a Vray mat.

Confused…

5 Replies
 lo1

shouldn’t it be

replaceInstances (classof m) (Vraymtl())

?

Nope, it’s because m is changing classes whilst within the function, and later in the function it’s still being called from the initial declaration…

“texmap_opacity” is not a property of a standard material, that’s causing the error, seems to be a problem with the replaceinstances() function.
edit: sorry, I went too fast, I just got your question, Ill take a look

ok, I’ve found a workaround:
seems that m keeps the old value after the replaceinstances() function, even if the material passed has changed but the argument passed on replaceinstances is the variable you want to change.
I’ve tried this, and it works:


fn thefunction m = 
(
vm = VrayMtl()
Replaceinstances m vm
vm.texmap_opacity = checker

)

my english is kinda crappy, sorry about that

cheers,

Thanks Lutteral, Seems like that’s the best way to work it, meant I had to adjust the rest of my code accordingly but it has worked. Cheers