几何实体的创建方法之一:
构成封闭底面,指定拉伸方向与拉伸高度。GeometryCreationUtilities

//自创几何实体相交法
[TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class FindIntersectWallsByGeometry : 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 a point to draw solid在屏幕上选择一点,找到附近的墙。
        Selection sel = app.ActiveUIDocument.Selection;
        XYZ pt = sel.PickPoint("Please pick a point to get the close walls");         //XYZ pttemp1 = sel.PickPoint(Autodesk.Revit.UI.Selection.ObjectSnapTypes.None, "Pick leader end...");
        //XYZ pttemp2 = sel.PickPoint(Autodesk.Revit.UI.Selection.ObjectSnapTypes.None, "Pick leader elbow...");         //
        double dBoxLength = ;
        //Z值不变,以选择的点为中心,找到矩形四个点。
        XYZ pt1 = new XYZ(pt.X - dBoxLength / , pt.Y - dBoxLength / , pt.Z);
        XYZ pt2 = new XYZ(pt.X + dBoxLength / , pt.Y - dBoxLength / , pt.Z);
        XYZ pt3 = new XYZ(pt.X + dBoxLength / , pt.Y + dBoxLength / , pt.Z);
        XYZ pt4 = new XYZ(pt.X - dBoxLength / , pt.Y + dBoxLength / , pt.Z);
        //创建四条线。
        Line lineBottom = app.Application.Create.NewLineBound(pt1, pt2);
        Line lineRight = app.Application.Create.NewLineBound(pt2, pt3);
        Line lineTop = app.Application.Create.NewLineBound(pt3, pt4);
        Line lineLeft = app.Application.Create.NewLineBound(pt4, pt1);
        //封闭曲线
        CurveLoop profile = new CurveLoop();
        profile.Append(lineBottom);
        profile.Append(lineRight);
        profile.Append(lineTop);
        profile.Append(lineLeft);         List<CurveLoop> loops = new List<CurveLoop>();
        loops.Add(profile);
        //创建实体的方法(底面,拉伸方向,拉伸高度)
        XYZ vector = new XYZ(, , );
        Solid solid = GeometryCreationUtilities.CreateExtrusionGeometry(loops, vector, );         //相交过滤器
        FilteredElementCollector collector = new FilteredElementCollector(doc);
        ElementIntersectsSolidFilter solidFilter = new ElementIntersectsSolidFilter(solid);         collector.WherePasses(solidFilter);         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/GeometryCreationUtilities.html

Revit API创建几何实体Solid并找到与之相交的元素的更多相关文章

  1. Revit Family API 添加几何实体

    先创建一个封闭曲线createProfileLShape();再创建实体,这里需要手工画一个参考平面; ; i < nVerts; ++i)        {            Line l ...

  2. Revit api 创建族并加载到当前项目

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  3. Revit API创建一个拷贝房间内对象布局命令

    本课程演示创建一个拷贝房间内对象布局命令,完整演示步骤和代码.这个命令把选中房间内的对象复制到其它选中的一个或多个房间中,而且保持与源房间一致的相对位置.通过本讲座使听众知道创建一个二次开发程序很简单 ...

  4. Revit API创建标注NewTag

    start ;             )                 {                     eId = item;                 }            ...

  5. Revit API创建墙的保温层修改墙厚度

    start [Transaction(TransactionMode.Manual)] [Regeneration(RegenerationOption.Manual)]  / ;         ; ...

  6. Revit API创建标高,单位转换

    一业内朋友让我写个快速创建标高的插件. ;             ; i <= iNum; i++)             {                 Level level = d ...

  7. Revit API 创建带箭头的标注

      [Transaction(TransactionMode.Manual)] [Regeneration(RegenerationOption.Manual)] public class cmd : ...

  8. Revit api 创建楼梯图元

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  9. Revit API创建详图视图

    start //创建详图视图 Transaction ts = new Transaction(doc, "http://greatverve.cnblogs.com"); ts. ...

随机推荐

  1. cefsharp保存文件为pdf

    var success = await browserViewModel.WebBrowser.PrintToPdfAsync(dialog.FileName, new PdfPrintSetting ...

  2. 2018-2019-2 网络对抗技术 20165301 Exp1 PC平台逆向破解

    任务一 直接修改程序机器指令,改变程序执行流程 1.输入指令objdump -d pwn5301 | more反汇编pwn1文件. 通过反汇编,可以看到main函数中的call 804891,其机器码 ...

  3. How to return plain text from AWS Lambda & API Gateway

    With limited experience in AWS Lambda & API Gateway, it's struggling to find the correct way to ...

  4. .NetCore 使用AutoMapper

    添加引用 AutoMapper AutoMapper.Extensions.Microsoft.DependencyInjection 注册服务 services.AddAutoMapper(); 配 ...

  5. 关于 contentWindow, contentDocument

    没有永恒的技术只有变态的需求,没有好说的客户只有无奈的开发者, 如果iframe的出现是一个错误的话,iframe里边在来一个iframe那是错上加错,神话没有在远古的尘嚣中消失,却在怀具的今天不断上 ...

  6. linux中如何清空一个文件的内容

    方法1: echo "" > /www.jbxue.com /xxx.log 方法2: echo "" >> /www.jbxue.com / ...

  7. 【Java】 大话数据结构(12) 查找算法(3) (平衡二叉树(AVL树))

    本文根据<大话数据结构>一书及网络资料,实现了Java版的平衡二叉树(AVL树). 平衡二叉树介绍 在上篇博客中所实现的二叉排序树(二叉搜索树),其查找性能取决于二叉排序树的形状,当二叉排 ...

  8. 应用Mongoose开发MongoDB(1)数据库连接

    最近因为项目,接触了MongoDB,因为是分工合作,我负责的部分主要是实现前端对数据库增删查改的需求,因此以下内容只着重于针对不同问题如何进行解决. 整个工程的最终目的是通过mongoose编写数据库 ...

  9. 020.Zabbix的Actions配置

    一 Action概述 当产生Trigger后,即当触发器条件被满足时,采取一些操作,如发送事件通知,远程执行命令等,需要配置Action.   名称 作用 Trigger 当Trigger的状态从OK ...

  10. 小成就之解决调用spring中FileSystemXmlApplicationContext路径问题

    此文写下调用spring过程中遇到的一个问题!或许对于入行的人一看觉得我很傻逼吧,这问题谁都会了!但我觉得对于新手(自已)来说,算是一个好思路与好办法! 问题: 对于 test_aa ta = (te ...