Grasshopper

algorithmic modeling for Rhino

Hello,

I am working on my first component using Visual Studio 2012 and the GH Assembly Addon found here: 

https://visualstudiogallery.msdn.microsoft.com/9e389515-0719-47b4-a...

The Archimedean Spiral code example that comes with the GH Assembly addon, linked above,  and the Grasshopper SDK Help propose two different means of declaring start values for the component inputs--

The example in the GH Assembly Addon uses:


Plane plane = Plane.WorldXY;

Which would suggest using "Plane plane = null;" for initializing the object.

The Grasshopper SDK Help file recommends using:

Rhino.Geometry.Circle circle = Rhino.Geometry.Circle.Unset;   

 Which method for initializing variables is preferred?  Why doesn't Visual Studio recognize the ".Unset" method?
Thanks,
Aaron



                

Views: 398

Replies to This Discussion

Plane is a value type, which means it cannot be null. If you assign null to Plane, you probably get a plane where all numbers are set to zero. This is not the same as Plane.WorkdXY.

Unset is a property on some RhinoCommon structs, and it returns an invalid instance. So if you set a value type such as Circle or Point3d or Plane to Unset, you can check later whether it has been assigned by calling IsValid on it.

In a way it doesn't matter how you initialise variables. The DA.GetData() method will return false if the value wasn't assigned from an input, and that's your queue to exist the SolveInstance method.

And even if the DA.GetData method returns true, you still need to check whether the value you got is legal.

Great! Thanks, David.  Super helpful.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service