Announcement

Collapse
No announcement yet.

Maxscript help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Maxscript help

    Hi all,

    Does anyone know how to set all materials for an object to have the same materialID?

    I've been using $.material.effectsChannel = 5 etc, but this only works on single materials, not multi/subs.


    Thanks for any pointers!


  • #2
    This seems to work and sets the MultiSub and its child materials to effectID 7

    Code:
                for MatID in selection do 
                (
    
                    if classof MatID.material == MultiMaterial then
                    (
                        MatID.material.effectsChannel = 7
                            for MatNum = 1 to MatID.material.materialList.count do 
                                MatID.material.materialList[MatNum].effectsChannel = 7
                    )    
                )

    But throws up this error in the listener (which breaks the script after it has run)

    Code:
    -- Error occurred in anonymous codeblock; filename: ; position: 248; line: 8
    -- Unknown property: "effectsChannel" in undefined

    If I change out the MatID.material.materialList[MatNum] to read as the actual material number ie: [5], then I don't get the error.

    Any ideas?

    Comment


    • #3
      This should set the effects channel for materials and multimaterials:

      Code:
      fn setMaterialChannel m c = (
          if m != undefined do m.effectsChannel = c
          if classOf m == MultiMaterial do (
              for s in m.materialList do setMaterialChannel s c
          )
      )
      
      for o in selection do (
          setMaterialChannel o.material 5
      )

      Comment

      Working...
      X