Home > Software engineering >  Grasshopper in VB.net write Koch curve
Grasshopper in VB.net write Koch curve

Time:11-16



The code is as follows:

The main program
Private Sub the RunScript (ByVal x As the Line, ByVal y As an Integer, ByRef A As Object)
Dim lines01 As New List (Of the Line)
Lines01. Add (x)
For I As Integer=1 To y
Lines01=Koch (lines01) ' problem 1. Error (BC30311) : type "System. Collections. Generic. The List (Of Rhino. Geometry. The Line)" value cannot be converted to "Rhino. Geometry. The Line",
Next
A=lines01
End Sub

A subroutine

The Function Koch (ln As Line) As the List (Of the Line)
Dim pl As Plane=Plane. The unset
Dim pt01 pt02, pt03 pt04, pt05 As Point3d
Dim vec01, vec02 As Vector3d
Dim line01, line02 line03, line04 As the Line
Dim newLines As New List (Of the Line)
If ln. TryGetPlane (pl) Then
Pt01=ln. The From
Pt05=ln. To
Vec01=pt05 - pt01
Pt02=pt01 + vec01/3
Pt04=pt01 + vec01 * 2/3
Vec02=vec01/3
Vec02. Rotate (60 * math.h PI/180, pl. ZAxis)
Pt03=pt02 + vec02
Line01. From=pt01: line01. To=pt02: newLines. Add (line01)
Line02. From=pt02: line02. To=pt03: newLines. Add (line02)
Line03. From=pt03: line03. To=pt04: newLines. Add (line03)
Line04. From=pt04: line04. To=pt05: newLines. Add (line04)
End the If
Return newlines
End the Function

For everyone a great god answer!!!!! thank you

CodePudding user response:

Koch (ln As Line
But when you are in the call
Lines01=Koch ( lines01 ) is introduced into a List
  • Related