Select a specific number of faces from a known percentage in mode random

Hi All man :)

I have create this script: (Create a plane with more subdivision and select it)

try (destroydialog t) catch()
 
Percentage = 100.0 ---define the initial percentage 
 
 
 
rollout t "Test"
(
	spinner sp "Rate = " range:[0,100,100] type:#integer
	button b "Go!"
 
	on sp changed val do Percentage = val
 
	on b pressed do
	(
		obj = $ ---the object selected
		converttopoly obj ---convert the object in editpoly
		getFaces = obj.numfaces --get the number of the face 
 
		---Calculate the number of face to selected by specified percentage 
		numFaces = (Percentage / 100.0 * getFaces) as integer
 
		---create a array for all faces  by specified percentage value
		numFaces_array = #()
 
		for o=1 to numFaces do 
        ( 
        append numFaces_array o 
        ) 		
 
 
		subobjectLevel = 4
		polyop.setFaceSelection  obj  numFaces_array --select the face 
 
 
		print numFaces
		----
		update obj
	)
 
 
 
 
)
createdialog t

As you can see, the script determines a percentage of a known number of faces that are selected consecutively (1,2,3, etc.)on the subdivision plane.

How do random known number of faces across the whole subdivision plane?

Some days I feel, but I can not understand...

Thanks in advance :)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Anubis's picture

use random index

Hi Michele,
if i understand ...

rndFaces = #{} -- empty bitArray
while rndFaces.numberSet < numFaces do
    rndFaces[random 1 obj.numFaces] = true

my recent MAXScripts RSS (archive here)

Michele71's picture

WoW!! Thanks Anubis :) :)

WoW!! Thanks Anubis :) :) Yes, it is what I was looking.

I have referred to create the script to tutorial MaxSript "How do I delete randomly a specified percentage of geometry objects?" but when start the loop WHEN/DO 3dsMax crash (strange...)! Whit your solution is all right!

Thanks again :)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.