Importer for Foil data

I remember someone had a script to import xy values to generate NACA foil sections. Was I dreaming?

Hi Jody - is is a matter of reading in a text file of points in the form

NACA 0008
1.0000     0.00084
0.9500     0.00537
0.9000     0.00965
0.8000     0.01749
0.7000     0.02443
0.6000     0.03043
0.5000     0.03529
0.4000     0.03869
0.3000     0.04001
0.2500     0.03961
etc etc 

And maybe interpolating the points with a curve? What is the file like and what is the desired result?

-Pascal

Thanks Pascal,

 I found the script I remembered already loaded and think I got it from Dale.

http://developer.rhino3d.com/samples/rhinoscript/airfoil/

Option Explicit

’ Subroutine to import “Selig” formatted airfoil shapes
Sub ImportAirfoil

’ Local constants
Const ForReading = 1

’ Local variables
Dim objFSO, objFile
Dim strFileName, strAirfoil, strLine, strCurve
Dim arrPt, arrPoints(), nCount

’ Prompt for an airfoil data file
strFileName = Rhino.OpenFileName(“Open”, “Airfoil Data File (.dat)|.dat|”)
If IsNull(strFileName) Then Exit Sub

’ Create a file system object
Set objFSO = CreateObject(“Scripting.FileSystemObject”)

’ Open the data file for reading
On Error Resume Next
Set objFile = objFSO.OpenTextFile(strFileName, ForReading)
If Err Then
MsgBox Err.Description
Exit Sub
End If

’ Read the name of the airfoil
strAirfoil = objFile.ReadLine

’ Read through the file looking for point coordinates
nCount = 0
Do While objFile.AtEndOfStream <> True
strLine = objFile.ReadLine
’ Convert the string to a point
arrPt = PointFromString(strLine)
If IsArray(arrPt) Then
ReDim Preserve arrPoints(nCount)
arrPoints(nCount) = arrPt
nCount = nCount + 1
End If
Loop

’ Close the curve
ReDim Preserve arrPoints(nCount)
arrPoints(nCount) = arrPoints(0)

’ Add the named interpolated curve
If IsArray(arrPoints) Then
strCurve = Rhino.AddInterpCurveEx(arrPoints)
Rhino.ObjectName strCurve, strAirfoil
End If

’ Close the file and release objects
objFile.Close
Set objFile = Nothing
Set objFSO = Nothing

End Sub

’ Function to generate a point from a string
Function PointFromString( strLine )
Dim arrTokens, arrPoint, x, y
PointFromString = Null
If VarType(strLine) = vbString Then
strLine = Trim(strLine)
arrTokens = Rhino.StrTok(strLine, " ")
If IsArray(arrTokens) And UBound(arrTokens) = 1 Then
x = CDbl(arrTokens(0))
y = CDbl(arrTokens(1))
arrPoint = Array(x, y, 0.0)
PointFromString = arrPoint
End If
End If
End Function

Just have to be sure that you download as a Selig format. Thanks for your response and thanks to Dale too!

NACA 642-015 AIRFOIL
1.000000 0.000000
0.950000 0.003460
0.900000 0.009500
0.850000 0.016770
0.800000 0.024720
0.750000 0.032960
0.700000 0.041130
0.650000 0.048950
0.600000 0.056200
0.550000 0.062660
0.500000 0.068100
0.450000 0.072240
0.400000 0.074730
0.350000 0.074820
0.300000 0.073190
0.250000 0.069850
0.200000 0.064800
0.150000 0.057850
0.100000 0.048420
0.075000 0.042400
0.050000 0.035040
0.025000 0.025280
0.012500 0.018420
0.007500 0.014560
0.005000 0.012080
0.000000 0.000000
0.005000 -0.012080
0.007500 -0.014560
0.012500 -0.018420
0.025000 -0.025280
0.050000 -0.035040
0.075000 -0.042400
0.100000 -0.048420
0.150000 -0.057850
0.200000 -0.064800
0.250000 -0.069850
0.300000 -0.073190
0.350000 -0.074820
0.400000 -0.074730
0.450000 -0.072240
0.500000 -0.068100
0.550000 -0.062660
0.600000 -0.056200
0.650000 -0.048950
0.700000 -0.041130
0.750000 -0.032960
0.800000 -0.024720
0.850000 -0.016770
0.900000 -0.009500
0.950000 -0.003460
1.000000 0.000000

Here is mine… --Mitch

ImportAirfoilDataV1.py (6.0 KB)

Mitch.

 That is beautiful! Much cleaner parsing the curve for some reason. You

da man! Thanks

Jody