Revit API遍历房间Room创建空间Space
2012-01-01 21:46
405 查看
遍历全部房间,为每个房间创建对应的空间。
[TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class cmdRoom : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
{
UIApplication uiApp = commandData.Application;
Document doc = uiApp.ActiveUIDocument.Document;
Selection sel = uiApp.ActiveUIDocument.Selection;
Transaction ts = new Transaction(doc, "http://revit.5d6d.com");
ts.Start();
//遍历所有房间
FilteredElementCollector collector = new FilteredElementCollector(doc);
collector.OfCategory(BuiltInCategory.OST_Rooms);
foreach (Element el in collector)
{
Room room = el as Room;
LocationPoint roomPoint = room.Location as LocationPoint;
//为房间创建空间
doc.Create.NewSpace(room.Level, new UV(roomPoint.Point.X, roomPoint.Point.Y));
}
ts.Commit();
return Result.Succeeded;
}
}from:http://revit.5d6d.com/thread-1384-1-1.html
[TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class cmdRoom : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
{
UIApplication uiApp = commandData.Application;
Document doc = uiApp.ActiveUIDocument.Document;
Selection sel = uiApp.ActiveUIDocument.Selection;
Transaction ts = new Transaction(doc, "http://revit.5d6d.com");
ts.Start();
//遍历所有房间
FilteredElementCollector collector = new FilteredElementCollector(doc);
collector.OfCategory(BuiltInCategory.OST_Rooms);
foreach (Element el in collector)
{
Room room = el as Room;
LocationPoint roomPoint = room.Location as LocationPoint;
//为房间创建空间
doc.Create.NewSpace(room.Level, new UV(roomPoint.Point.X, roomPoint.Point.Y));
}
ts.Commit();
return Result.Succeeded;
}
}from:http://revit.5d6d.com/thread-1384-1-1.html
相关文章推荐
- Revit API根据房间Room创建空间Space
- Revit API创建一个拷贝房间内对象布局命令
- Revit API创建房间
- RevitAPI: 创建四通失败CrossFitting - InvalidOperationException: failed to insert cross.
- RevitAPI之在墙上创建门(基于宿主)
- RevitAPI之快速创建尺寸标注
- DB2学习--创建表空间 Wizard 就是用来指定Create ** Tablespace时的参数
- Zookeeper实例Curator API-使用curator来创建一个含隔离命名空间的ZooKeeper客户端
- Revit API创建详图视图
- ORA-01658: 无法为表空间space中的段创建 INITIAL 区
- ArcGIS flex api创建的空间数据存入数据库
- Oracle create tablespace 创建表空间语法详解
- RevitAPI: 编译错误 - 未能找到类型或命名空间名称“Autodesk”(是否缺少 using 指令或程序集引用?)
- Revit Family API 创建参考平面
- RevitAPI之在机械设备和风管终端间创建风管系统
- 如何用Revit API从无到有创建构建的类型对象?
- RevitAPI: 在墙上创建灯具族实例
- ORA-01658: 无法为表空间space中的段创建 INITIAL 区解决办法
- Revit API创建标注NewTag
- RevitAPI: 如何创建共享参数,并和类别绑定