MaxScript to collect all VRay materials in the scene

时间:2017-05-03 14:29:16

标签: 3dsmax maxscript

Hello this is my first script ever. I am trying to write a script that will get all VRay materials in the scene into an array, after that I want to pull them trough for loop and attach each vray material to a slot in Multi/Sub-Object. And then output of multi/sub object connect to VRayMtlWrapper and keep the old multisub object as sub material.

I can do that in graph but it takes to long with double digits amount of materials.

I've scraped some scripts and read maxscript help to find what I need but with no luck.

Atm I know to collect materials in the scene

materials = for m in scenematerials collect m;

but after that i dont know how to write so that i can access their outputs/inputs or attributes and connect them with a multi sub object. I have developed the logic in my head but dont know how to write the syntax to realise it. Any info, directions, links would be appreciated.

Here's even an image of what im trying to do with a script automaticaly example

1 个答案:

答案 0 :(得分:0)

我找到了解决方案。 如果你想只接受vray你只需写:

matVray = for m in scenematerials m.category == #vray collect m;

如果您只想拾取vray库中的素材,只需添加

即可
matVray = for m in scenematerials m.category == #vray and superclassof m == material collect m

要将数组中的材质放入多子对象,请将其:

multiSub = Multimaterial numsubs:matVray.count
multiSub.materiallist = matVray

最后一部分将multisub连接到vray包装器:

vrayWrapper = VRayMtlWrapper baseMtl:multiSub