misc.documentation.arrows.01

Option Explicit
‘Script written by
‘Script copyrighted by
‘Script version Sunday, June 08, 2008 1:19:49 AM

Call Main()
Sub Main()
Dim crv: crv = Rhino.GetObjects(“Select Curves”,4)
If isNull(crv) Then Exit Sub
Dim arrItems, arrValues, arrResults
arrItems = array(“scale_width”,”twist_angle”,”tip_location”,”tip_angle”,”start_width”,”end_width”,”tip_length”,”type_(1)or(2)”,”curved arrows”)
arrValues = array(1,0,.95,45,.2,.5,1,1,True)
arrResults = Rhino.PropertyListBox (arrItems, arrValues ,,”Arrow Parameters”)
Dim i
If arrResults(0) .99 Then
arrResults(2) = .99
End If
If arrResults(4) < .01 Then
arrResults(4) = .01
End If
If arrResults(5) < .01 Then
arrResults(5) = .01
End If
If arrResults(7) 1 Then
arrResults(7) = 1
End If

Call Rhino.EnableRedraw(False)
For i = 0 To uBound(crv) Step 1
Call reparameterize(crv(i))
Call curveArrows(crv(i),CDbl(arrResults(0)),CDbl(arrResults(1)),CDbl(arrResults(2)),CDbl(arrResults(3)),CDbl(arrResults(4)),CDbl(arrResults(5)),CDbl(arrResults(6)),CInt(arrResults(7)),CBool(arrResults(8)))
Next
Call Rhino.EnableRedraw(True)
End Sub
Function curveArrows(curve, dblScale,twistAngle,tip,headAngle,edgeParaA,edgeParaB,width,dblType,CrvBln)
curveArrows = Null
Dim i,j, crv, tipEdge, crvCpy, crvDom, dis,scale, count, crvFrame, strProfSet(1),tempCrv, crvX, srf(3)
Dim endPt, midPtA, midPtB
count = 2+CInt(twistAngle/90)
ReDim frame(count), pt(count*2+1), swProfSetA(count-1), swProfSetB(count-1),crvA(count-1),crvB(count-1),parameter(count)
ReDim srfEdge(2), edgeA(count-1), edgeB(count-1)

If width 0 Then
tip = (Rhino.CurveLength(curve)-width)/Rhino.CurveLength (curve)
End If
crvDom = Rhino.CurveDomain(curve)(1)
parameter(0) = 0
For i = 0 To count-1 Step 1
parameter(i) = (crvDom*tip/(count-1))*i
Next
parameter(count) = crvDom-(crvDom-crvDom*tip)*.5

dis = Rhino.Distance(Rhino.EvaluateCurve(curve,crvDom*tip),Rhino.EvaluateCurve(curve,crvDom))*dblScale
scale = dis*0.5

j=0
For i = 0 To count Step 1
crvFrame = Rhino.CurveFrame(curve,parameter(i))
If i = count Then
frame(i) = Rhino.RotatePlane(crvFrame,(twistAngle/(count-1))*(i-1),crvFrame(1))
Else
frame(i) = Rhino.RotatePlane(crvFrame,(twistAngle/(count-1))*i,crvFrame(1))
End If
pt(j) = Rhino.PointAdd(frame(i)(0),Rhino.VectorRotate(Rhino.VectorScale(frame(i)(2),scale),90-headAngle,frame(i)(3)))
j=j+1
pt(j) = Rhino.PointAdd(frame(i)(0),Rhino.VectorRotate(Rhino.VectorScale(frame(i)(2),scale),90+headAngle,frame(i)(3)))
j=j+1
If iedgeParaB Then
edgeParaB = -(edgeParaA-edgeParaB)/(count-1)
ElseIf edgeParaB>edgeParaA Then
edgeParaB = (edgeParaB-edgeParaA)/(count-1)
Else
edgeParaB = 0
End If
For i = 0 To count-1 Step 1
edgeA(i) = Rhino.SplitCurve(crvA(i),Rhino.CurveDomain(crvA(i))(1)*(1-(edgeParaA+edgeParaB*i)),True)
edgeB(i) = Rhino.SplitCurve(crvB(i),Rhino.CurveDomain(crvB(i))(1)*(edgeParaA+edgeParaB*i),True)
Next
For i = 0 To count-1 Step 1
swProfSetA(i) = (“_SelID ” & edgeA(i)(1) & ” “)
swProfSetB(i) = (“_SelID ” & edgeB(i)(0) & ” “)

Next
strProfSet(0) = Join(swProfSetA)
strProfSet(1) = Join(swProfSetB)
If dblType = 1 Then
Call Rhino.Command( “-_Sweep1 ” & “_SelID ” & crv(0) & ” ” & strProfSet(0) & ” _Enter _Simplify=None Enter”)
srf(2)= Rhino.FirstObject()
End If
Call Rhino.Command( “-_Sweep1 ” & “_SelID ” & crv(0) & ” ” & strProfSet(1) & ” _Enter _Simplify=None Enter”)
srf(3)= Rhino.FirstObject()

If dblType = 1 Then
Call Rhino.JoinSurfaces(srf,True)
Else
Call Rhino.JoinSurfaces(array(srf(1),srf(3)),True)
End If
Call Rhino.DeleteObjects(crv)
Call Rhino.DeleteObjects(srfEdge)
For i = 0 To count-1 Step 1
Call Rhino.DeleteObjects(edgeA(i))
Call Rhino.DeleteObjects(edgeB(i))
Next
End Function
Function reparameterize(strCurveID)
If Rhino.IsCurve(strCurveID) = True Then
Call rhino.SelectObject(strCurveID)
Call rhino.Command(“reparameterize 0 1”)
Call rhino.UnselectAllObjects()
End If
If Rhino.IsSurface(strCurveID) = True Then
Call rhino.SelectObject(strCurveID)
Call rhino.Command(“reparameterize 0 1 0 1”)
Call rhino.UnselectAllObjects()
End If
End Function

Advertisements

There are no comments on this post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: