# RandomSelect Script ERROR???

**URL:** <https://forums.chaos.com/t/randomselect-script-error/14685>\
**Category:** Off-topic\
**Created:** [June 5, 2007, 8:36pm UTC](https://forums.chaos.com/t/randomselect-script-error/14685 "2007-06-05T20:36:32Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![KVMaster](https://avatars.discourse-cdn.com/v4/letter/k/df705f/32.png) [@KVMaster](https://forums.chaos.com/u/KVMaster)\
**Post date:** [June 5, 2007, 8:36pm UTC](https://forums.chaos.com/t/randomselect-script-error/14685/1 "2007-06-05T20:36:32Z")

</div>

Trying to run the BlurScript called RandomSelect in Max 8 and getting an error -- Type error: Call needs function or class, got: undefined. :evil:  
Anyone know what the deal is or can point me to a script that randomly selects objects in a scene?

Thanks in advance,

Brian

---

<div class="post-metadata">

**Author:** ![Sushidelic](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@Sushidelic](https://forums.chaos.com/u/Sushidelic)\
**Post date:** [June 6, 2007, 8:49am UTC](https://forums.chaos.com/t/randomselect-script-error/14685/2 "2007-06-06T08:49:30Z")

</div>

```auto
percentage = 50
for i = 1 to (geometry.count*percentage/100) do
(
randomnumber = random 1 geometry.count
selectmore geometry[randomnumber]
)

```

a quick one to work on geometry. change the percentage according to your needs.

```auto
myobjects = #()
percentage = 50
for i = 1 to ($.count*percentage/100) do
(
randomnumber = random 1 $.count
append myobjects $[randomnumber]
)
select myobjects

```

This one takes your selection. Change percentage value accordingly.

enjoy.  
Michael

---

<div class="post-metadata">

**Author:** ![Sushidelic](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@Sushidelic](https://forums.chaos.com/u/Sushidelic)\
**Post date:** [June 6, 2007, 11:01am UTC](https://forums.chaos.com/t/randomselect-script-error/14685/3 "2007-06-06T11:01:17Z")

</div>

```auto
try (destroydialog rndm) catch()
rollout rndm "random select"
(
	spinner percentage "percentage" range:[0,100,50] type:#integer
	button selectit "select"
	on selectit pressed do
	(
		objs = $ as array
		newsel = #()
		for i = 1 to (objs.count*percentage.value/100) do
			(
			n = random 1 objs.count
			append newsel objs[n]
			deleteitem objs n
			)
		select newsel
		destroydialog rndm
	)

)
createDialog rndm 130 50

```

something more userfriendly

---

<div class="post-metadata">

**Author:** ![Sushidelic](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@Sushidelic](https://forums.chaos.com/u/Sushidelic)\
**Post date:** [June 6, 2007, 11:58am UTC](https://forums.chaos.com/t/randomselect-script-error/14685/4 "2007-06-06T11:58:54Z")

</div>

ok - now it’s really finished, but just one other nice approach

```auto
try (destroydialog rndm) catch()
rollout rndm "random select"
(
   local objs = $ as array
   slider percentage "percentage" range:[1,22,12] type:#integer
   on percentage changed value do
   (
      newsel = #()
      for i = 1 to (objs.count*percentage.value^2/100) do
         (
         n = random 1 objs.count
         append newsel objs[n]
         )
      select newsel
   )

)
createDialog rndm 500 60

```

---

<div class="post-metadata">

**Author:** ![KVMaster](https://avatars.discourse-cdn.com/v4/letter/k/df705f/32.png) [@KVMaster](https://forums.chaos.com/u/KVMaster)\
**Post date:** [June 6, 2007, 12:24pm UTC](https://forums.chaos.com/t/randomselect-script-error/14685/5 "2007-06-06T12:24:13Z")

</div>

THANKS!!

Michael,

THANKS A BUNCH!!! I tried the first two and they work like a charm 😄😄

The other two polished versions you posted later give me a -- Type error: DestroyDialog requires Rollout Class, got: undefined. By NO means am I complaining just don’t want your hard work go to waste!! You need to get these posted on ScriptSpot or added to the BlurScripts page. I searched for a while, since I have no script writing skills 😅 , and could not find anything. Hopefully I’m not messing anything up on my end…

THANKS AGAIN!!! 😄😄

---

<div class="post-metadata">

**Author:** ![Sushidelic](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@Sushidelic](https://forums.chaos.com/u/Sushidelic)\
**Post date:** [June 6, 2007, 12:56pm UTC](https://forums.chaos.com/t/randomselect-script-error/14685/6 "2007-06-06T12:56:23Z")

</div>

well’they’re far from beeing worth to be posted on scriptspot… glad i could help, edited the last two so that they should work now too!

best regards,  
michael

---

<div class="post-metadata">

**Author:** ![KVMaster](https://avatars.discourse-cdn.com/v4/letter/k/df705f/32.png) [@KVMaster](https://forums.chaos.com/u/KVMaster)\
**Post date:** [June 6, 2007, 1:46pm UTC](https://forums.chaos.com/t/randomselect-script-error/14685/7 "2007-06-06T13:46:08Z")

</div>

THANKS

now it says -- Unable to convert: undefined to type: Array 😢

Hopefully I’m not wearing out my welcome…

THANKS AGAIN FOR HELPING ME OUT!!! 😄😄

---

<div class="post-metadata">

**Author:** ![Sushidelic](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@Sushidelic](https://forums.chaos.com/u/Sushidelic)\
**Post date:** [June 6, 2007, 2:09pm UTC](https://forums.chaos.com/t/randomselect-script-error/14685/8 "2007-06-06T14:09:06Z")

</div>

You need to select the objects first, should have said that! The scripts will then remove objects from the selection.

best regards,  
Michael

---

<div class="post-metadata">

**Author:** ![KVMaster](https://avatars.discourse-cdn.com/v4/letter/k/df705f/32.png) [@KVMaster](https://forums.chaos.com/u/KVMaster)\
**Post date:** [June 6, 2007, 2:21pm UTC](https://forums.chaos.com/t/randomselect-script-error/14685/9 "2007-06-06T14:21:52Z")

</div>

OOPS

Knew I was going to screw something simple up on my end!! 😅

WORKS PERFECT!!!
