PlanarFace.Normal取得向量。IsAlmostEqualTo判断向量是否一致。

// ===============================================================
// helper function: given a solid, find a planar 
//Extrusion实体,给一个实体,给一个方向,找到与此方向一致的面。
// face with the given normal (version 2)
// this is a slightly enhaced version of the previous 
// version and checks if the face is on the given reference plane.
// ===============================================================
PlanarFace findFace(Application app, Extrusion pBox, XYZ normal, ReferencePlane refPlane)
{
    // get the geometry object of the given element
    //
    Options op = new Options();
    op.ComputeReferences = true;
    GeometryObjectArray geomObjs = pBox.get_Geometry(op).Objects;     // loop through the array and find a face with the given normal
    //
    foreach (GeometryObject geomObj in geomObjs)
    {
        if (geomObj is Solid)  // solid is what we are interested in.
        {
            Solid pSolid = geomObj as Solid;
            FaceArray faces = pSolid.Faces;
            foreach (Face pFace in faces)
            {
                PlanarFace pPlanarFace = (PlanarFace)pFace;
                // check to see if they have same normal
                //face.Normal是面的向量。IsAlmostEqualTo();
                if ((pPlanarFace != null) && pPlanarFace.Normal.IsAlmostEqualTo(normal))
                {
                    // additionally, we want to check if the face is on the reference plane
                    //还要判断面是否在参考平面上。
                    XYZ p0 = refPlane.BubbleEnd;//终点?
                    XYZ p1 = refPlane.FreeEnd;//起点?
                    Line pCurve = app.Create.NewLineBound(p0, p1);
                    if (pPlanarFace.Intersect(pCurve) == SetComparisonResult.Subset)//子集
                    {
                        return pPlanarFace; // we found the face
                    }
                }
            }
        }         // will come back later as needed.
        //
        //else if (geomObj is Instance)
        //{
        //}
        //else if (geomObj is Curve)
        //{
        //}
        //else if (geomObj is Mesh)
        //{
        //}
    }     // if we come here, we did not find any.
    return null;
}

url:http://greatverve.cnblogs.com/p/revit-family-api-find-face.html

Revit Family API 找到实体某一方向上的面。的更多相关文章

  1. Revit MEP API找到连接器连接的连接器

    通过conn.AllRefs;可以找到与之连接的连接器. //连接器连接的连接器 [TransactionAttribute(Autodesk.Revit.Attributes.Transaction ...

  2. Revit Family API 添加几何实体

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

  3. Revit Family API 添加对齐

    没测试成功,留待以后研究. [TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)] ; ; i < nV ...

  4. Revit 2015 API 的全部变化和新功能

    这里从SDK的文章中摘录出全部的API变化.主要是希望用户用搜索引擎时能找到相关信息: Major changes and renovations to the Revit API APIchange ...

  5. Revit Family API 添加类型

    FamilyManager.NewType("");添加新类型,然后设置参数,就是为新类型设置参数. [TransactionAttribute(Autodesk.Revit.At ...

  6. Revit Family API 创建参考平面

    使用API来编辑族时,使用doc.FamilyCreate.NewReferencePlane();创建参考平面. )         {  ];         }         // canno ...

  7. Revit Family API 添加参数与尺寸标注

    使用FamilyManager其他的与普通添加参数与标注没区别. [TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Man ...

  8. Revit API找到风管穿过的墙(当前文档和链接文档)

    start [Transaction(TransactionMode.Manual)] [Regeneration(RegenerationOption.Manual)] public class c ...

  9. 8.2 使用Fluent API进行实体映射【Code-First系列】

    现在,我们来学习怎么使用Fluent API来配置实体. 一.配置默认的数据表Schema Student实体 using System; using System.Collections.Gener ...

随机推荐

  1. py-faster-rcnn代码阅读3-roidb.py

    roidb是比较复杂的数据结构,存放了数据集的roi信息.原始的roidb来自数据集,在trian.py的get_training_roidb(imdb)函数进行了水平翻转扩充数量,然后prepare ...

  2. 如何使用optipng压缩png图片

    OptiPNG – Google推荐的png图片无损压缩工具下载及使用教程 2014年08月24日 实用软件 暂无评论 optipng png图片无损压缩工具介绍: optipng png图片无损压缩 ...

  3. 如何将java项目转化为web项目

    1.修改工程文件 找到项目工作空间目录,打开.project文件,找到:<natures> </natures>代码段,在代码段中加入如下内容并保存:<nature> ...

  4. shell脚本 ------ 输出带颜色的字体

    shell脚本中echo显示内容带颜色显示,echo显示带颜色,需要使用参数-e 格式如下: echo -e “\033[字背景颜色:文字颜色m字符串\033[0m” 例如: echo -e “\03 ...

  5. bootstrap 引用注意事项

    2014年6月8日 13:35:31 bootstrap 提供了cdn服务,在引用css,js的时候注意先后顺序,firebug就不会报错 <script src="http://cd ...

  6. java注解方式解析xml格式

    注解类和字段方式: @XStreamAlias("message") 别名注解 注解集合: @XStreamImplicit(itemFieldName="part&qu ...

  7. CSS3实现图片木桶布局

    CSS3实现图片木桶布局 效果图: 代码如下,复制即可使用: <!DOCTYPE html> <script> window.navigator.appVersion.inde ...

  8. ERP客户关系渠管理添加和修改联系人(二十一)

    树形结构treeview 前端代码: <form id="form1" runat="server"> <div> <asp:Tr ...

  9. .NET Core 项目经验总结:项目结构介绍 (一)

    原文地址(个人博客):http://www.gitblogs.com/Blogs/Details?id=384b4249-15e4-41bf-9cf7-44a3e1e51885 作为一个.NET We ...

  10. 远程执行shell

    目前我的需求是在我的hadoop集群搭建起来前,能定时做一下简易指标的监控,目前我的方案就是在我的server机上,定时执行远程脚本出指标数据,然后通过python脚本发送邮件. 远程执行脚本如下: ...