Notifications
Clear all

[Closed] Select/deselect random objects?

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

3 Replies

Perhaps something along the lines of:


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


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)

Thank you both!

Looks exactly like what I needed.