Yes, I know. 🙂
If the user decide to select 900 of 1000 edges it is better to generate 100 random numbers and then to use the rest of the numbers instead of waiting 3dsMax to generate 900 random numbers.
This shuffles the array, but on my Max2020, despite the edgToSelArr is filled with correct amount of numbers, 3dsMax selects equal or less amount of edges. 🙂
(
global rol_testingStuff
try(destroyDialog rol_testingStuff)catch()
rollout rol_testingStuff "WHOPPER"
(
spinner spn_edgesToSel "Edges to select:" range:[1,1000,3] width:80 type:#integer
button btn_test "WHOPPER"
fn ShuffleArr arr =
(
for i = arr.count to 1 by -1 collect
(
swapIndex = random 1 i
swap arr[random 1 i] arr[i]
)
)
fn EdgSlct obj =
(
if classOf obj == Editable_Poly do
(
select obj
max modify mode
subobjectlevel = 2
spnVal = spn_edgesToSel.value
edgCnt = polyop.getNumEdges obj
case of
(
(spnVal > edgCnt): messagebox "Selected object has less edges than the value in the spinner"
(spnVal == edgCnt): (polyop.setEdgeSelection obj #{1..edgCnt})
default:
(
randomizedArr = ShuffleArr (#{1..edgCnt} as array)
edgToSelArr = for i = 1 to spnVal collect randomizedArr[i]
polyop.setEdgeSelection obj edgToSelArr
)
)
)
)
on btn_test pressed do
(
if selection.count == 1 do
EdgSlct selection[1]
)
)
createdialog rol_testingStuff width:200
)
https://miauu-maxscript.com/