Random Delete tool
Recent RSS
Random Delete tool
From:  Jolin Masson
Date:  11. February 2013, 15:10

Hi, I am trying to refine the RandomTools created for Scriptographer so that it suits my preference, but I can't figure it out in Javascript. Not knowing a lot of Javascript don't help me either!

Right now, the script will delete a random number of items, depending of the number you give in the dialog box, and the number is somehow in relation with the quantity of items selected.
I would like it to delete a given percentage of the items, no matter how much are selected.

Re: Random Delete tool
From:  Jolin Masson
Date:  21. February 2013, 16:19

Oups, here is the file!

Re: Random Delete tool
Date:  21. February 2013, 21:41

try something like this
if you want to delete x% of items

for each item in the selection
if Math.random() < x/100 then delete item

Re: Random Delete tool
From:  Jolin Masson
Date:  21. February 2013, 22:13

Hi Gareth, I don't think I get it… here is the lines 77-85 that I played with, but it won't work, I have an error on the Mathe.random… line.

// loop through selected items
for ( i in sel ) {
var object = sel[i];

if( object.isValid() ) {
// ------------------------------------
// delete
// ------------------------------------
if ( values.b_delete ) {
if (Math.random() <= val_deleteAmt/100) object.remove();
} //end isValid()

And here is the global file if you wan't to have a look

Re: Random Delete tool
From:  pqbd
Date:  21. February 2013, 22:33

You need to call values.val_deleteAmt, as it's a property of 'values'

Re: Random Delete tool
From:  Jolin Masson
Date:  21. February 2013, 22:58

Woooow, it's working :D
That is awsome, thanks a thousand!

Here is the file, if anyone's interested, proudly entitled with a 1.0 at the end.

Does anyone know how I can upload it to the site? It doesn't seam to have a submit button anymore…

08.08.14, 15:24
15.05.14, 14:23
02.03.14, 19:16
18.11.13, 14:48
22.03.13, 03:05
22.02.13, 15:45
10.01.17, 16:37
19.02.16, 06:03
19.02.16, 06:00
17.01.16, 11:00
12.01.16, 13:10
25.11.15, 08:19
Script of the Moment
Sketchy Structures 04.11.10