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 ...
随机推荐
- mysql_存储过程_后一行减去前一行
DELIMITER $$ /*统计单个用户登录次数的存过 @times_count int 返回值 @i 记录行号的变量 初始值为0 @temp 记录时间差的变量 @total 记录登录次数的变量 初 ...
- mongoexport导出csv中文乱码
在用mongoexport导出csv文件时,发现数据库中的中文在excel中都显示为乱码,用notepad打开则正常. 解决办法: 在notepad中,将编码格式改为UTF-8,保存,再用excel打 ...
- Linux sleep命令
Linux sleep命令可以用来将目前动作延迟一段时间. 使用权限:所有使用者. 语法 sleep [--help] [--version] number[smhd] 参数说明: --help : ...
- NEERC Southern Subregional 2011
NEERC Southern Subregional 2011 A - Bonnie and Clyde solution 双指针搞搞就好. 时间复杂度:\(O(n)\) B - Building F ...
- 安装Scrapy遇到的坑
安装过程怕是要吐血,架梯子等等结果被setuptools的版本给坑了. 参考网址: http://blog.csdn.net/YHYR_YCY/article/details/78876148 htt ...
- java多线程计算和
如题:如何利用多线程实现1~1000000000的和 本文利用Callable可以返回值的特性,并将执行结果用CompletionService进行存储,最后将分步值累加. import java.u ...
- !!!sql_mode=only_full_group_by配置
Expression #7 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'invoicecer ...
- Android 5.0 行为变更
Android 5.0 除了提供诸多新特性和功能外,还对系统和 API 行为做出了各种变更.本文重点介绍您应该了解并在开发应用时加以考虑的一些主要变更. 如果您之前发布过 Android 应用,请注意 ...
- 移动端console.log()调试
在微信或app进行开发的时候,没法直接查看console.log的输出内容,调试起来简直太痛苦了. 1.笨笨的方法 fiddler抓请求:追加dom节点,显示调试信息. var div =docume ...
- Web Automation with Selenium (C#)
Web Automation is a quite regular task nowadays, scripting for repeated operations and testing. Sele ...