ScriptSpot is a diverse online community of artists and developers who come together to find and share scripts that empower their creativity with 3ds Max. Our users come from all parts of the world and work in everything from visual effects to gaming, architecture, students or hobbyists.
Submitted by nguyenthanhtung3d on Thu, 2016-10-06 00:36
Hi all
I'm looking for a script that can assign random wirecolor to each object in the scene in order to create a good wirecolor passes. Any clue ? Please help me out
Thanks in advance !
</p><p>sel = selection as array<br>clearSelection()<br>t=timestamp()<br>h=heapFree<br>rdm=random <br>for o in sel do o.wirecolor = rdm black white<br>select sel<br>format "Done it in :% | RAM : %\n"((timeStamp()-t)/1000.)(heapfree - h)</p><p>--Done it in :0.059 | RAM : -4616L</p><p>
swordslayer
</p><p>fn shuffle &arr =<br>(<br> local temp, swapIndex, counter = arr.count + 1<br> while counter > 1 do<br> (<br> swapIndex = random 1 (counter -= 1)<br> temp = arr[counter]<br> arr[counter] = arr[swapIndex]<br> arr[swapIndex] = temp<br> )<br> OK<br>)<br><br>fn incrementCounters &r &g &b step =<br>(<br> if(b += step)> 256 do<br> (<br> b = 1<br> if(g += step)> 256 do<br> (<br> g = 1<br> if(r += step)> 256 do r = 1<br> )<br> )<br>)<br><br>fn assignRandomWirecolor objs simple:true =<br>(<br> local stepCount = objs.count^(double 1/3) + 1<br> local step = 255./stepCount<br> local redArr = #(0) + #{1..255}<br> local greenArr = copy redArr #noMap<br> local blueArr = copy redArr #noMap<br> local r = local g = local b = 1<br><br> if simple then<br> (<br> shuffle &redArr<br> shuffle &greenArr<br> shuffle &blueArr<br> )<br> else shuffle &sel -- slower with many objects<br><br> for obj in objs do<br> (<br> obj.wirecolor = [redArr[int(r)], greenArr[int(g)], blueArr[int(b)]]<br> incrementCounters &r &g &b step<br> )<br>)<br><br><br>sel = selection as array<br>clearSelection()<br>t=timestamp()<br>h=heapFree<br>assignRandomWirecolor sel --simple:false --> if simple is not so cool, try the other option<br>select sel<br>format "Done it in :% | RAM : %\n" ((timeStamp()-t)/1000.) (heapfree - h)</p><p>--Done it in :0.064 | RAM : -20432L</p><p>
Comments
miauu simple one liner in 242
miauu simple one liner in 242 objects....
swordslayer
Thank u
Thank u
Or, if you want it to be unique wirecolors: http://stackoverflow.com/questions/8910878/give-each-object-in-scene-a-unique-wirecolor
Some of my scripts and MCGs :: 3ds Max SDK Intro for Scripters
Thank u
Thank u
.
Tools and Scripts for Autodesk 3dsMax
Thank you, it works great and
Thank you, it works great and simple