'------------------------------------------------------------------------------ ' RhinoScript Code To Export Airfoil .Dat file for evaluation by DesignFoil ' XFOIL, VisualFoil or the Multisurface Aerodynamics VLM program ' it uses the UIUC database format input. 'tested on Rhino Version 3, SR 5b and all these analysis programs ' DesignFoil by John Dreese, XFOIL by Mark Drela and Harold Youngren ' VisualFoil, MutiSurface Aerodynamics by Patrick Hanley ' Written based on McNeel RhinoScript Example Files ' XFLR5, a re-write of XFOIL by Andre Deperrois which includes Miarex v1.0, ' by Mathieu Scherrer. Very nice. '------------------------------------------------------------------------------ Option Explicit '------------------------------------------------------------------------------ ' Subroutine: ExportFoilDat ' Purpose: Exports points on a NURB Based Foil Shape to a space-delimited file ' Discussion: This subroutine will iterate through Points that lie on a curve starting from the ' trailing edge, working along the upper surface then around the leading edge ' then along the lower surface back to the trailing edge. This version groups using ' a cosine weighting scheme toward the leading and trailing edges ' which yields much better resolution of fine details there ' Join all splines together if split, adjust 'curve seam' to the trailing edge ' and direction toward the top surface. The spline should wrap all the way- ' as one spline. It Scales it to a Unit 1 Chord so it is non-dimensionalized ' And Adjusts it to the Origin based on MinX, ChordY '------------------------------------------------------------------------------ Sub ExportFoilDat() Dim strObject, arrDomain, dblParam, arrPoint, Index, Steps,RawCos, DeltaCos,NextRawCos, arrEvalPts(),EvalPt Dim dblLastParam, strFileName, strText,Scale,MinX,ChordY Dim objFSO, objStream, i strObject = Rhino.GetObject("Select the Foil Curve", 4) 'Steps = Rhino.GetInteger("number of steps", 200, 10, 2000) 'Dividing Cosine deltas by 4 is only good for 200 steps 'If you wish to not Cosine weight it, more steps can be used ' uncomment the above Steps=200 strText=Rhino.StringBox("Description of Foil" ) arrDomain = Rhino.CurveDomain(strObject) dblParam=0 For Index = 0 To Steps dblLastParam=dblParam ' Original uniform spacing; dblParam = arrDomain(0)+((arrDomain(1)-arrDomain(0))/Steps)*Index 'calc Cos Spacing; '' RawCos=abs(cos(((Index)/Steps)*6.28318531)) '' NextRawCos=abs(cos(((Index+1)/Steps)*6.28318531)) '' DeltaCos=abs(RawCos-NextRawCos)/4 '' If Index=0 then '' dblParam = (DeltaCos*(arrDomain(1)-arrDomain(0)))+arrDomain(0) '' Else '' dblParam = (DeltaCos*(arrDomain(1)-arrDomain(0)))+dblLastParam '' End If EvalPt = Rhino.EvaluateCurve(strObject, dblParam) If Index=0 then MinX=EvalPt(0) ChordY=EvalPt(2) End IF If EvalPt(0)