• 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
  • 相关阅读:
    Lucene.Net
    关于数据库优化问题总结
    网页幻灯片效果
    ASP.NET邮件发送
    【收藏】悟透JavaScript(李战)
    JS之显示、隐藏控件方法
    初学自定义验证码
    js之判断浏览器类型及版本号
    js清空上传控件的值
    vs2008学习之路
  • 原文地址:https://www.cnblogs.com/earthtosky/p/10521984.html
Copyright © 2020-2023  润新知