zoukankan      html  css  js  c++  java
  • Revit二次开发_快速显示隐藏剖面框

    最近遇到一种状况需要经常切换剖面框的可见性,于是想将剖面框的显示与隐藏做成一个按钮,方便切换。
    其他类似元素想做成快速切换可见性应该可以使用类似做法。
    这次的隐藏对象是剖面框,所以我直接就隐藏元素了。
    以下核心代码:
                View activeView = uidoc.ActiveView;
                //过滤剖面框
                FilteredElementCollector elemCollector = new FilteredElementCollector(doc);
                elemCollector.OfCategory(BuiltInCategory.OST_SectionBox);
                Element sectionBox = null;
                //找到当前视图中可以隐藏的剖面框
                foreach(Element e in elemCollector)
                {
                    if (e.CanBeHidden(activeView))
                    {
                        sectionBox = e;
                        continue;
                    }
                }
                List<ElementId> sectionBoxIds = new List<ElementId>();
                sectionBoxIds.Add(sectionBox.Id);
                using(Transaction tran=new Transaction(doc, "快速隐藏工具"))
                {
                    tran.Start();
                    //判断当前视图中剖面框是否被隐藏
                    if (sectionBox.IsHidden(activeView))
                    {
                        //取消隐藏
                        activeView.UnhideElements(sectionBoxIds);
                    }
                    else
                    {
                        //隐藏
                        activeView.HideElements(sectionBoxIds);
                    }
                    tran.Commit();
                }
     
    转自:https://blog.csdn.net/imfour/article/details/79007851
  • 相关阅读:
    solr 最佳实践
    DNS 域名解析过程
    mac 下 virtualbox 配置全网通
    搜索引擎使用技巧
    三叉搜索树
    双数组trie树的基本构造及简单优化
    基于回归-马尔科夫模型的客运量预测
    solr 常用命令
    PHP yield 分析,以及协程的实现,超详细版(上)
    C语言,简单计算器【上】
  • 原文地址:https://www.cnblogs.com/earthtosky/p/10521984.html
Copyright © 2011-2022 走看看