Announcement

Collapse
No announcement yet.

another maxscript help needed :)

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

  • another maxscript help needed :)

    I'm trying to put together script that will change phase of noise map for all selceted objects. Anyone can help?
    Luke Szeflinski
    :: www.lukx.com cgi

  • #2
    Code:
    macroScript randColor
    	category:"lukxScripts"
    (
    (
    	select $*VrayProxy*
    )
    	theMat = sceneMaterials
    	for theMat in selection do
    	(
    	ranPhase = random 0 200
    	texmap_diffusePhase = ranPhase
    	)
    	)
    I tried this, got OK after eval but it doesn't do antything. Phase doesn't change. I'm totaly noob form maxsript.
    Luke Szeflinski
    :: www.lukx.com cgi

    Comment


    • #3
      Hi Lukx


      This is just a quick hack for your problem.

      The first script assumes that all selected objects have their *own* material. The second script copies the material of the first object in the selection and assigns a uniquecopy to the other objects in the scene.

      Code:
      macroScript randColor_1
      	category:"rdg::preset"
      	toolTip:"randomize VRay diffuse noise phase [1]"
      	buttonText:"randDiffPhase 1"
      ( 
      	(
      		theSel= selection as array
      		for i = 1 to theSel.count do (
      			ranPhase = random 0. 360.
      			theSel[i].material.texmap_diffuse.phase = ranPhase
      		)
      	)
      )
      Code:
      macroScript randColor_2
      	category:"rdg::preset"
      	toolTip:"randomize VRay diffuse noise phase [2]"
      	buttonText:"randDiffPhase 2"
      ( 
      	(
      		theSel= selection as array
      		theBaseMat = theSel[1].material
      		for i = 1 to theSel.count do (
      			ranPhase = random 0. 360.
      			newMat = copy theBaseMat
      			newMat.texmap_diffuse.phase = ranPhase
      			theSel[i].material = newMat 
      		)
      	)
      )
      Depending on you pipeline there are many improvements possible and/or necessary.

      Hope this helps.

      Georg
      In Polygongewittern - Industrial Parametrisation of the World
      http://www.preset.de/
      http://www.count-as-one.net/

      Comment


      • #4
        Thank you, tahnk you , thank you .
        First one is perfect
        Damn I wish I knew what to look for in maxscript helpfile to know hwo to do such things .
        Luke Szeflinski
        :: www.lukx.com cgi

        Comment


        • #5
          ah...and what I would have to do to make it work when I got multisub material and not all the mats in it have noise map? plus in one noise map there are two more noise maps for black and white? RIgth now when rrunig the script I got error
          Luke Szeflinski
          :: www.lukx.com cgi

          Comment


          • #6
            Depending on you pipeline there are many improvements possible and/or necessary.


            some if-else and/or refs.dependents might help.


            we need to check first what type of material it is.
            if it is a multi/sub we need to iterate through the materials.
            this would give us one material at a time.
            refs.dependents returns a list of all instances of noise maps in this material.
            iterating through this array allows us to randomize all noise phases.

            Later I can take a look at this.
            In Polygongewittern - Industrial Parametrisation of the World
            http://www.preset.de/
            http://www.count-as-one.net/

            Comment


            • #7
              Code:
              macroScript randColor
              	category:"lukxScripts"
              (
              (
              	select $*VrayProxy*
              	theSel= selection as array
              	for i = 1 to theSel.count do (
              	   ranPhase = random 0. 360.
              	   theSel[i].material.texmap_diffuse.phase = ranPhase
              	   theSel[i].material.texmap_diffuse.map1.phase = ranPhase
              	   theSel[i].material.texmap_diffuse.map2.phase = ranPhase
              	)
                )
              )

              i tried this but still same problem
              Luke Szeflinski
              :: www.lukx.com cgi

              Comment


              • #8
                Code:
                theNoises = getclassinstances Noise
                
                for i in theNoises do ( ... )
                This will store all the noise maps in the scene - wherever they sit - within an array.
                Then you can loop through them and change phase.

                Lele

                Comment


                • #9
                  the getclassinstances approach is smart.

                  but do you happen to know how to test if on of the noises is attached to a diffusemap?

                  also this gives you all the noise, not just the noise in the selected objects.


                  here is a remix of the sloft referenceArticle:
                  http://www.sloft.com/2005/11/26/maxscript-references/


                  Code:
                  macroScript randColor_3
                  	category:"rdg::preset"
                  	toolTip:"randomize noise phase [3]"
                  	buttonText:"randPhase 3"
                  (
                  	(
                  		fn getNoiseTextures ref = (
                  		    local bitmapList = #()
                  		    local refList = refs.dependsOn ref
                  		    for r in refList do (
                  				if classof r == noise then (
                  					append bitmapList r
                  				)
                  				join bitmapList (getNoiseTextures r)
                  				
                  			)
                  			return bitmapList
                  		)
                  		
                  		allTheNoise = #()
                  		theSel = selection as array
                  		
                  		for i = 1 to theSel.count do (
                  			tempNoise = getNoiseTextures theSel[i].material
                  			for i in tempNoise do (
                  				append allTheNoise i
                  			)
                  		)
                  		
                  		for t in allTheNoise do (
                  			t.phase = random 0. 360.
                  		)
                  	)
                  )
                  This changes all the noises in the selected materials - not just diffuse noise. I guess you need to traverse the materials with another custom function to get only the noise in defined material slots ...
                  In Polygongewittern - Industrial Parametrisation of the World
                  http://www.preset.de/
                  http://www.count-as-one.net/

                  Comment


                  • #10
                    I think there's a random noise script in the Blur Script Pack

                    Comment

                    Working...
                    X