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
  • 相关阅读:
    单链表
    白话经典算法系列之中的一个 冒泡排序的三种实现
    QoS令牌桶工作原理
    BackTrack5 (BT5)无线password破解教程之WPA/WPA2-PSK型无线password破解
    [Django] Base class in the model layer
    MATLAB中导入数据:importdata函数
    联想A798T刷机包 基于百度云V6 集成RE3.1.7美化版 精简冗余文件
    改动symbol link的owner
    利用HttpOnly来防御xss攻击
    【NOIP2014 普及组】螺旋矩阵
  • 原文地址:https://www.cnblogs.com/earthtosky/p/10521984.html
Copyright © 2011-2022 走看看