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.