从一个平面图中获取所有房间名称并更改每个房间的参数 | Revit API
Get all room names from one plan view and change a parameter of each room | Revit API
现在我正在做一个项目,它应该从平面图中获取房间名称并将每个房间名称与数据库进行比较。如果在数据库中找到房间名称,则房间中名为 "IS_IN_DATABASE" 的参数应更新为 "YES"
不幸的是我不知道如何从一个平面图中获取房间名称...
我找到这个 post:https://forums.autodesk.com/t5/revit-api-forum/how-to-retrieve-rooms-filtered-by-level/td-p/6627076
但它不起作用,因为我总是遇到异常:
viewId 不是视图。
参数名称:viewId
如果你提供一些代码会更容易,但这行得通吗?
View activeView = doc.ActiveView;
List<Room> rooms = new FilteredElementCollector(doc, activeView.Id).OfClass(typeof(Room)).Cast<Room>().ToList();
要仅获取列表中的名称,您可以使用如下方法:
List<string> rooms = new FilteredElementCollector(doc, activeView.Id).OfClass(typeof(Room)).Select(a => a.Name).ToList();
把using Autodesk.Revit.DB.Architecture
放在最上面,否则无法识别房间
已在 Revit API discussion forum thread on getting room names and changing parameter value 中回答。
如果您针对这两个不同的问题分别提出问题会更好。
现在我正在做一个项目,它应该从平面图中获取房间名称并将每个房间名称与数据库进行比较。如果在数据库中找到房间名称,则房间中名为 "IS_IN_DATABASE" 的参数应更新为 "YES"
不幸的是我不知道如何从一个平面图中获取房间名称...
我找到这个 post:https://forums.autodesk.com/t5/revit-api-forum/how-to-retrieve-rooms-filtered-by-level/td-p/6627076
但它不起作用,因为我总是遇到异常:
viewId 不是视图。 参数名称:viewId
如果你提供一些代码会更容易,但这行得通吗?
View activeView = doc.ActiveView;
List<Room> rooms = new FilteredElementCollector(doc, activeView.Id).OfClass(typeof(Room)).Cast<Room>().ToList();
要仅获取列表中的名称,您可以使用如下方法:
List<string> rooms = new FilteredElementCollector(doc, activeView.Id).OfClass(typeof(Room)).Select(a => a.Name).ToList();
把using Autodesk.Revit.DB.Architecture
放在最上面,否则无法识别房间
已在 Revit API discussion forum thread on getting room names and changing parameter value 中回答。
如果您针对这两个不同的问题分别提出问题会更好。