PDA

View Full Version : Random Selction


Gabba
12-06-2009, 07:13 PM
Hi guys! I'm looking for a script, addon or plug-in that can do a random polygon selction.
I searched but with no luck. I've found PolygonRandomSelection 2.0 info but don't know how to get it, it seems to be disappeared from the web.
Thanks to all!

PiotrekM
12-06-2009, 10:29 PM
heres a quick script


#random poly selection

import win32com.client
from win32com.client import constants as c
import math
import sys
import random

#vars
app = Application
log = Application.LogMessage
oSel = Application.Selection

#collect selected objects
Application.ActivateObjectSelTool("")
sellist = XSIFactory.CreateObject( "XSI.Collection" )

for i in oSel:
sellist.add(i)

if sellist.count !=0:
for sel in sellist:
if sel.Type == "polymsh":

apolylist = []
Application.SelectObj(sel)
log(sel)

#get number of polygons in object

NofPolys = sel.ActivePrimitive.Geometry.Polygons.Count

polyscount = random.randrange(0,NofPolys,1)

for i in range(polyscount):
apolylist.append(random.randrange(0,NofPolys,1))

#remove duplicates (convert to set and back to list)
apolylist = list(set(apolylist))

##select random polygons
#Application.SetSelFilter("Polygon")
if apolylist.count != 0:
Application.SelectGeometryComponents(str(sel.FullName)+".poly" +str(apolylist) )

else:
log(str(sel.FullName)+ " has to be a poly mesh.")
Application.SelectObj(sellist)
Application.SetSelFilter("Polygon")
else:
log("Select some objects.")

Gabba
12-07-2009, 07:36 AM
I'll give it a try!!!
Thank you very very much! =)

CGTalk Moderation
12-07-2009, 07:36 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.