Grasshopper

algorithmic modeling for Rhino

I am trying to use an if statement to determine how to draw lines based of if points exist or not. I am not sure what to say in my if statement.

This is my c# code

And I want it to result in one of these sets of curves depending on the existence of points.

Views: 407

Replies to This Discussion

Hi Ryan, the types Point3d and Line are structes, not classes. As such they cannot be null and you cannot tell whether a point is defined or not (because if it isn't defined, it'll just be {0,0,0}). Point and Lines can have Unset values (meaning they contain invalid numbers), but that isn't happening here.

Because you didn't post your actual file I can't say whether treating all points a single list input will be a good alternative, but you may want to consider that.

Another alternative would be to use the System.Object hint instead of Point3d. System.Object is a class and can therefore be null, and it can also contain any other type. This way you can tell whether an input is defined or not, but you lose some type-safety in the process (see attached).

Attachments:

Thanks David that helps!

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