Revit API判断直线相交关系移动风管
start
//风管对齐
[TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class cmdDuctAlign : IExternalCommand
{
private XYZ GetIntersection(Line line1, Line line2)
{
IntersectionResultArray results; SetComparisonResult result
= line1.Intersect(line2, out results);
//SetComparisonResult.Subset
//SetComparisonResult.Superset
if (SetComparisonResult.Overlap == result)//没有交点,可能是平行,也可以是延长线相交。
throw new InvalidOperationException(
"Overlap");
if (SetComparisonResult.Disjoint == result)//不相交
throw new InvalidOperationException(
"Disjoint");
if (SetComparisonResult.Superset == result)//包含,子集
throw new InvalidOperationException(
"Superset");
if (SetComparisonResult.Subset == result)//交集
throw new InvalidOperationException(
"Subset");
if (results == null || results.Size != )
throw new InvalidOperationException(
"Could not extract line intersection point."); IntersectionResult iResult
= results.get_Item(); return iResult.XYZPoint;
}
public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
{
UIApplication app = commandData.Application;
Document doc = app.ActiveUIDocument.Document;
Selection sel = app.ActiveUIDocument.Selection; SplitButtonData splitButtonData = new SplitButtonData("", "");
PushButton pbtn = new PushButton();
RibbonPanel rpanel = new RibbonPanel();
Transaction ts = new Transaction(doc, "revit");
ts.Start(); IList<Reference> refDucts = sel.PickObjects(ObjectType.Element, "duct");
Duct duct1 = doc.GetElement(refDucts.ElementAt()) as Duct;
Duct duct2 = doc.GetElement(refDucts.ElementAt()) as Duct;
LocationCurve lCurve1 = duct1.Location as LocationCurve;
LocationCurve lCurve2 = duct1.Location as LocationCurve;
XYZ xyz11 = lCurve1.Curve.get_EndPoint();
XYZ xyz12 = lCurve1.Curve.get_EndPoint();
XYZ xyz21 = lCurve2.Curve.get_EndPoint();
XYZ xyz22 = lCurve2.Curve.get_EndPoint();
//判断线段相交关系
Line line1 = Line.get_Bound(xyz11, xyz12);
Line line2 = Line.get_Bound(xyz21, xyz22);
GetIntersection(line1, line2); #region 风管移动 //转化到平面
XYZ xyz1 = new XYZ(xyz11.X, xyz11.Y, );
XYZ xyz2 = new XYZ(xyz12.X, xyz12.Y, );
XYZ xyz3 = new XYZ(xyz21.X, xyz21.Y, );
XYZ xyz4 = new XYZ(xyz22.X, xyz22.Y, );
//找到与直线垂直的向量
XYZ vec1 = xyz2 - xyz1;
XYZ zVec = new XYZ(, , );
XYZ nVec = vec1.CrossProduct(zVec).Normalize();//两条线相交的面对应的向量
TaskDialog.Show("vec", nVec.CrossProduct(zVec).Normalize().ToString());
lCurve2.Move(nVec); #endregion ts.Commit(); return Result.Succeeded;
}
}
url: http://greatverve.cnblogs.com/p/revit-api-line-SetComparisonResult.html
Revit API判断直线相交关系移动风管的更多相关文章
- POJ 1269 Intersecting Lines (判断直线位置关系)
题目链接:POJ 1269 Problem Description We all know that a pair of distinct points on a plane defines a li ...
- [poj] 1066 Treasure Hunt || 判断直线相交
原题 在金字塔内有一个宝藏p(x,y),现在要取出这个宝藏. 在金字塔内有许多墙,为了进入宝藏所在的房间必须把墙炸开,但是炸墙只能炸每个房间墙的中点. 求将宝藏运出城堡所需要的最小炸墙数. 判断点和直 ...
- Revit API 判断一个构件在某个视图中的可见性
查看 Revit API.发现有Element::IsHidden这个方法.通过UI创建一个element,注意要使得这个element在某些视图可见,但是在另一些视图不可见.运行下面的方法,你会发现 ...
- poj3449(判断直线相交)
题目链接:https://vjudge.net/problem/POJ-3449 题意:给出若干几何体,判断每个几何体与其它几何体的相交情况,并依次输出. 思路: 首先要知道的是根据正方形对角线的两个 ...
- POJ 1269 Intersecting Lines【判断直线相交】
题意:给两条直线,判断相交,重合或者平行 思路:判断重合可以用叉积,平行用斜率,其他情况即为相交. 求交点: 这里也用到叉积的原理.假设交点为p0(x0,y0).则有: (p1-p0)X(p2-p0) ...
- Revit API判断是不是柱族模板
OwnerFamily即族模板.获取类别的方法:Document.Settings.Categories.get_Item(BuiltInCategory.OST_Columns); //判断是不是柱 ...
- CC34:判断直线相交
题目 解法 水题,判断斜率.判断截距,ok..... class CrossLine { public: bool checkCrossLine(double s1, double s2, doubl ...
- poj 1127(直线相交+并查集)
Jack Straws Description In the game of Jack Straws, a number of plastic or wooden "straws" ...
- poj 1269 Intersecting Lines(直线相交)
Intersecting Lines Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 8637 Accepted: 391 ...
随机推荐
- 恶意代码分析实战-PE资源提取
场景 1.提取恶意代码中的资源部分内容 思路 存在Loadresource函数的时候说明有一部分内容在资源里. 技术点 Lab1-4 ResourceHacker打开保存资源,载入IDA查看
- WPF使用DataGridComboBoxColumn完成绑定
在使用DataGrid的时候,有时候需要使某些列为ComboBox,这时自然想到使用DataGridComboBoxColumn,但是如果使用的是ItemsSource数据绑定后台的对象,就会发现,这 ...
- win7下PHP+MySQL+CoreSeek中文检索引擎配置
1.Windows下的coreseek安装测试 (64位win7旗舰版) 官方参考:http://www.coreseek.cn/products-install/install_on_windows ...
- Qt 程序等待多长时间执行Sleep
#include <QTime> void MainWindow::Sleep(unsigned int msec) { QTime reachTime=QTime::currentTim ...
- Java中类与类的关系
在java中类和类的关系大致分三种:泛化.关联.依赖. 1. 泛化(Generalization) "XX是一个XX"关系(is a),通常使用的关键词为 extends.impl ...
- CF1064B 【Equations of Mathematical Magic】
题目要求解$a-(a\oplus x)-x=0$的解$x$的个数 移项得$a-x=a\oplus x$ $a$的二进制形式,应该是一个$01$串,异或的过程是不能影响到两个不同的位的,所以我们按位考虑 ...
- SendMessage原理初探
今天跟踪一下SendMessage的实现. 用向导先创建一个Windows application. 向导生成了一个简单的窗口,如下. 在File菜单添加SendMessage,顺便添加一个PostM ...
- hdu 1394 求一个序列的最小逆序数 单点增 区间求和
题目的意思就好比给出一个序列 如:0 3 4 1 2 设逆序数初始n = 0: 由于0后面没有比它小的,n = 0 3后面有1,2 n = 2 4后面有1,2,n = 2+2 = 4: 所以该序列逆序 ...
- #Plugin 环形loading插件
CircleLoader 环形loading插件 1.原生JS,不依赖jquery,zepto 2.前端学习交流群:814798690 案例展示 下载地址 https://github.com/cha ...
- [转] CSSOM视图模式(CSSOM View Module)相关整理
以下就是一些API属性的相关内容,包括兼容性,使用,测试等. 一.Window视图属性 这些属性可以hold住整个浏览器窗体大小.微软则将这些API称为“Screenview 接口”.包括:inner ...