zoukankan      html  css  js  c++  java
  • Revit API通过相交过滤器找到与风管相交的对象。

    相交过滤器的应用,比几何相交法简便。Excluding剔除
    //找到与风管相交的对象,通过相交过滤器。
    [TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)]
    public class FindIntersectWallsByElement : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
        {
            UIApplication app = commandData.Application;
            Document doc = app.ActiveUIDocument.Document;
            Transaction trans = new Transaction(doc, "ExComm");
            trans.Start();

            //pick the duct
            Selection sel = app.ActiveUIDocument.Selection;
            Reference ref1 = sel.PickObject(ObjectType.Element, "Please pick a duct");
            Element duct = doc.GetElement(ref1);

            FilteredElementCollector collector = new FilteredElementCollector(doc);
            //相交过滤器
            ElementIntersectsElementFilter elementFilter = new ElementIntersectsElementFilter(duct, false);
            collector.WherePasses(elementFilter);

            List<ElementId> excludes = new List<ElementId>();
            excludes.Add(duct.Id);
            collector.Excluding(excludes);//剔除自身

            sel.Elements.Clear();

            //Add these interseting element to the selection
            foreach (Element elem in collector)
            {
                sel.Elements.Add(elem);
            }

            trans.Commit();
            return Result.Succeeded;
        }
    }
    url:http://greatverve.cnblogs.com/p/ElementIntersectsElementFilter.html
  • 相关阅读:
    C#面向对象编程基础-喜课堂笔记
    [爬虫]通过url获取连接地址中的数据
    第10季asp.net基础
    初学MVC
    学习MVC遇到的问题
    飞行棋小项目
    JAVAscript学习笔记
    iOS 清除xcode缓存和生成文件
    Access用OleDbParameter更新/插入数据
    SQLite动态库下载
  • 原文地址:https://www.cnblogs.com/greatverve/p/ElementIntersectsElementFilter.html
Copyright © 2011-2022 走看看