algorithmic modeling for Rhino
Hi,
How can assign material id to selected objects?
Below I have the script that randomly selects objects.
For example, I select objects and want to assign material id number 9 for all of them.
arrObjects = Rhino.GetObjects("Pick objects")
dblPercentage = Rhino.GetReal("Set percentage", 50, 0, 100)
NumItems = int(dblPercentage * UBound(arrObjects) / 100)
Rhino.Print NumItems & " elements will stay."
arrObjectsCopy = arrObjects
Dim i,j,tmp
Randomize 'Shuffle
For i = 1 To UBound(arrObjects) - 1
' Pick a random element.
j = Int((UBound(arrObjects) - i + 1) * Rnd + i)
' Swap.
tmp = arrObjectsCopy(i)
arrObjectsCopy(i) = arrObjectsCopy(j)
arrObjectsCopy(j) = tmp
Next
'Cut the tail
Redim Preserve arrObjectsCopy(NumItems)
Rhino.SelectObjects(arrObjectsCopy)
Tags:
Welcome to
Grasshopper
Added by morteza khorsand 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by morteza khorsand 0 Comments 0 Likes
Added by morteza khorsand 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by