Grasshopper

algorithmic modeling for Rhino

as we know,Point3d has properties,x,y,z.

but i want to inherit Point3d class to add another property,(such as a boolean value,to verify the visibility or a double value that show the distance between original point(0,0,0))

anyone can show me how to code it ?

vb or csharp all is welcome,but perfer csharp^_^

thank you very much!

Views: 361

Replies to This Discussion

Hi Andrea,

Point3d is not a class, it is a struct. You cannot inherit from a struct. What you can do is create another class or struct that has a Point3d as a member:

public class MyPoint

{

  private Point3d m_point;

  private double m_distance;

  private bool m_visible;

  public Point3d Location

  {

    get { return m_point; }

    set { m_point = value; }

  }

  //Etcetera, etcetera

}

--

David Rutten

david@mcneel.com

Poprad, Slovakia

thank you David for rapid reply

but....i have checked,the point3d is a class,because of "DistanceTo",distanceto is a method,struct cannot has method....

how to check one whether is a class or struct?

thank you David,Merry Christams

Structs can have methods just like classes.

The RhinoCommon help file can be used to determine whether something is a struct or a class (or an interface or any other type of OOP element).

--

David Rutten

david@mcneel.com

Poprad, Slovakia

thank you,i understand!

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service