Hello,
I need some expert help with a script for exporting the control points of multiple curves. The curves will be planar, one in front of the other along the X-axis (like cross-sections through a cylinder along the X-axis).
There is this script from the wiki mcneel page which I found (original indicated by ** below), but it only exports the control points of a single curve. Basically what I need in the end is a .csv-file with the point coordinates of the control points of multiple curves, sorted in the correct order (i.e. one point after the other along the curves, for each curve, one curve after the other).
I know nothing about scripting so my sorry attempts at modifying it did not get me very far. I managed to have it let me select multiple curves (see modifications indicated by * in script below), but then I always get an error message at the next step after my selecting.
I hope this is a simple thing for someone who is more knowledgeable than me…
Thanks in advance!
Antus
Sub ExportControlPoints()
**'Pick a curve object**
**Dim strObject**
**strObject = Rhino.GetObject("Select curve", 4)**
*strObject = Rhino.GetObjects("Select curves", 4)*
**If IsNull(strObject) Then Exit Sub**
**' Get the curve's control points**
**Dim arrPoints**
**arrPoints = Rhino.CurvePoints(strObject)**
**If Not IsArray(arrPoints) Then Exit Sub**
**' Prompt the user to specify a file name**
**Dim strFilter, strFileName**
**strFilter = "Text File (*.txt)|*.txt|All Files (*.*)|*.*|"**
**strFileName = Rhino.SaveFileName("Save Control Points As", strFilter)**
**If IsNull(strFileName) Then Exit Sub**
**' Get the file system object**
**Dim objFSO, objStream**
**Set objFSO = CreateObject("Scripting.FileSystemObject")**
**' Open a text file to write to**
**On Error Resume Next**
**Set objStream = objFSO.CreateTextFile(strFileName, True)**
**If Err Then**
**MsgBox Err.Description**
**Exit Sub**
**End If**
**' Write each point as text to the file**
**Dim strPoint, strText**
**For Each strPoint In arrPoints**
**strText = Rhino.Pt2Str(strPoint)**
**objStream.WriteLine(strText)**
**Next**
**' Close the file**
**objStream.Close**
End Sub