Announcement

Collapse
No announcement yet.

Script for mats

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

  • Script for mats

    Anyone know of or have a script to change shader types? I need to find all ward shaders in a scene and switch them to blinn or phong. The infamous "red dot" problem.
    "It's the rebels sir....They're here..."

  • #2
    Try the MaterialControl maxscript from the blur scripts collection.

    http://www.neilblevins.com/blurscripts/blurscripts.htm

    Comment


    • #3
      does not seem to work on VRay materials
      "It's the rebels sir....They're here..."

      Comment


      • #4
        Run zis and select all the objects you want changed:

        Code:
        Rollout changeBRDF "Change BRDF"
        (	
        	global brdf = 0
        	
        	radiobuttons brdf_type labels:#("Phong", "Blinn", "Ward")
        	button applyIt "Apply" width:200 align:#right
        	
        	on brdf_type changed state do
        	(
        		global brdf = brdf_type.state as integer - 1
        	)
        	
        	on applyIt pressed do
        	(
        		ObjArray = selection as array
        	
        		for m in 1 to ObjArray.count do
        		(
        			if (classof ObjArray[m].material == VRayMtl) then
        			(
        				ObjArray[m].material.brdf_type = brdf
        			)
        								
        		)
        	)
        )
        	
        createdialog changeBRDF width:300

        Comment


        • #5
          Thanks! getting error though

          -- Type error: CreateDialog requires RolloutClass, got: undefined
          "It's the rebels sir....They're here..."

          Comment


          • #6
            Piss. You on max 9?

            Comment


            • #7
              Yar
              "It's the rebels sir....They're here..."

              Comment


              • #8
                Try this then - select everything and evaluate the code:

                Code:
                      ObjArray = selection as array
                   
                      for m in 1 to ObjArray.count do
                      (
                         if (classof ObjArray[m].material == VRayMtl) then
                         (
                            ObjArray[m].material.brdf_type = 1
                         )
                                        
                      )
                   )
                And for phong:

                Code:
                      ObjArray = selection as array
                   
                      for m in 1 to ObjArray.count do
                      (
                         if (classof ObjArray[m].material == VRayMtl) then
                         (
                            ObjArray[m].material.brdf_type = 0
                         )
                                        
                      )
                   )

                Comment


                • #9
                  this should do the trick..."refs.dependson" is a killer for recursive stuff!

                  Code:
                  clearlistener()
                  
                  fn removeward mat =
                  (
                  local mats = #()
                  local scenemats = refs.dependsOn mat
                  for r in scenemats do    
                  (
                  	if (classof r == vraymtl) then
                              append mats r
                  
                          join mats (removeward r)
                      )
                  	return mats
                  )
                  
                  for t in scenematerials do 
                  
                  
                  
                  mymats = removeward scenematerials
                  for i in mymats do
                  (
                  print i
                  if i.brdf_type == 2 then (i.brdf_type = 1) else()
                  )

                  this script goes everywhere, no matter if your vraymaterial is inside a multimat,blend, whatever and how deep nested.

                  regards,michael
                  This signature is only a temporary solution

                  Comment


                  • #10
                    Code:
                    (
                    Rollout changeBRDF "Change BRDF"
                    (   
                       global brdf = 0
                       
                       radiobuttons brdf_type labels:#("Phong", "Blinn", "Ward")
                       button applyIt "Apply" width:200 align:#right
                       
                       on brdf_type changed state do
                       (
                          global brdf = brdf_type.state as integer - 1
                       )
                       
                       on applyIt pressed do
                       (
                          ObjArray = selection as array
                       
                          for m in 1 to ObjArray.count do
                          (
                             if (classof ObjArray[m].material == VRayMtl) then
                             (
                                ObjArray[m].material.brdf_type = brdf
                             )
                                            
                          )
                       )
                    )
                       
                    createdialog changeBRDF width:300
                    )
                    try this to fix the error with the rolloutcreator
                    (additional wrapping parenthesis)
                    Marc Lorenz
                    ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___
                    www.marclorenz.com
                    www.facebook.com/marclorenzvisualization

                    Comment


                    • #11
                      I'm still using max 8 over here (no reason to install 9 yet) so sorry I couldnt check :/

                      Comment


                      • #12
                        Originally posted by Sushidelic
                        this should do the trick..."refs.dependson" is a killer for recursive stuff!

                        Code:
                        clearlistener()
                        
                        fn removeward mat =
                        (
                        local mats = #()
                        local scenemats = refs.dependsOn mat
                        for r in scenemats do    
                        (
                        	if (classof r == vraymtl) then
                                    append mats r
                        
                                join mats (removeward r)
                            )
                        	return mats
                        )
                        
                        for t in scenematerials do 
                        
                        
                        
                        mymats = removeward scenematerials
                        for i in mymats do
                        (
                        print i
                        if i.brdf_type == 2 then (i.brdf_type = 1) else()
                        )

                        this script goes everywhere, no matter if your vraymaterial is inside a multimat,blend, whatever and how deep nested.

                        regards,michael
                        get the following error, for all of the above so Im not sure
                        if I am executing it incorrectly or error in the script
                        -- Syntax error: at ), expected <factor>
                        -- In line: )
                        "It's the rebels sir....They're here..."

                        Comment


                        • #13
                          oops, looks like i pasted the wrong code...

                          try this again:

                          Code:
                          clearlistener&#40;&#41;
                          
                          fn removeward mat =
                          &#40;
                          local mats = #&#40;&#41;
                          local scenemats = refs.dependsOn mat
                          for r in scenemats do   
                          &#40;
                             if &#40;classof r == vraymtl&#41; then
                                      append mats r
                          
                                  join mats &#40;removeward r&#41;
                              &#41;
                             return mats
                          &#41;
                          
                          mymats = removeward scenematerials
                          for i in mymats do
                          &#40;
                          print i
                          if i.brdf_type == 2 then &#40;i.brdf_type = 1&#41; else&#40;&#41;
                          &#41;
                          This signature is only a temporary solution

                          Comment


                          • #14
                            Sorry guys lost my PSU! Ok this works. Thanks so much.
                            "It's the rebels sir....They're here..."

                            Comment

                            Working...
                            X