Python: apply material from materiallibrary to node

Python: apply material from materiallibrary to node

danielkenobi3d
Explorer Explorer
365 Views
0 Replies
Message 1 of 1

Python: apply material from materiallibrary to node

danielkenobi3d
Explorer
Explorer

So here is the thing. I am trying to set up a value of undefined,

Just a simple test with materials.

I run the following code


Code:
import MaxPlus
selection = MaxPlus.SelectionManager.Nodes
for i in selection:
    g = i.Material
    print g




if the object has a material will print

Animatable(VRayMtl)

if the object doesn´t have a material will print None

but if I try to run the following code (when the object has a material).
I will run in the following error

Code:
import MaxPlus
selection = MaxPlus.SelectionManager.Nodes
for i in selection:
    i.Material = None


>> MAXScript MacroScript Error Exception:
-- Runtime error: Line 6487 SetMaterial()
<type 'exceptions.ValueError'> invalid null reference in method 'INode_SetMaterial', argument 2 of type 'Autodesk::Max::Mtl' <<


So the question is how come the value of the material is None when it doesn't have the material assigned, but if i try to assign this value directly I get an error. what am I missing? any help here will be appreciated.

 

0 Likes
366 Views
0 Replies
Replies (0)