What is the relationship between Rhino.Geometry, Rhino.Input and ObjRef

I have found the following “IntersectCurve” script and have a question regarding …(the whole script)

partial class Examples
      public static Rhino.Commands.Result IntersectCurves(Rhino.RhinoDoc doc)
        // Select two curves to intersect
        var go = new Rhino.Input.Custom.GetObject();
        go.SetCommandPrompt("Select two curves");
        go.GeometryFilter = Rhino.DocObjects.ObjectType.Curve;
        go.GetMultiple(2, 2);
        if (go.CommandResult() != Rhino.Commands.Result.Success)
          return go.CommandResult();

    // Validate input
    var curveA = go.Object(0).Curve();
    var curveB = go.Object(1).Curve();
    if (curveA == null || curveB == null)
      return Rhino.Commands.Result.Failure;

    // Calculate the intersection
    const double intersection_tolerance = 0.001;
    const double overlap_tolerance = 0.0;
    var events = Rhino.Geometry.Intersect.Intersection.CurveCurve(curveA, curveB, intersection_tolerance, overlap_tolerance);

    // Process the results
    if (events != null)
      for (int i = 0; i < events.Count; i++)
        var ccx_event = events[i];
        if (ccx_event.PointA.DistanceTo(ccx_event.PointB) > double.Epsilon)
          doc.Objects.AddLine(ccx_event.PointA, ccx_event.PointB);
    return Rhino.Commands.Result.Success;

When I put it into Visual Studio and started checking the data types I found some unusual things (from a beginner point of view) in the 14th row. var curveA = go.Object(0).Curve();

go = Rhino.Input.Custom.GetObject()

Rhino.Input.Custom.GetObject() has method Object()
the Object() method takes an argument : the index of the object to get

it returns an ObjRef present at that index

so go.Object(0) is an ObjRef

an ObjRef has the Method Curve() wich returns the curve for that ObjRef ( if its referencing a curve)

I believe an earlier reply by me in another topic was false as I stated that go.Object(0) would return an array.


Thank you, Willem!

Now, I understand and makes sense. I have checked the documentation and yes, the return type of the go.Object(0) is ObjRef and go.Object(0) will become ObjRef and as ObjRef comes with “.Curve” Method we are able to implement the .Curve Method in the same line. Finally the return type of the .Curve() Method will be Curve and this way we can declare this variable with the “curveA” that data type’s is also Curve coming from the Rhino.Geometry.Curve Class/Method.



1 Like