I'm trying to put together script that will change phase of noise map for all selceted objects. Anyone can help?
Announcement
Collapse
No announcement yet.
another maxscript help needed :)
Collapse
X
-
Tags: None
-
Code:macroScript randColor category:"lukxScripts" ( ( select $*VrayProxy* ) theMat = sceneMaterials for theMat in selection do ( ranPhase = random 0 200 texmap_diffusePhase = ranPhase ) )
Luke Szeflinski
:: www.lukx.com cgi
-
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 ) ) )
Hope this helps.
GeorgIn Polygongewittern - Industrial Parametrisation of the World
http://www.preset.de/
http://www.count-as-one.net/
Comment
-
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
-
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 errorLuke Szeflinski
:: www.lukx.com cgi
Comment
-
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
-
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 problemLuke Szeflinski
:: www.lukx.com cgi
Comment
-
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. ) ) )
In Polygongewittern - Industrial Parametrisation of the World
http://www.preset.de/
http://www.count-as-one.net/
Comment
Comment