EaBIM

标题: Revit API遍历房间Room创建空间Space [打印本页]

作者: 萧闫子    时间: 2014-1-9 13:08
标题: Revit API遍历房间Room创建空间Space

遍历全部房间,为每个房间创建对应的空间。

  1. <div align="left">[TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)]
  2. public class cmdRoom : IExternalCommand
  3. {
  4.     public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
  5.     {
  6.         UIApplication uiApp = commandData.Application;
  7.         Document doc = uiApp.ActiveUIDocument.Document;
  8.         Selection sel = uiApp.ActiveUIDocument.Selection;

  9.         Transaction ts = new Transaction(doc, "http://revit.5d6d.com");
  10.         ts.Start();

  11.         //遍历所有房间
  12.         FilteredElementCollector collector = new FilteredElementCollector(doc);
  13.         collector.OfCategory(BuiltInCategory.OST_Rooms);
  14.         foreach (Element el in collector)
  15.         {
  16.             Room room = el as Room;
  17.             LocationPoint roomPoint = room.Location as LocationPoint;
  18.             //为房间创建空间
  19.             doc.Create.NewSpace(room.Level, new UV(roomPoint.Point.X, roomPoint.Point.Y));
  20.         }

  21.         ts.Commit();

  22.         return Result.Succeeded;
  23.     }
  24. }</div>
复制代码



作者: 鹦鹉仔    时间: 2014-2-20 14:33
路过!!! 帮顶……




欢迎光临 EaBIM (https://eabim.net/) Powered by Discuz! X3.2