Rotate blocks randomly around their basepoints


#1

…Is there a way to do this? I am trying this for 2 hours now, but I have no success…
any help would be really appreciated .

thank you for any feedback

Andreas


#2

Initially I was thinking of a plugin I used a liitle while ago: http://www.food4rhino.com/app/rhinogrow but then I reaslied you don’t want them to move?

Andy


(Pascal Golay) #3

Hi Andreas - you’ll need a script for this - here’s a quick Python, in case that helps -

import rhinoscriptsyntax as rs import random

def test():

Ids = rs.GetObjects("Select block instances to rotate", filter = 4096, preselect=True)
if Ids is None: return
vec = rs.VectorCreate([0,0,1], [0,0,0])


for Id in Ids:
    pt = rs.BlockInstanceInsertPoint(Id)
    ang = random.randrange(-180, 180)
    rs.RotateObject(Id, pt,ang,vec)

if __name__ == "__main__": test()

-Pascal


#4

I still use the Harmony script to randomly rotate objects: http://www.rayflectar.com/p04-Programming/programming.html
(Jitter option) though I can’t recall if it worked with blocks or cared about their basepoints.


#5

first of all thanks for the swift feedback - cool community!

@pascal : thanks for your effort, it is really appreciated, I tried to use your script, I copied the text between the dot line and pasted it in the python editor, but something is not working here … what am I doing wrong?

here is a screenshot:

@2DCube, @edhenry70 : thanks for your suggestion, I know and use both tools , but the problem here is that I would like to be able to define a point around the rotation would take place…

maybe it is a good idea to explain what I would like to archive…


I have a leave (block), which is attached to a small branch, I also have a 3D curve. I would like to distribute numerous copies of this leave flowing along that curve with a random degree of rotation.
It should look like a kind of Ivy / liane…

I already considered buying the armadillo plugin, but I shy away from the pricetag

any Ideas?

best

Andreas


#6

You need to indent the whole script under def test(): - the formatting on Pascal’s post went wrong, should look like this:

import rhinoscriptsyntax as rs
import random

def test():

    Ids = rs.GetObjects("Select block instances to rotate", filter = 4096, preselect=True)
    if Ids is None: return
    vec = rs.VectorCreate([0,0,1], [0,0,0])
    
    
    for Id in Ids:
        pt = rs.BlockInstanceInsertPoint(Id)
        ang = random.randrange(-180, 180)
        rs.RotateObject(Id, pt,ang,vec)

if __name__ == "__main__":
    test()

–Mitch


#7

thanks Mitch -> now it works !


#8

Ah I get you. Maybe @Jarek can help with ArrayCrvPLUS?

I use if for a lot of things, it should do what you need here - there’s a lot of functionality with regard to rotation, scaling etc.

Andy


#9

yes, I remember I used to use it in the past, however I cannot find it anymore… do you have an old version or a working download link?

thanks

Andreas


#10

Hi Andreas,

you can get it from here: http://www.dig.gallery/misc

–jarek