Hi there!
This is more a question about best practices than an actual problem, but here it goes:
I have created a custom class that will be used inside a custom GH_Component. I have copied a made-up version of the class at the bottom of the message to make my point.
What I want to do is being able to call AddRuntimeException()
, to throw an alert if the Surface.ClosestPoint()
method did not succeed. Since AddRuntimeException()
is only accesible from the actual component, I have created a new variable in my class to hold a reference to it’s owner
(the component that initialized it).
So, my question is as follows:
- Is this an actual good idea?
- Is there an better way to do this?
Since my end goal is to create a family of components that talk to each other, and I would be passing around this custom classes:
- Should I be deriving them from
IGH_Goo
and creatingGH_Param
wrappers for all the classes I would be passing around? - Would deriving from
IGH_Goo
give me access to throwing exceptions?
I guess they would be only 2 or 3 classes that I would need to pass around so it wouldn’t be a lot of work… Just asking!
This is the class:
public class ChebychevAxis
{
Surface _surface;
double u, v;
ChebychevNetGHComponent owner;
DataTree<Point3d> _axisPoints;
public ChebychevAxis(Surface surface, Point3d startPoint)
{
_surface = surface;
bool success = _surface.ClosestPoint(startPoint, out u, out v);
if (!success) owner.AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, "OOPS!! Something happend while setting the starting point");
}
}
Thanks in advance!
P.D. Markdown text is fun