Option Explicit 'Script written by 'Script copyrighted by 'Script version Friday, November 21, 2008 6:02:59 PM Call Main() Sub Main() Dim strCurv, arrPoints, arrptCent, strCentSurf, strOtherCurve, dblParam Dim arrOtherPoints, intRes, vectDir, strRib, arrptStart,dblDeep,intUnit,arrShapes() Dim arrCurves01, arrDom,strLine, arrCurves02, boolClosed, arrInt, arrCross(),arrEmpty() Dim i,j, k, m 'layer management If Not IsLayer("ribs01") Then : Rhino.AddLayer "ribs01",RGB(0,256,256): End If If Not IsLayer("ribs02") Then : Rhino.AddLayer "ribs02",RGB(256,256,256) : End If intUnit=Rhino.UnitSystem intRes=1 If intUnit=9 Then intRes=intRes/12 End If arrCurves01=Rhino.GetObjects("select ring curves",4) If Not Isarray(arrCurves01) Then: Rhino.Print "no ring curves selected" : Exit Sub : End If arrCurves02=Rhino.GetObjects("select cross curves",4) If Not Isarray(arrCurves01) Then: Rhino.Print "no cross curves selected" : Exit Sub : End If 'get rib depth and convert to correct units dblDeep=Rhino.GetReal("enter rib depth in inches",6) If IsNull(dblDeep) Then: Rhino.Print "no depth selected" : Exit Sub : End If If intUnit=9 Then dblDeep=dblDeep/12 End If Rhino.Print"working...." m=0 Rhino.CurrentLayer "ribs01" Rhino.EnableRedraw False For Each strCurv In arrCurves01 '--------------------make first set of ribs-------------------------- arrPoints=Rhino.DivideCurveLength(strCurv,intRes) arrptCent=FpointCentroid(arrPoints) For i=0 To Ubound(arrPoints) arrptStart=arrPoints(i) vectDir=Rhino.VectorCreate(arrptCent,arrptStart) vectDir=rhino.VectorUnitize(vectDir) vectDir=Rhino.VectorScale(vectDir,dblDeep) vectDir=Rhino.VectorAdd(arrptStart,vectDir) strLine=Rhino.addLine(arrptStart,vectDir) ReDim Preserve arrShapes(i) arrShapes(i)=strLine Next 'wrap loft array if curve is closed boolClosed=Rhino.IsCurveClosed (strCurv) If boolClosed=True Then ReDim Preserve arrShapes(Ubound(arrShapes)+1) arrShapes(Ubound(arrShapes))=arrShapes(0) End If strRib=Rhino.AddLoftSrf(arrShapes) 'clean up Rhino.DeleteObjects(arrShapes) '----------------make arrCross curve array------------------------ 'set size of cross array ReDim Preserve arrCross(Ubound(arrCurves02)) For k=0 To Ubound(arrCross) 'place empty array in each position of cross array If m=0 Then ReDim arrEmpty(Ubound(arrCurves01)) arrCross(k)=arrEmpty End If 'construct profile line arrInt=Rhino.CurveCurveIntersection(strCurv,arrCurves02(k)) arrptStart=arrInt(0,1) vectDir=Rhino.VectorCreate(arrptCent,arrptStart) vectDir=rhino.VectorUnitize(vectDir) vectDir=Rhino.VectorScale(vectDir,dblDeep) vectDir=Rhino.VectorAdd(arrptStart,vectDir) strLine=Rhino.addLine(arrptStart,vectDir) 'add profile line to cross aray at position arrCross(k)(m)=strLine Next 'increase count m=m+1 Next '------------------------------loft second set of ribs using arrCross---------------------- Rhino.CurrentLayer "ribs02" For Each arrShapes In arrCross strRib=Rhino.AddLoftSrf(arrShapes) 'clean up 'Rhino.DeleteObjects(arrShapes) Next Rhino.EnableRedraw True End Sub Function FpointCentroid(arrPoints) 'this function returns an array of point coordinates at the centroid of an array of points Dim arrCent(2),i, j arrCent(0)=0 arrCent(1)=0 arrCent(2)=0 For i=0 To Ubound(arrPoints) arrCent(0)=arrCent(0) + arrPoints(i)(0) arrCent(1)=arrCent(1) + arrPoints(i)(1) arrCent(2)=arrCent(2) + arrPoints(i)(2) Next j=i+1 FpointCentroid=Array((arrCent(0)/i),(arrCent(1)/i),(arrCent(2)/i)) End Function Function FSurfaceParameter(strObject,dblDist,intUV, intLine) 'returns a double: the parameter along a curve or surface 'that equals a given distance, in a given direction U=0, V=1 'Rhino.Print intLine Dim arrDom, dblParam arrDom=rhino.SurfaceDomain(strObject,intUV) dblParam= (arrDom(0) + ((arrDom(1)-arrDom(0))*dblParam)) FcurveParameter = Rhino.EvaluateCurve(strObject,dblParam) End Function