Make BendsThis is a featured page

Option Explicit
dim arrCPlane : arrCPlane = Rhino.ViewCPlane
dim arrCrvs : arrCrvs = Rhino.GetObjects("Select cutting paths", 4)
dim lngSegments : lngSegments = Rhino.GetInteger("how many divisions?", 10)
dim i
dim arrPts0, arrPts1, arrEditPts0, arrEditPts1
For i=0 To (Ubound(arrCrvs)-1)
dim strCrv0 : strCrv0 = arrCrvs(i)
dim strCrv1 : strCrv1 = arrCrvs(i+1)
if lngSegments>1 Then
arrPts0 = Rhino.DivideCurve (strCrv0, lngSegments)
arrPts1 = Rhino.DivideCurve (strCrv1, lngSegments)
else
arrEditPts0 = Rhino.CurveEditPoints (strCrv0)
arrEditPts1 = Rhino.CurveEditPoints (strCrv1)
arrPts0 = array(arrEditPts0(0), arrEditPts0(Ubound(arrEditPts0)))
arrPts1 = array(arrEditPts1(0), arrEditPts1(Ubound(arrEditPts1)))
end If
dim j
For j=0 To (lngSegments-1)
dim arrPt00 : arrPt00 = arrPts0(j)
dim arrPt01 : arrPt01 = arrPts0(j+1)
dim arrPt10 : arrPt10 = arrPts1(j)
dim arrPt11 : arrPt11 = arrPts1(j+1)
dim dblDist0 : dblDist0 = Rhino.Distance (arrPt00, arrPt01)
dim dblDist1 : dblDist1 = Rhino.Distance (arrPt10, arrPt11)
dim dblDist2 : dblDist2 = (dblDist0 + dblDist1)/2
dim strLine0 : strLine0 = Rhino.AddLine (arrPt00, arrPt01)
dim strLine1 : strLine1 = Rhino.AddLine (arrPt01, arrPt11)
dim strLine2 : strLine2 = Rhino.AddLine (arrPt11, arrPt10)
dim strLine3 : strLine3 = Rhino.AddLine (arrPt10, arrPt00)
dim strLine4 : strLine4 = Rhino.AddLine (arrPt10, arrPt11)
dim arrMid0 : arrMid0 = Rhino.CurveMidPoint (strLine0)
dim arrMid1 : arrMid1 = Rhino.CurveMidPoint (strLine1)
dim strSrf : strSrf = Rhino.AddEdgeSrf (array(strLine0, strLine1, strLine2, strLine3))
dim arrCntr : arrCntr = Rhino.SurfaceAreaCentroid (strSrf)
dim arrParam : arrParam = Rhino.SurfaceClosestPoint (strSrf, arrCntr(0))
dim arrNormal: arrNormal = Rhino.SurfaceNormal (strSrf, arrParam)
dim arrVector: arrVector = rhino.VectorCreate (arrMid1, arrCntr(0))
Rhino.ViewCPlane , array(arrCntr(0), arrVector, array(arrNormal(0)*(-1),arrNormal(1)*(-1),arrNormal(2)*(-1)) )
dim strProfile: strProfile = MakeProfile(dblDist2)
dim strLoft : strLoft = Rhino.AddLoftSrf (array(strLine0, strProfile, strLine4 ))
rhino.DeleteObjects array(strLine0, strLine1, strLine2, strLine3, strLine4, strProfile, strSrf)

Next
Next
Rhino.ViewCPlane , arrCPlane


Function MakeProfile(dblDist)
'Automatically generated syntax for a curve
dim arrPlane : arrPlane = Rhino.ViewCPlane
Dim nObject_cp()
ReDim nObject_cp(8)

' nObject_cp(0) = Array(-0.001, 0.333333, 0)
' nObject_cp(1) = Array(0, -0.166667, 0)
' nObject_cp(2) = Array(0, 0.333333, 0)
' nObject_cp(3) = Array(-0.5, 0.833333, 0)
' nObject_cp(4) = Array(0, 0.833333, 0)
' nObject_cp(5) = Array(0.5, 0.833333, 0)
' nObject_cp(6) = Array(0, 0.333333, 0)
' nObject_cp(7) = Array(0, -0.166667, 0)
' nObject_cp(8) = Array(0.001, 0.333333, 0)

nObject_cp(0) = Array(-0.001, 0.32895, 0)
nObject_cp(1) = Array(0, 0, 0)
nObject_cp(2) = Array(0, 0.32895, 0)
nObject_cp(3) = Array(-0.333333, 0.666667, 0)
nObject_cp(4) = Array(0, 1, 0)
nObject_cp(5) = Array(0.333333, 0.666667, 0)
nObject_cp(6) = Array(0, 0.32895, 0)
nObject_cp(7) = Array(0, 0, 0)
nObject_cp(8) = Array(0.001, 0.32895, 0)

Dim nObject_k()
ReDim nObject_k(10)
nObject_k(0) = -2
nObject_k(1) = -1
nObject_k(2) = 0
nObject_k(3) = 1
nObject_k(4) = 2
nObject_k(5) = 3
nObject_k(6) = 4
nObject_k(7) = 5
nObject_k(8) = 6
nObject_k(9) = 7
nObject_k(10) = 8

Dim nObject_cp0()
ReDim nObject_cp0(8)
nObject_cp0(0) = Rhino.XformCPlaneToWorld (nObject_cp(0), arrPlane)
nObject_cp0(1) = Rhino.XformCPlaneToWorld (nObject_cp(1), arrPlane)
nObject_cp0(2) = Rhino.XformCPlaneToWorld (nObject_cp(2), arrPlane)
nObject_cp0(3) = Rhino.XformCPlaneToWorld (nObject_cp(3), arrPlane)
nObject_cp0(4) = Rhino.XformCPlaneToWorld (nObject_cp(4), arrPlane)
nObject_cp0(5) = Rhino.XformCPlaneToWorld (nObject_cp(5), arrPlane)
nObject_cp0(6) = Rhino.XformCPlaneToWorld (nObject_cp(6), arrPlane)
nObject_cp0(7) = Rhino.XformCPlaneToWorld (nObject_cp(7), arrPlane)
nObject_cp0(8) = Rhino.XformCPlaneToWorld (nObject_cp(8), arrPlane)

dim strNurbs
strNurbs = Rhino.AddNurbsCurve(nObject_cp0, nObject_k, 3)
dim dblLength : dblLength = Rhino.CurveLength (strNurbs)
dim scalePt : scalePt = Rhino.XformCPlaneToWorld (array(0,0,0), arrPlane)
MakeProfile = Rhino.ScaleObject (strNurbs, scalePt, array((dblDist/dblLength),(dblDist/dblLength) ,(dblDist/dblLength)))
End Function









No user avatar
mkbk
Latest page update: made by mkbk , Mar 26 2007, 11:58 AM EDT (about this update About This Update mkbk Edited by mkbk

496 words added

view changes

- complete history)
Keyword tags: None
More Info: links to this page
There are no threads for this page.  Be the first to start a new thread.