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. order by 字段自动填写脚本

    新版 firefox 中的 hackbar 没有 order by 字段填写, 所以就有了这个: =begin pod sql注入中自动输出order by 的位数 =end pod sub MAIN ...

  2. git使用常用命令

    第一部分:个人整理部分(读<Git教程By廖雪峰.pdf>笔记) /* 配置全局参数 */git config --global user.name "username" ...

  3. Mysql读写分离-Amoeba Proxy

    参考:http://www.linuxidc.com/Linux/2015-10/124115.htm 一个完整的MySQL读写分离环境包括以下几个部分: 应用程序client database pr ...

  4. Android实现手机摄像头的自动对焦

    如何实现Android相机的自动对焦,而且是连续自动对焦的.当然直接调用系统相机就不用说了,那个很简单的.下面我们主要来看看如如何自己实现一个相机,并且实现自动连续对焦. 代码如下: public c ...

  5. VM workstation 与 VM vSphere的区别 [转载]

    在学完vSphere后,想起了VMware Workstation.这两个都是虚拟化的东西,这两者到底有什么本质的不同呢?顺着我的思路我开始将所学过的进行检索期望从中寻到一丝半点的线索.很快大脑中建立 ...

  6. Docker 简介与shell操作使用

    一.Docker概述 1.Docker简介        Docker是一个开源的应用容器引擎:是一个轻量级容器技术:Docker支持将软件编译成一个镜像:然后在镜像中各种软件做好配置,将镜像发布出去 ...

  7. vs2010 打包安装

    https://jingyan.baidu.com/article/b7001fe184e4e50e7382dd4e.html 1 建立安装项目2 要安装的文件都添加到应用程序文件夹3 在应用程序文件 ...

  8. relay.index' not found

    主备搭建时,备库上执行以下语句报错: (root@localhost:mysql.sock)[(none)]>change master to master_host='192.168.0.57 ...

  9. Windows下PHP多线程扩展pthreads的安装

    pthreads扩展安装步骤 1.查看phpinfo() 获取PHP版本号及位数(x86表示32位,x64表示64位).编译器版本.PHP配置文件加载所在位置等.如下图所示: 2.pthreads扩展 ...

  10. 在 Vim 中优雅地查找和替换

    原文更好看链接http://harttle.com/2016/08/08/vim-search-in-file.html 总有人问我 Vim 中能不能查找,当然能!而且是超级强的查找! 这篇文章来详细 ...