Hi,
I have been puzzled for the last few days, why my GH Python code is not working.
What I want to do is to copy a row of curves between two points. Like this:
Here is the code that does not work (“a” and “b” are input points, “N” is the number of curves between those two points, “curve” is the initial input curve):
import rhinoscriptsyntax as rs
vect = rs.VectorSubtract(b,a)
vect1 = rs.VectorDivide(vect,N)
a = []
for i in range(0,N):
vect = rs.VectorScale(vect1,i)
movedCurve = rs.MoveObject(curve,vect)
a.append(movedCurve)
For some reason it works only when I add the rs.CopyObject method inside of rs.MoveObject, like so: (line 9):
import rhinoscriptsyntax as rs
vect = rs.VectorSubtract(b,a)
vect1 = rs.VectorDivide(vect,N)
a = []
for i in range(0,N):
vect = rs.VectorScale(vect1,i)
movedCurve = rs.MoveObject(rs.CopyObject(curve),vect)
a.append(movedCurve)
Why is that so?
Basically in the first code, I am moving the initial curve, iteratively one by one vector and in each iteration I am appending that moved curve into the export “a” list. So why do I have to use the rs.CopyObject method too?
I attached the .gh file with both upper code present in it, and the .3dm with just two points and a curve.
Thank you.
copy curve between 2 points.gh(4.2 KB)
copy curve between 2 points.3dm(49.5 KB)