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 !
Forum topic · General Scripting
By nguyenthanhtung3d · 2016-10-06
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 !
fajar · 2016-10-07
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>

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>

nguyenthanhtung3d · 2016-10-08
Thank u
Swordslayer · 2016-10-06
Or, if you want it to be unique wirecolors: http://stackoverflow.com/questions/8910878/give-each-object-in-scene-a-unique-wirecolor
nguyenthanhtung3d · 2016-10-08
Thank u
.
miauu · 2016-10-06
for o in objects do o.wirecolor = random black white
nguyenthanhtung3d · 2016-10-08
Thank you, it works great and simple