Grasshopper

algorithmic modeling for Rhino

Hello,

I get the following error: object variable or With block variable not set. Does someone knows my mistake? My code is:

Private Sub RunScript(ByVal B As Double, ByVal n As Integer, ByVal a As Double, ByVal p As Double, ByVal t As Double, ByRef Eu As Object, ByRef Ru As Object, ByRef Mu As Object, ByRef H As Object, ByRef Ed As Object, ByRef Rd As Object, ByRef Md As Object) 

    Dim Hu As Integer
    Dim i As Integer
    Dim E1((n-1)) As Integer
    Dim R1((n-1)) As Integer
    Dim M1((n-1)) As Integer
    Dim E2((n-1)) As Integer
    Dim R2((n-1)) As Integer
    Dim M2((n-1)) As Integer
    Dim h1((n-1)) As Integer

    For i = n - 1 To 1 Step -1
      a = a * ( (math.cos(math.PI - b)) ^ (i))
      Hu = a * (math.sin(t) + math.cos(b - t - math.PI / 2))
      E1(i) = 2 * a * math.sin(b - t - math.PI / 2)
      R1(i) = E1(i) / (2 * math.sin(p))
      M1(i) = R1(i) * math.cos(p / 2)
      E2(i) = 2 * a * math.cos(t)
      R2(i) = E2(i) / (2 * math.sin(p))
      M2(i) = R2(i) * math.cos(p / 2)
      h1(i) = (Hu ^ 2 - (M1(i) - M2(i)) ^ 2) ^ (1 / 2)
      a = a * ( (math.cos(math.PI - b)) ^ (i - 1))
      t = b - math.PI / 2 - math.Asin(Ed(i) / (2 * a))
    Next
    a = a * ( (math.cos(math.PI - b)) ^ (0))
    Hu = a * (math.sin(t) + math.cos(b - t - math.PI / 2))
    E1(0) = 2 * a * math.sin(b - t - math.PI / 2)
    R1(0) = E1(i) / (2 * math.sin(p))
    M1(0) = R1(i) * math.cos(p / 2)
    E2(0) = 2 * a * math.cos(t)
    R2(0) = E2(i) / (2 * math.sin(p))
    M2(0) = R2(i) * math.cos(p / 2)
    h1(0) = (Hu ^ 2 - (M1(i) - M2(i)) ^ 2) ^ (1 / 2)
    For i = 1 To (n - 1)
      h(i) = h(i) + h(i - 1)
    Next
    Eu = E1
    Mu = M1
    Ru = R1
    Ed = E2
    Md = M2
    Rd = R2
    H = h1

  End Sub 

Views: 482

Replies to This Discussion

Hi Robin,

at some point you say:

t = b - Math.PI / 2 - Math.Asin(Ed(i) / (2 * a))

You cannot use Ed here as it hasn't been assigned anything yet. The same goes for:

h(i) += h(i - 1)

Did you mean h1 instead of h?

I also get a lot of overflow errors once the object variable not set disappear. But I have no idea what this script is supposed to do and it's very difficult to debug a script that uses such unmemorable variable names.

--
David Rutten
david@mcneel.com
Seattle, WA

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service