Notifications
Clear all

[Closed] random poly selection

Hey thanks guys for the help.

Wahoonrey, your script has a syntax error; i havent checked what, but i got what ur trying to get to; not repeating selection. Thanks Fabman, I shall be using your script for now. Thanks a lot guys,

Vikram.

P.S: If incase there is a selection of a face multiple times would it cause a problem in say when i emit particles from those selected poly’s???

1 Reply
(@fabman)
Joined: 10 months ago

Posts: 0

Nope… it shouldn’t cause any problem, when you select through Maxscript the same face ( or object ) twice it’s like selecting it once. It’s not like it’s going to emit two particles per poly …

Sorry guys, first rule of Fight Club is: Don’t post untested code.

This works:

(
	local obj = selection[1].baseobject -- Get the base object of the first object in the selection
	local numFaces = polyop.getNumFaces obj -- Get the number of faces
	local faces = #{} -- initialize the face bitarray
	local percent = 80.0 -- set the required percentage
	local cutoff = ceil (numfaces * percent / 100.0) -- precalculate the cutoff and round up
	 
	-- while the number of bits set in the face array is smaller than the cutoff find new random faces
	while (faces.numberSet < cutoff) do append faces (random 1 numFaces)
	 
	-- set the poly object's faces to the new selection
	polyop.setFaceSelection obj faces
	
	-- Force redraw to ensure the selection is visible and set the subobject to poly in case.
	completeRedraw()
	subObjectLevel = 4
)
Page 2 / 2