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!!
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))
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.
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))
Works perfectly :))
Thank you so much
-Jeremy
Hi there,
Please forgive my ignorance, this is my first time using scripts.
I have a few hundred blocks on the screen and want to select some randomly. I’ve tried running this script and this is what I get.
What Rhino version are you using?
Here in Rhino 8 windows the script worked. When you run the script, you’re asked to select…
Please select the whole set from which you want to get a random selection. Then enter a number which needs to be smaller than the total number of objects in the set.
Thanks for getting back! I’m using Rhino 7. I have selected all the items and still get an error message. Where abouts in the script do I add the number of items? I’ve currently got 12,000ish blocks (roof tiles) selected and want to select about 1000 at random each time.
This should be a python script and not *.rvb
It all makes sense now! I didn’t know about python scripts. Thank you so much.