Grasshopper

algorithmic modeling for Rhino

Hi, I am pretty new to grasshopper and have very little VB experience, so as you can imagine the learning curve is steep trying to create a script for grasshopper.  I am trying to create a script that will take a list and go down the list one by one and calculate an array.  It gets complicated in that the array created is the the length of the list squared and has data calculated based off of the value in the array immediately preceding the new value calculated.  I added the errors I am getting in the code, but I suspect there may be more issues.

 

Private Sub RunScript(ByVal Dist As Double, ByVal Scale As Double, ByVal Speed As List(Of Double), ByVal ActVol As List(Of Double), ByRef Basis As Object)
    Dim Val As Integer = (Dist / Scale) + 1
    Dim Ref As Integer = 1
    Dim Index As Integer
    Dim Above As Integer
    Dim AIndex As Integer
    Dim Below As Integer
    Dim BIndex As Integer
    Dim Cal (Val^2) As Double

 

    Do While Ref < Val
      Index = (Ref - 1) * Val + Ref
      Cal(Index) = ActVol(Ref)
      Above = Ref + 1
      Below = Ref - 1

      Do While Above <= Val
        AIndex = (Ref - 1) * Val + Above - 1
        Cal(Index) = Cal(AIndex) + Speed * Scale * (ActVol(Above) - Cal(AIndex)) Error: Opperator '*' is not defined for types 'System.Collections.List(Of Double)' and 'Double'
      Loop


      Do While Below > 0
        BIndex = (Ref - 1) * Val + Below + 1
        Cal(Index) = Cal(BIndex) + Speed * Scale * (ActVol(Below) - Cal(BIndex)) Error: Opperator '*' is not defined for types 'System.Collections.List(Of Double)' and 'Double'
      Loop

      Ref = Ref + 1
    Loop

    Basis = Cal


  End Sub

Views: 228

Replies to This Discussion

Hi Scott,

Speed is a list of doubles, therefore:

cal(index) = cal(aIndex) + speed * scale * (actvol(above) - cal(aIndex))
                           ^^^^^


is invalid. You cannot multiply a double (scale) with a list of doubles (speed).
I think you probably mean:

cal(index) = cal(aIndex) + speed(above) * scale * (actvol(above) - cal(aIndex))

--
David Rutten
david@mcneel.com
Poprad, Slovakia

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service