Revit API创建几何实体Solid并找到与之相交的元素
几何实体的创建方法之一:
构成封闭底面,指定拉伸方向与拉伸高度。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并找到与之相交的元素的更多相关文章
- Revit Family API 添加几何实体
先创建一个封闭曲线createProfileLShape();再创建实体,这里需要手工画一个参考平面; ; i < nVerts; ++i) { Line l ...
- Revit api 创建族并加载到当前项目
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- Revit API创建一个拷贝房间内对象布局命令
本课程演示创建一个拷贝房间内对象布局命令,完整演示步骤和代码.这个命令把选中房间内的对象复制到其它选中的一个或多个房间中,而且保持与源房间一致的相对位置.通过本讲座使听众知道创建一个二次开发程序很简单 ...
- Revit API创建标注NewTag
start ; ) { eId = item; } ...
- Revit API创建墙的保温层修改墙厚度
start [Transaction(TransactionMode.Manual)] [Regeneration(RegenerationOption.Manual)] / ; ; ...
- Revit API创建标高,单位转换
一业内朋友让我写个快速创建标高的插件. ; ; i <= iNum; i++) { Level level = d ...
- Revit API 创建带箭头的标注
[Transaction(TransactionMode.Manual)] [Regeneration(RegenerationOption.Manual)] public class cmd : ...
- Revit api 创建楼梯图元
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- Revit API创建详图视图
start //创建详图视图 Transaction ts = new Transaction(doc, "http://greatverve.cnblogs.com"); ts. ...
随机推荐
- 洛谷 P4389: 付公主的背包
题目传送门:洛谷 P4389. 题意简述: 有 \(n\) 个物品,每个物品都有无限多,第 \(i\) 个物品的体积为 \(v_i\)(\(v_i\le m\)). 问用这些物品恰好装满容量为 \(i ...
- expect学习笔记及实例详解【转】
1. expect是基于tcl演变而来的,所以很多语法和tcl类似,基本的语法如下所示:1.1 首行加上/usr/bin/expect1.2 spawn: 后面加上需要执行的shell命令,比如说sp ...
- oracle任务job
1)创建测试表 1 create table test1(a date); 2)创建存储过程 1 2 3 4 5 create or replace procedure myproc as begin ...
- pixel像素基础
地址:http://www.imooc.com/video/9564 dp(安卓),pt(iphone)是物理像素 ppi是由物理像素确定的 一英寸内有多少个像素渲染,ppi越高,图片越清晰 1px ...
- 打FFT时中发现的卡常技巧
题目:洛谷P1919 A*B Problem 加强版 我的代码完全借鉴boshi,然而他380ms我880ms...于是我通过彻底的卡(chao)常(dai)数(ma)成功优化到了380ms,都是改了 ...
- Ubuntu编译gdb-ARM调试环境
参考Qt可用的gdb编译,以及交叉编译gdbserver,以及配置QtCreator远程调试 编译脚本 如下: #!/bin/bash echo -e "\033[32m 正在执行步骤一:检 ...
- JAVAssist字节码操作
Java动态性的两种常见实现方式 字节码操作 反射 运行时操作字节码可以让我们实现如下功能: 动态生成新的类 动态改变某个类的结构(添加/删除/修改 新的属性/方法) 优势: 比反射开销小,性能高 ...
- SSH免密登录机制
SSH免密登录机制:(见下图) 1.A先使用ssh-keygen生成一对公钥和私钥:ssh-keygen 2.将A的公钥复制给B一份,并且将其追加到B的授权文件中:ssh-copy-id B 3.接 ...
- Argument 1 passed to Illuminate\Auth\SessionGuard::login() must be an instance of Illuminate\Contracts\Auth\Authenticatable, instance of App\User given,
使用laravel内置的注册认证系统,注册账号,提示如下错误.Google之后,发现github的一个答案,解决了.分享一下 Argument 1 passed to Illuminate\Auth\ ...
- 搞不清FastCgi与php-fpm之间是个什么样的关系
我在网上查fastcgi与php-fpm的关系,查了快一周了,基本看了个遍,真是众说纷纭,没一个权威性的定义. 网上有的说,fastcgi是一个协议,php-fpm实现了这个协议: 有的说,php-f ...