' philippe block ' ph_block@mit.edu ' ' SCRIPT NAME: philippe_block_bridge.rvb ' DESCRIPTION: script for making a roof surface between two edges ' it asks for a profile for midspan ' result is a structurally optimal shape with a random midsection ' VERSION: runs for Rhino 4 Beta ' ' 01-20-05 ' Computational Design Solutions part1, MIT '------------------------------------------------------- ' ' ' ' 'MAKING A BRIDGE FROM TWO CURVES '================================================================= 'You are responsible for creating a bridge using the curves below 'The points that create the curves can be manipulated for variance 'in bridge curvature '================================================================= dim crv1,crv2,crv3 '1 & 2 are the edge curve, 3 is the profile dim srf 'this is the final surface function main() makecurves makeBridge 'use curves to make bridge end function '=======MAKECURVES FUNCTION======================================= 'This function creates two curves from points as paramaters 'the location of points can be manipulated for creating different 'bridge results '================================================================= function makeCurves() 'curves will be created from 4 points 'you are welcome to add more points for creating different 'types of curves, but the minimum should be 4 Dim crvOne, crvTwo 'Define variables for curves Dim crvOnePt1, crvOnePt2, crvOnePt3, crvOnePt4 'Define the variables for each point of curve one Dim crvTwoPt1, crvTwoPt2, crvTwoPt3, crvTwoPt4 'Define the variables for each point of curve two 'Create array of points crvOnePt1 = Array(0.0, 0.0, 10.0) 'create three floats that are the (X,Y,Z) values of the point crvOnePt2 = Array(4.0, 0.0, 10.0) crvOnePt3 = Array(8.0, 0.0, 10.0) crvOnePt4 = Array(12.0, 0.0, 10.0) crvTwoPt1 = Array(0.0, 50, 10.0) 'create three floats that are the (X,Y,Z) values of the point crvTwoPt2 = Array(4.0, 50, 10.0) crvTwoPt3 = Array(8.0, 50, 10.0) crvTwoPt4 = Array(12.0, 50, 10.0) crvOne = Rhino.AddInterpCurve(Array(crvOnePt1, crvOnePt2, crvOnePt3, crvOnePt4)) 'Create first curve with array of points crvTwo = Rhino.AddInterpCurve(Array(crvTwoPt1, crvTwoPt2, crvTwoPt3, crvTwoPt4)) 'Create second curve with array of points crv1 = crvOne crv2 = crvTwo end function '**************************************** '===== FUNCTION FOR YOU TO CODE ========= '**************************************** '=======MAKEBRIDGE FUNCTION======================================= 'This function uses the two curves from above function to build 'your bridge '================================================================= function makeBridge() 'In this function body you will be responsible for using the 'two curves c1 and c2 above which are passed as parameters 'to build your bridge 'you are allowed to use as many helper functions as necessary 'Concentrate on keeping your solution simple in the beginning 'you are welcome to elaborate on your design after you have something 'working dim div: div = 20 'number of division, ie accuracy 'draw profile and get profile dim profile profile = Rhino.getObject("Draw profile and Get Object",4) dim startProf,endProf startProf = Rhino.CurveStartPoint (profile) endProf = Rhino.CurveEndPoint (profile) dim zMin if startProf(2) < endProf(2) then 'zMin is lowest of start and end point of profile zMin = startProf(2) else zMin = endProf(2) end if dim midpoint redim arrPt1(div) 'array of division points of curve 1 redim arrPt2(div) 'array of division points of curve 2 redim arrPt3(div) 'array of division points of profile redim arrPoly(div) 'array of connecting polylines redim arrMid(div) 'array of midpoints dim j dim Uval1,Uval2,Uval3 dim params1,params2,params3 dim point1,point2,point3 'find extremities of curve params1 = Rhino.curveDomain(crv1) params2 = Rhino.curveDomain(crv2) params3 = Rhino.curveDomain(profile) 'params(0)=Umin 'params(1)=Umax 'divide curve in "div" equal parts along u For j=0 to div Uval1=((params1(1)-params1(0))/div)*j Uval2=((params2(1)-params2(0))/div)*j Uval3=((params3(1)-params3(0))/div)*j point1 = Rhino.evaluateCurve(crv1,Uval1) point2 = Rhino.evaluateCurve(crv2,Uval2) point3 = Rhino.evaluateCurve(profile,Uval3) arrPt1(j) = point1 'division points on edge 1 arrPt2(j) = point2 'division points on edge 2 arrPt3(j) = point3 'points of original profile arrayPts = Array(arrPt1(j),arrPt2(j)) ' arrPoly(j) = Rhino.AddPolyline (arrayPts) 'array of polylines (straight) connecting edges arrMid(j) = Rhino.CurveMidPoint (arrPoly(j)) 'array of midpoints > midspan profile points 'giving correct height to midpoints arrMid(j)(2) = arrMid(j)(2) - zMin + arrPt3(j)(2) next crv3 = Rhino.AddInterpCurve (arrMid) 'make 3rd curve through the points of arrMid srf = Rhino.AddLoftSrf(Array(crv1,crv3,crv2)) end function main Rhino.ViewDisplayMode "Top",1 Rhino.ViewDisplayMode "Front",1 Rhino.ViewDisplayMode "Right",1 Rhino.ViewDisplayMode "Perspective",1