This is a very simple script that creates 3 different elix entwining. The diameters depend on the curve's curvature, directly or not.
Users can define the number of levels.
enjoy!
sim_c
Option Explicit
'Script written by
'Script copyrighted by
'Script version sabato 7 febbraio 2009 18.00.30
Call Main()
Sub Main()
Dim intNPts: intNPts= Rhino.GetInteger("how many points?", 15, 10, 20)
Dim i, arrPts, arrPtC, strCurve
ReDim arrPts(intNPts-1)
ReDim arrPtC (intNPts-1)
For i=0 To (intNPts-8)
arrPtC(i) = array(10*cos(i),10*sin(i),40*sqr(i))
arrPts(i)= Rhino.addpoint(arrPtC(i))
Next
For i= intNPts-8 To (intNPts-1)
arrPtC(i) = array(10*cos(i)/((i+1)/5),10*sin(i)/((i+1)/5),40*sqr(i))
arrPts(i)= Rhino.addpoint(arrPtC(i))
Next
strCurve = Rhino.AddInterpCurve (arrPtC)
Dim arrDom: arrDom = Rhino.CurveDomain(strCurve)
Dim dblparam, arrCrvData, dblStep, arrPlane, arrCircle, j
Dim dblRadius
ReDim arrCirc(intNpts)
dblStep = (arrDom(1)-arrDom(0))/intNPts
For j=0 To intNPts
dblParam = arrDom(0) + j*dblStep
arrCrvData = Rhino.CurveCurvature (strCurve, dblParam)
arrPlane = Rhino.CurvePerpFrame(strCurve, dblParam)
If Not isNull (arrCrvData) Then
dblRadius= arrCrvData(3)/10
Else
dblRadius = 0.1
End If
arrCirc(j) = Rhino.AddCircle(arrPlane, dblRadius)
'strCurveCrv = Rhino.AddInterpCurve(arrCirc)
Next
Call Rhino.AddLoftSrf(arrCirc)
Dim arrPts1, arrPtC1, strCurve1, n
ReDim arrPts1(intNPts-1)
ReDim arrPtC1 (intNPts-1)
For n=0 To (intNPts-1)
arrPtC1(n) = array(15*-cos(n)/(n+1),15*-sin(n)/(n+1),11*(n))
arrPts1(n)= Rhino.addpoint(arrPtC1(n))
Next
strCurve1 = Rhino.AddInterpCurve (arrPtC1)
Dim arrDom1: arrDom1 = Rhino.CurveDomain(strCurve1)
Dim dblparam1, arrCrvData1, dblStep1, arrPlane1, arrCircle1, m
Dim dblRadius1
ReDim arrCirc1(intNpts)
dblStep1 = (arrDom1(1)-arrDom1(0))/intNPts
For m=0 To intNPts
dblParam1 = arrDom1(0) + m*dblStep1
arrCrvData1 = Rhino.CurveCurvature (strCurve1, dblParam1)
arrPlane1 = Rhino.CurvePerpFrame(strCurve1, dblParam1)
If Not isNull (arrCrvData1) Then
dblRadius1= 175/arrCrvData1(3)
Else
dblRadius1 = 50
End If
arrCirc1(m) = Rhino.AddCircle(arrPlane1, dblRadius1)
'strCurveCrv = Rhino.AddInterpCurve(arrCirc)
Next
Call Rhino.AddLoftSrf(arrCirc1)
Dim p, arrPts2, arrPtC2, strCurve2
ReDim arrPts2(intNPts-1)
ReDim arrPtC2 (intNPts-1)
For p=0 To (intNPts-8)
arrPtC2(p) = array(10*-cos(p),10*-sin(p),40*sqr(p))
arrPts2(p)= Rhino.addpoint(arrPtC(p))
Next
For p= intNPts-8 To (intNPts-1)
arrPtC2(p) = array(10*-cos(p)/((p+1)/5),10*-sin(p)/((p+1)/5),40*sqr(p))
arrPts2(p)= Rhino.addpoint(arrPtC(p))
Next
strCurve2 = Rhino.AddInterpCurve (arrPtC2)
Dim arrDom2: arrDom2 = Rhino.CurveDomain(strCurve2)
Dim dblparam2, arrCrvData2, dblStep2, arrPlane2, arrCircle2, q
Dim dblRadius2
ReDim arrCirc2(intNpts)
dblStep2 = (arrDom2(1)-arrDom2(0))/intNPts
For q=0 To intNPts
dblParam2 = arrDom2(0) + q*dblStep2
arrCrvData2 = Rhino.CurveCurvature (strCurve2, dblParam2)
arrPlane2 = Rhino.CurvePerpFrame(strCurve2, dblParam2)
If Not isNull (arrCrvData2) Then
dblRadius2= arrCrvData2(3)/10
Else
dblRadius2 = 0.1
End If
arrCirc2(q) = Rhino.AddCircle(arrPlane2, dblRadius2)
'strCurveCrv = Rhino.AddInterpCurve(arrCirc)
Next
Call Rhino.AddLoftSrf(arrCirc2)
Call Rhino.EnableRedraw(True)
End Sub
Hi Sim_C,
ReplyDeleteinteresting exploration. However, pitifully the script does not accept more than 20 levels (you might easily correct this feature) and doesn't let the user choose a custom development curve (which would be a very nice feature), try to work on that.
Also remember to put a LOT of comments in the script describing what you are doing, how and (eventually) why.