Revit编程如何提取轴线信息

来源:互联网 发布:php.ini 编码设置 编辑:程序博客网 时间:2024/05/17 02:55


问题描述:


在Revit里面如何提取当前视图中轴网的信息,例如名称,标高,坐标等等?



Solution:


这个问题在Revit编程时是非常典型的应用情况。找到目标对象,然后获取目标对象上的信息。


找到目标对象需要使用Revit的过滤机制,最核心的也是比用的类就是FilteredElementCollector类,他提供了添加过滤条件的方法,并且提供方法来获取满足条件的对象集合。

获取对象信息需要用Revit类的属性以及Revit对象的参数值,还有从Element.Location属性获取对象的位置信息。

这些的讲座信息你可以从 这个视频讲座中获取Revit编程最基本知识:  http://download.autodesk.com/media/adn/Revit_2011_API_DevTV_Chinese.zip 

从这个讲座里面获取Revit编程比较完整的描述如何读取参数信息,对象位置信息等:http://download.autodesk.com/media/adn/Revit2011_new_API_webcast(Chinese).zip



下面是实例代码如何获取上述信息。

  [Transaction(TransactionMode.Manual)]  public class GetAllGrids : IExternalCommand  {    public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)    {      UIApplication uiApp = commandData.Application;      Application app = uiApp.Application;      UIDocument uiDoc = uiApp.ActiveUIDocument;      Document doc = uiDoc.Document;      FilteredElementCollector collector = new FilteredElementCollector(doc,doc.ActiveView.Id);      collector.OfClass(typeof(Grid));      string sInfo = null;      foreach (Element elem in collector)      {        sInfo += "Name = " + elem.Name + ";";                Grid grid = elem as Grid;        LocationCurve locCurve = grid.Location as LocationCurve;        Curve cur = locCurve.Curve;        XYZ ptStart = cur.get_EndPoint(0);        XYZ ptEnd = cur.get_EndPoint(0);      }      TaskDialog.Show("Grid message", sInfo);               return Result.Succeeded;    }  }


转载请复制以下信息:
原文链接: http://blog.csdn.net/joexiongjin/article/details/8807449
作者:  叶雄进 , Autodesk ADN





原创粉丝点击