PDA

View Full Version : Select/deselect random objects?


Pongo
05-28-2008, 10:59 PM
Hello,

I'm hoping someone can help me out with a simple script. I've done a few searches and have not found anything by itself that will do this. I found a few that were parts of script sets, but I would like to not have to install a bunch of things for this simple task.

Simply put, I need to select or deselect a number of objects in my scene. That's it!

The script could either work from the current selection, and remove random objects, or it could randomly select objects from the scene. Either method will work for me.

Unfortunately I do so little scripting, I have a hard time with the syntax of things. I hope I'm not asking too much here.

Thanks

MarcoBrunetta
05-28-2008, 11:13 PM
Perhaps something along the lines of:

FOR object in selection DO
(
local selectVar = random 0 1
IF selectVar == 0 DO
(
deselect object
)
)

davestewart
05-28-2008, 11:19 PM
A few to get you started:

Changing "every" will randomly select every X objects.


From the current selection, replacing the current selection: every = 2
select (for obj in getCurrentSelection() where random 1 every == every collect obj)



From all objects, replacing the current selection: every = 2
select (for obj in objects where random 1 every == every collect obj)



From all visible objects, replacing the current selection: every = 2
select (for obj in objects where random 1 every == every AND NOT obj.ishidden collect obj)

Pongo
05-29-2008, 12:31 AM
Thank you both!

Looks exactly like what I needed.

CGTalk Moderation
05-29-2008, 12:31 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.