0

I am working on code to use elements from a number of different Revit categories to find two endpoints to use as a virtual "trim/extend" plane. I have this working for Detail Lines & structural framing......

switch (Ref_Plane_Category){
    case "Lines": {
                LocationCurve xloc = Ref_Plane.Location as LocationCurve;
                End3 = xloc.Curve.GetEndPoint(0);
                End4 = xloc.Curve.GetEndPoint(1); break;
    }
    case "Structural Framing": {
                Options options = new Options();
                AnalyticalModel xmodel = Ref_Plane.GetAnalyticalModel();
                Curve xcurve = xmodel.GetCurve();
                End3 = xcurve.GetEndPoint(0); End4 = xcurve.GetEndPoint(1); break;
    }

However, when I use similar methods for Grids and Reference Planes, Revit responds with errors (usually "Object reference not set to an instance of an object"). I've explored "Snoop", but it doesn't seem obvious how to get to the listed values, which are inside tabs such as "Plane". Does anyone know how I access similar information (such as ANY two points on a Grid or Reference Plane)? Currently, I am bypassing the extracted points, and using....

case "Grids": {

                ObjectSnapTypes Snapper = ObjectSnapTypes.Nearest | ObjectSnapTypes.Endpoints;
                End3 = m_doc.Selection.PickPoint(Snapper, "Pick One Point On Grid");
                ObjectSnapTypes Snappur = ObjectSnapTypes.Endpoints | ObjectSnapTypes.Nearest;
                End4 = m_doc.Selection.PickPoint(Snappur, "Pick Another Point On Grid"); break;
}

.....but it would be much better to find usable points directly.

KeachyPeen
  • 147
  • 2
  • 13

1 Answers1

0

Reference Planes do not have end points. On the canvas when creating them, they do, but teh object is theoretically infinite... That's probably why you can't get end point programmaticly. Same applies for Grids. Although the addin mentioned here has a tool that creates 3D Grids, so it must be getting end point from somewhere.

Grids and reference planes both have a 2D and a 3D component. Do some searching in that vein might turn something up. I'll have a look around when I can get access to my desktop.

BigBadBIM
  • 21
  • 1