How to rotate multiple objects continiously which is following a circular path?
Hello everyone, I have no idea about scripting, and I have just searching about what it is. I have a problem for one of my project, I think its a simple thing but after trying a lot I didn’t recieve any successfull solutions.
Thank you so much for the answer! However, the thing that I mention about rotating is like continiously without stopping. Like here array gives me this result. How can it be like an animation, those things turning around the circle?
you might post a file with the before and after result what you want to achieve. Do you want ArrayPolar (copy the objects multiple times) or do you want to create a new surface eg. something like Revolve ?
Ps. It is often the best approach to first use regular Rhino commands and then try to script what they do to automate the process.
For an end product actually, not trying to create new surface or things etc. Exactly like in the gif, from the center point of the circle turning the objects on it like a wheel constantly.
Hi,
This is a starting point, instead of using static spheres you may want to make it use your custom selected objects. The path can be any curve.
If you are using Rhino8WIP we can use imageio to take a screenshot of the viewport and generate a gif, otherwise for Rhino7 which doesn’t support Rhinocode you should record your screen using a separate application.
import rhinoscriptsyntax as rs
import Rhino
import math
import time
def create_spheres_on_path():
spheres = []
for i in range(0, 200, 50):
sphere = rs.AddSphere([i, 0, 0], 20)
spheres.append(sphere)
return spheres
def move_spheres_along_path(spheres, path, iteration_count, pause_duration=0.01):
domain = path.Domain
step_size = (domain[1] - domain[0]) / iteration_count
for i in range(iteration_count+1):
t = domain[0] + i * step_size
point_on_path = path.PointAt(t)
for sphere in spheres:
rs.MoveObject(sphere, point_on_path - rs.SurfaceAreaCentroid(sphere)[0])
rs.Redraw()
time.sleep(pause_duration)
def main():
spheres = create_spheres_on_path()
crv = rs.GetObject("Select a path")
path= rs.coercecurve(crv)
move_spheres_along_path(spheres, path, iteration_count=500, pause_duration=0.01)
if __name__ == "__main__":
main()
Wow, thank you so much for the extra info as well. This script is really close to my aim. The only thing is here the spherese are rotating, but I want to choose my objects instead of those spheres.