Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

developer:scriptsamples:importinterpcrv [2015/09/14] (current)
Line 1: Line 1:
 +======Importing an Interpolated Curve======
 +> **Developer:​** //​[[developer:​rhinoscript|RhinoScript]]//​
 +> **Summary:​** //How to read a point file and create an interpolated curve.//
 +
 +=====Example=====
 +The following [[developer:​rhinoscript|RhinoScript]] demonstrates how to read a text file containing point coordinates and create an interpolated curve from the points. See the [[developer:​rhinoscript|RhinoScript]] help file for details on running scripts.
 +
 +<code vb>
 + ​Option Explicit
 +
 + Sub ImportInterpCrv()
 +
 +   Dim strFilter, strFileName
 +   ​strFilter = "Text File (*.txt)|*.txt|All Files (*.*)|*.*|"​
 +   ​strFileName = Rhino.OpenFileName("​Open Point File", strFilter)
 +   If IsNull(strFileName) Then Exit Sub
 +
 +   Dim objFSO, objFile
 +   Set objFSO = CreateObject("​Scripting.FileSystemObject"​)
 +
 +   On Error Resume Next
 +   Set objFile = objFSO.OpenTextFile(strFileName,​ 1)
 +   If Err Then
 +     ​MsgBox Err.Description
 +     Exit Sub
 +   End If
 +
 +   Dim strLine, arrPt, arrPoints(),​ nCount
 +   ​nCount = 0  ​
 +   Do While objFile.AtEndOfStream <> True
 +     ​strLine = objFile.ReadLine
 +     If Not IsNull(strLine) Then
 +       ​strLine = Replace(strLine,​ Chr(34), , 1)
 +       arrPt = Rhino.Str2Pt(strLine)
 +       If IsArray(arrPoint) Then
 +         ReDim Preserve arrPoints(nCount)
 +         ​arrPoints(nCount) = arrPt
 +         ​nCount = nCount + 1
 +       End If
 +     End If
 +   Loop
 +
 +   If IsArray(arrPoints) Then
 +     ​Rhino.AddInterpCurveEx arrPoints
 +   End If
 +
 +   ​objFile.Close
 +
 +   Set objFile = Nothing
 +   Set objFSO = Nothing
 +
 + End Sub
 +</​code>​
 +
 +\\
 +
 +{{tag>​Developer RhinoScript}}
  
developer/scriptsamples/importinterpcrv.txt ยท Last modified: 2015/09/14 (external edit)