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. ...
随机推荐
- TAU调研咨询
厦门宇能科技有限公司 GPRS-RTU/DTU.3/4G路由器.无线远程抄表.管网监控 咨询电话:0592-5710250 2017-07-04 9:36:16 您好,欢迎光临.请问有什么可以帮到您? ...
- Dhaka2011
Dhaka2011 A - Binary Matrix 题目描述:有一个\(n \times m\)的\(01\)矩阵,这一矩阵第一行和最后一行是相邻的,第一列和最后一列是相邻的,现在每次可以交换相邻 ...
- jexus配置支持Owin
vi打开配置文件,加一行 OwinMain=xxx.dll ###################### # Web Site: Default ########################### ...
- Objective-C 与JAVA的SHA1/HmacSHA1加密算法实现
最近研究IOS手机上登录的功能.由于加密方式使用SHA1算法.网上也没找到直接的例子,最终参照StackoverFlow上的大神,完成了加密实现. 先上代码: //HmacSHA1加密: +(NSSt ...
- cube-ui
cube-ui 新官网:https://didi.github.io/cube-ui/#/zh-CN
- angular有关网站
angular官网 https://v2.angular.cn/docs/ts/latest/ angular更新信息https://github.com/angular/angular/blob/m ...
- UFLDL 教程学习笔记(一)
ufdl的新教程,从基础学起.第一节讲的是线性回归.主要目的是熟悉目标函数,计算梯度和优化. 按着教程写完代码后,总是编译出错,一查是mex的原因,实在不想整了. 这位博主用的是向量,比较简洁:htt ...
- python日常
1.远程访问远程访问Jupyter Notebook,本地浏览器不能打开,先查了防火墙的状态,然后将设置的端口进行allow,网址,仍然拒绝链接,而后通过远程访问Jupyter Notebook,然后 ...
- maven-replacer-plugin 静态资源版本号解决方案(css/js等)
本文介绍如何使用 maven 的 com.google.code.maven-replacer-plugin 插件来自动添加版本号,防止浏览器缓存. 目录 1.解决方案 2.原始文件和最终生成效果 3 ...
- php中empty()、isset()、is_null()和变量本身的布尔判断区别
<?php//预定义变量数组:空字符,字符0,数组0,null,布尔false,空数组$arr_var = array('', '0', 0, null, false, array()); fo ...