Grasshopper

algorithmic modeling for Rhino

If you have a conditional statement and you want to kill all numbers less Y my intuition tells me to set x to null which does not work.


    If x < y Then
      x = null

    Else
      x = x
      Print("Point passed" & x)
    End If


    A = x


_______________________________________________________________

If I set x to "null" it returns null because it is a string which is an invalid argument.
This works but what is the correct way to kill or make all values less than Y null?

    If x < y Then
      x = "null"

    Else
      x = x
      Print("Point passed" & x)
    End If


    A = x
 


   

Views: 699

Replies to This Discussion

There are certain data types in .Net that cannot be null (or Nothing which is the VB.Net keyword). Any number type (ints, doubles, singles, longs, etc) cannot be null. Those values all have a default value of 0 (or 0.0). Assigning Nothing to those variables just sets the value back to the default.

Also, VB.Net is a Strongly Typed language, which mean two things, A) you must specify the type of a variable when its declared, and B) the type of the variable cannot change. So you don't really even have the option to assign a string to that variable either.
Thanks for the post Damien, with that being said, how would you write a vb conditional statement that deletes all circles less than a specific number, if im not mistaken zero it is technically still a value and would not delete the circles. Maybe you would have to cull the circles....
For i As Int32 = CircleList.Count - 1 To 0 Step -1
   If (CircleList(i).Radius < min_radius) Then CircleList.RemoveAt(i)
Next


Note that you have to run through the list backwards, otherwise the items you remove will play havoc with the remainder of the loop.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Thanks for the reply David, I wouldn't have thought to use CircleList.Count is that a variable that you defined or is that a method within the library, speaking of methods where can I find documentation with explanations of the different methods? For example if I wanted to make a line from two points in VB.net where would I find the documentation to do so (similar to the Processing line method) if there is such a thing in VB. I apologize for my lack of knowledge...
Thanks again
Hi Charles,

Count is a readonly property of the List class. Most classes in the .NET framework have properties and methods attached to them. You can use the online MSDN pages to find out all about a particular class and its members.

At the time of writing this is the MSDN help topic for the List(Of T) type. But note that Microsoft often juggle their urls, so the link might expire at any moment.

Usually if you google a specific class name+namespace, the msdn page will be the first hit.

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

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