'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 '================================================================= '=======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 crvOnePt1, crvOnePt2, crvOnePt3, crvOnePt4, crvOnePt5 'Define the variables for each point of curve one Dim crvTwoPt1, crvTwoPt2, crvTwoPt3, crvTwoPt4, crvTwoPt5 'Define the variables for each point of curve two Dim crvOne, crvTwo 'Define variables for curves '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, 12.0) crvOnePt3 = Array(8.0, 0.0, 16.0) crvOnePt4 = Array(12.0, 0.0, 12.0) crvOnePt5 = Array(12.0, 0.0, 10.0) crvTwoPt1 = Array(0.0, 50, 16.0) 'create three floats that are the (X,Y,Z) values of the point crvTwoPt2 = Array(4.0, 50, 12.0) crvTwoPt3 = Array(8.0, 50, 10.0) crvTwoPt4 = Array(12.0, 50, 12.0) crvTwoPt5 = Array(12.0, 50, 16.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 'Use the built curves to build bridge call makeBridge(crvOne, crvTwo) end function '**************************************** '===== FUNCTION CODED BY LESLIE LOK ========= '**************************************** '=======MAKEBRIDGE FUNCTION======================================= 'This function uses the two curves from above function to build 'your bridge '================================================================= function makeBridge(c1, c2) 'Find the Uval of c1 and c2 by finding the params of c1 and c2 'Set Umin and Umax 'paramsc1-Umin(0), Umax(1) 'paramsc2-Umin(0), Umax(1) 'use i to represent the range of the integrals (example:0,1,2,3,4,5,6=) 'in another words, set the number of points throughout the curve 'i= 0 to 6 'the Uval will be the values that sits in the integrals of i 'example,if c1 is 36,points, i Uval '0 '0 '1 '6 '2 '12 '3 '18 'continue... '6 '36 'Finding the params of c1 and c2 'Set the numbers of points that will be allocated on c1 and c2 by using evaluate curve (6) dim i dim Uvalc1 dim Uvalc2 Dim paramsc1 Dim paramsc2 dim rows dim line rows=20 redim linearray(rows) 'find the params of c1 and c2 paramsc1=Rhino.curveDomain(c1) paramsc2=Rhino.curveDomain(c2) 'after getting the params for the curves, find Uval for c1 and c2 For i= 0 to rows Uvalc1=((paramsc1(1)-paramsc1(0))/rows)*i Uvalc2=((paramsc2(1)-paramsc2(0))/rows)*i '50 is divided into 5 segmants, from 1 to 5, there are 5 points 'but the Uval is not the points, need to find points dim pointc1 dim pointc2 pointc1= Rhino.evaluateCurve(c1,Uvalc1) pointc2= Rhino.evaluateCurve(c2,Uvalc2) 'from here, all the 5points that divide the curve into 5 segments on both c1 and c2 are found 'now add a command to execute the loop line = Rhino.Addline(pointc1, pointc2) 'lines are added between c1 and c2 and these lines are given a variable name called line linearray(i) = line 'an array is created by pulling all the lines(from the variable line) into the linearray(i) Next 'Create another row of lines perpendicular to the lines between c1 and c2 For i= 0 to UBound(linearray) - 1 'define i, i is the range of all 20 lines from 0 to Ubound '(linearray)-1 stops the adding of i and i+1 at line 19. 'Rhino.Print UBond(linearray) dim paramscrvfromarraytwo dim paramscrvfromarrayone dim crvfromarrayone dim crvfromarraytwo crvfromarrayone=linearray(i) crvfromarraytwo=linearray(i+1) 'linearray(i) and (i+1) are given variable names like c1 and c2 paramscrvfromarrayone = Rhino.curveDomain(crvfromarrayone) paramscrvfromarraytwo = Rhino.curveDomain(crvfromarraytwo) For j= 0 to 10 'there will be 10 segments on the on linearray(i) dim Uvalcrvfromarraytwo dim Uvalcrvfromarrayone dim pointcrvfromarrayone dim pointcrvfromarraytwo Uvalcrvfromarraytwo=((paramscrvfromarraytwo(1)-paramscrvfromarraytwo(0))/10)*j Uvalcrvfromarrayone=((paramscrvfromarrayone(1)-paramscrvfromarrayone(0))/10)*j 'resolve the Uval of the two array by using the params and divide them into 10 segments 'multiply by the 10 points pointcrvfromarrayone = Rhino.evaluateCurve(crvfromarrayone,Uvalcrvfromarrayone) pointcrvfromarraytwo = Rhino.evaluateCurve(crvfromarraytwo,Uvalcrvfromarraytwo) 'find points of the 10 segments 'RHino.AddPoint pointcrvfromarrayone 'RHino.AddPoint pointcrvfromarraytwo Rhino.AddLine pointcrvfromarrayone,pointcrvfromarraytwo 'draw line from i and i+1 Next Next end function makeCurves()