我正在编写代码以使用来自许多不同 Revit 类别的元素来找到两个端点以用作虚拟“修剪/延伸”平面。我有这个为细节线和结构框架工作......
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;
}
但是,当我对网格和参考平面使用类似方法时,Revit 会响应错误(通常是“对象引用未设置为对象的实例”)。我已经探索过“Snoop”,但如何获取列出的值似乎并不明显,这些值位于“Plane”等选项卡内。有谁知道我如何访问类似的信息(例如网格或参考平面上的任何两个点)?目前,我正在绕过提取的点,并使用....
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;
}
.....但是直接找到可用点会更好。