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

  1. // ===============================================================
  2. // helper function: given a solid, find a planar 
  3. //Extrusion实体,给一个实体,给一个方向,找到与此方向一致的面。
  4. // face with the given normal (version 2)
  5. // this is a slightly enhaced version of the previous 
  6. // version and checks if the face is on the given reference plane.
  7. // ===============================================================
  8. PlanarFace findFace(Application app, Extrusion pBox, XYZ normal, ReferencePlane refPlane)
  9. {
  10.     // get the geometry object of the given element
  11.     //
  12.     Options op = new Options();
  13.     op.ComputeReferences = true;
  14.     GeometryObjectArray geomObjs = pBox.get_Geometry(op).Objects;
  15.  
  16.     // loop through the array and find a face with the given normal
  17.     //
  18.     foreach (GeometryObject geomObj in geomObjs)
  19.     {
  20.         if (geomObj is Solid)  // solid is what we are interested in.
  21.         {
  22.             Solid pSolid = geomObj as Solid;
  23.             FaceArray faces = pSolid.Faces;
  24.             foreach (Face pFace in faces)
  25.             {
  26.                 PlanarFace pPlanarFace = (PlanarFace)pFace;
  27.                 // check to see if they have same normal
  28.                 //face.Normal是面的向量。IsAlmostEqualTo();
  29.                 if ((pPlanarFace != null) && pPlanarFace.Normal.IsAlmostEqualTo(normal))
  30.                 {
  31.                     // additionally, we want to check if the face is on the reference plane
  32.                     //还要判断面是否在参考平面上。
  33.                     XYZ p0 = refPlane.BubbleEnd;//终点?
  34.                     XYZ p1 = refPlane.FreeEnd;//起点?
  35.                     Line pCurve = app.Create.NewLineBound(p0, p1);
  36.                     if (pPlanarFace.Intersect(pCurve) == SetComparisonResult.Subset)//子集
  37.                     {
  38.                         return pPlanarFace; // we found the face
  39.                     }
  40.                 }
  41.             }
  42.         }
  43.  
  44.         // will come back later as needed.
  45.         //
  46.         //else if (geomObj is Instance)
  47.         //{
  48.         //}
  49.         //else if (geomObj is Curve)
  50.         //{
  51.         //}
  52.         //else if (geomObj is Mesh)
  53.         //{
  54.         //}
  55.     }
  56.  
  57.     // if we come here, we did not find any.
  58.     return null;
  59. }

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. Linux那些事儿之我是Hub(大结局)挂起自动化【转】

    转自:http://blog.csdn.net/fudan_abc/article/details/1805471 目睹了当今大学校园的素质流氓化,kiss公开化,消费白领化,上课梦游化,逃课普遍化, ...

  2. struct termios结构体详解

    一.数据成员 termios 函数族提供了一个常规的终端接口,用于控制非同步通信端口. 这个结构包含了至少下列成员:tcflag_t c_iflag;      /* 输入模式 */tcflag_t ...

  3. MongoDB 3.x 安装及权限验证

    1.首先在网上下载MongoDB的安装包,我这边使用的是3.2版本: 2.安装MongoDB安装程序,安装完成后设置环境变量,我这边的安装路径是:“C:\Program Files\MongoDB\S ...

  4. springboot整合Thymeleaf模板引擎

    引入依赖 需要引入Spring Boot的Thymeleaf启动器依赖. <dependency> <groupId>org.springframework.boot</ ...

  5. Python黑魔法

    1. 赋值 In [1]: x = 1 ...: y = 21 ...: print x, y ...: ...: x, y = y, x ...: print x, y 1 21 21 1 2. 列 ...

  6. 使用html+css+js实现弹球游戏

    使用html+css+js实现弹球游戏 效果图: 代码如下,复制即可使用: <!doctype html> <head> <style type="text/c ...

  7. TcxGrid 内容 行高度

  8. Python3.6安装OpenCV

    1.安装依赖 pip install --upgrade setuptools pip install numpy Matplotlib -i https://mirrors.aliyun.com/p ...

  9. zabbix】问题 Time zone for PHP is not set (configuration parameterdate.timezone)

    https://blog.csdn.net/jing875480512/article/details/79002404

  10. Codeforces 486E LIS of Sequence

    LIS of Sequence 我们先找出那些肯定不会再LIS里面. 然后我们从前往后扫一次, 当前位置为 i , 看存不存在一个 j 会在lis上并且a[ j ] > a[ i ], 如果满足 ...