Hi,

is there any chances to add a command for the future: random selection (with option to pick what % to be randomly selected from the whole scene). That would be really useful for artistic/design work. Thank you as always!!

Hi,

is there any chances to add a command for the future: random selection (with option to pick what % to be randomly selected from the whole scene). That would be really useful for artistic/design work. Thank you as always!!

1 Like

This could be scripted.

```
import random
import math
import rhinoscriptsyntax as rs
a=rs.GetObjects(message="Select")
b = len(a)
c = rs.GetInteger("percentage")
percentage = int(math.ceil(b/100*c))
rs.SelectObjects(random.sample(a, percentage))
```

3 Likes

thank you Martin, I will try it out

Hi Martin,

Thanks heaps for the script; I use it a lot.

Is it possible to have a similar script; where instead of inputting a percentage, you can input a number of objects you want to select?

Best,

Jeremy

I think the sample function requires a number and the percentage input is converted into a number first.

That means you can replace the percentage input with just a number input.

2 Likes

Hi Martin, thanks for your reply,

When the script asks for a percentage, when you input a number (e.g., 45), it gives you 45% of the total number of objects. How do you put 45 as a number of objects you want selected?

Best,

Jeremy

I think this should do it:

```
import random
import math
import rhinoscriptsyntax as rs
a=rs.GetObjects(message="Select")
c = rs.GetInteger("number")
rs.SelectObjects(random.sample(a, c))
```

1 Like

Works perfectly :))

Thank you so much

-Jeremy

1 Like