我正在尝试使用Revit API激活视图。我真正想要做的是显示标高或楼层平面视图。因此,我想要激活的视图(我的意思是,我希望这个视图实际显示在屏幕上)已经存在,并且我可以访问它的Id。
我见过关于创建、浏览、过滤视图的帖子,但没有关于激活它的帖子。这是一个楼层平面视图。(我想要的是,通过选择一个标高/楼层平面,它将在屏幕上显示该标高/楼层平面(类似于从现有Revit模型中打开该楼层平面以显示在用户屏幕上)。
发布于 2021-11-02 00:39:21
以下是如何切换到默认3D视图https://thebuildingcoder.typepad.com/blog/2011/09/activate-a-3d-view.html的示例
您可以对所有其他可用的视图执行相同的操作,如下所示
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
uidoc.ActiveView = yourview;
要从某个级别创建视图,您的代码可能如下所示
ViewFamilyType viewFamilyType = (from elem in new
FilteredElementCollector(doc)
.OfClass(typeof(ViewFamilyType))
let type = elem as ViewFamilyType
where type.ViewFamily == ViewFamily.FloorPlan
select type).FirstOrDefault();
using (Transaction t = new Transaction(doc))
{
t.Start("Create View");
var floorPlan = ViewPlan.Create(doc, viewFamilyType.Id, yourLevel.Id);
floorPlan.Name = "NewView";
t.Commit();
}
发布于 2021-11-02 12:49:06
非常容易做到:
# normally you have the ui set at the start of your script
ui = __revit__.ActiveUIDocument
# then just set the ActiveView as your view (not the ViewId)
ui.ActiveView = yourView
发布于 2021-11-26 10:51:06
FilteredElementCollector viewCollector =新文档(FilteredElementCollector);
viewCollector.OfClass(typeof(View));
foreach (Element viewElement in viewCollector)
{
yourview = (View)viewElement;
break;
}
}
uidoc.ActiveView = yourview;
https://stackoverflow.com/questions/69797909
复制相似问题