Hi,
I have spline that I need to place objects along. My problem is that the I need to place every object a certain distance from the spline starting point. I have a csv file that has every points distance from the starting point and the Z value. The spline is quite irregular.
In the end I will extrude a surface from the spline and then I will end up with objects placed on the wall based on the CSV file.
Hi,
Watched som tutorials about Python in Rhino to get some understanding about this
but I can’t get this to work. I am getting an error message “index out of range: 0”
I have attahed the Rhino file with curve and a sphere object, csv with a few of the values and the python flie.
Would be grately appricated if you can take a look at it @Adam_M
Got it to run know, it was some extra spaces in the filen name. I guess the “out of range” error has to do with no more lines to read in the csv.
So it runs but it doesn’t place the object along the line. Did a test with other values and I can see that the objects are placed with some kind of offset to the curve as illustrated in the image.
If I always place an object at 0 value I can always move all objects to the starting point of the spline using that object as refernce.
So I belive this is working for me now, thanks so much @Adam_M
Yeah, the Python I gave just uses the point on the curve as a translation vector for rs.CopyObjects. Meaning that the translation vector is from 0,0,0 to the points on the curve.
If you want to pick another point for your objects base point, you could do something like this:
import rhinoscriptsyntax as rs
import csv
filepath = "Your filepath here"
obId = rs.GetObject("Select objects to copy", preselect=True, select=True)
bp = rs.GetPoint("Pick base point")
pnts = []
crv = rs.coercecurve(rs.GetCurveObject("Pick Curve", False, True)[0])
with open(filepath) as csvfile:
reader = csv.reader(csvfile)
for row in reader:
row = float(row[0])
pnt =crv.PointAtLength(row)
vec = rs.VectorCreate(pnt, bp)
rs.CopyObjects(obId, vec)