Grasshopper

algorithmic modeling for Rhino

am trying to get items from three lists of coordinates x,y,z with the same count then try to change some according to an if statement resulting in a new list of points with the changes however am getting (public member count on type string not found ) anyone have an idea ? or is my script correct anyway ? thanks in advance

    Dim i As Integer 
    Dim x1 As Double = -0.193616
    Dim x2 As Double = -0.664584
    Dim x3 As Double = -0.396097
   


    Dim newPList As New List (Of Point3d)


    For i = 0 To xList.Count() - 1 Step 1

      If x1.Equals(xList(i)) Or x2.Equals(xList(i)) Or x3.Equals(xList(i))  Then
        xList(i) = 0.6

      End If


      Dim u As New point3d
      u.X = xList(i)
      u.Y = yList(i)
      u.Z = zList(i)
      newPList.Add(u)

    
    Next

    A = xList

Views: 296

Replies to This Discussion

See if it works with this code:

 

   Dim p_list As New list(Of point3d)
    Dim replace_list As New list(Of Double)
    replace_list.addrange({-0.193616, -0.664584, -0.396097})

    For i As Integer = 0 To  x.Count - 1
      For Each d As Double In replace_list
        If math.Abs(d - xlist(i)) < 0.001 Then
          xlist(i) = 0.6
          Exit For
        End If
      Next
      p_list.add(New point3d(xlist(i), ylist(i), zlist(i)))
    Next
    a = p_list

 

Notice i used a different method to evaluate if two doubles are the same. If you use the = or .equals method it is posible that two values that seem the same but have different precision return as not equal.

 

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service