Assign random wirecolor to object

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 !

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
fajar's picture

miauu simple one liner in 242

miauu simple one liner in 242 objects....

</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>

miauu

swordslayer


</p>
<p>fn shuffle &amp;arr =<br>(<br>&nbsp;&nbsp;&nbsp; local temp, swapIndex, counter = arr.count + 1<br>&nbsp;&nbsp;&nbsp; while counter &gt; 1 do<br>&nbsp;&nbsp;&nbsp; (<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; swapIndex = random 1 (counter -= 1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; temp = arr[counter]<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; arr[counter] = arr[swapIndex]<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; arr[swapIndex] = temp<br>&nbsp;&nbsp;&nbsp; )<br>&nbsp;&nbsp;&nbsp; OK<br>)<br><br>fn incrementCounters &amp;r &amp;g &amp;b step =<br>(<br>&nbsp;&nbsp;&nbsp; if (b += step) &gt; 256 do<br>&nbsp;&nbsp;&nbsp; (<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b = 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (g += step) &gt; 256 do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; g = 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (r += step) &gt; 256 do r = 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br>&nbsp;&nbsp;&nbsp; )<br>)<br><br>fn assignRandomWirecolor objs simple:true =<br>(<br>&nbsp;&nbsp;&nbsp; local stepCount = objs.count^(double 1/3) + 1<br>&nbsp;&nbsp;&nbsp; local step = 255./stepCount<br>&nbsp;&nbsp;&nbsp; local redArr = #(0) + #{1..255}<br>&nbsp;&nbsp;&nbsp; local greenArr = copy redArr #noMap<br>&nbsp;&nbsp;&nbsp; local blueArr = copy redArr #noMap<br>&nbsp;&nbsp;&nbsp; local r = local g = local b = 1<br><br>&nbsp;&nbsp;&nbsp; if simple then<br>&nbsp;&nbsp;&nbsp; (<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; shuffle &amp;redArr<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; shuffle &amp;greenArr<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; shuffle &amp;blueArr<br>&nbsp;&nbsp;&nbsp; )<br>&nbsp;&nbsp;&nbsp; else shuffle &amp;sel -- slower with many objects<br><br>&nbsp;&nbsp;&nbsp; for obj in objs do<br>&nbsp;&nbsp;&nbsp; (<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; obj.wirecolor = [redArr[int(r)], greenArr[int(g)], blueArr[int(b)]]<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; incrementCounters &amp;r &amp;g &amp;b step<br>&nbsp;&nbsp;&nbsp; )<br>)<br><br><br>sel = selection as array<br>clearSelection()<br>t=timestamp()<br>h=heapFree<br>assignRandomWirecolor sel --simple:false --&gt; 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>

nguyenthanhtung3d's picture

Thank u

Thank u

Swordslayer's picture

 

Or, if you want it to be unique wirecolors: http://stackoverflow.com/questions/8910878/give-each-object-in-scene-a-unique-wirecolor

Recent rants and code snippets:
http://creativescratchpad.blogspot.com/

nguyenthanhtung3d's picture

Thank u

Thank u

miauu's picture

.

for o in objects do o.wirecolor = random black white
nguyenthanhtung3d's picture

Thank you, it works great and

Thank you, it works great and simple

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.