系统族,可以直接转化为对应的类(Wall,Duct)然后取得几何信息,普通族需要转化为FamilyInstance

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms; using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes; using Autodesk.Revit.DB; [TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class GetWallBFace : IExternalCommand
{
  public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
  {     UIApplication app = commandData.Application;
    Document doc = app.ActiveUIDocument.Document;     //select a wall      
    Reference ref1 = app.ActiveUIDocument.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element, "Please pick a wall");
    Element elem = doc.GetElement(ref1);
    Wall wall = elem as Wall;     Options opt = new Options();
    opt.ComputeReferences = true;
    opt.DetailLevel = Autodesk.Revit.DB.DetailLevels.Medium;     GeometryElement e = wall.get_Geometry(opt);//系统族的Geometry可以直接获取     foreach (GeometryObject obj in e.Objects)
    {
      Solid solid = obj as Solid;
      if (solid != null && solid.Faces.Size > )//实体必须做这样的判断,因为有可能是假的。        
        FindBottomFace(solid);
    }     return Result.Succeeded;
  }   Face FindBottomFace(Solid solid)
  {
    PlanarFace pf = null;
    foreach (Face face in solid.Faces)
    {
      pf = face as PlanarFace;//转化为立面平面
      if (null != pf)
      {
        //判断向量的方法:转化为Normal然后以绝对值判断(0,0,-1)
        if (Math.Abs(pf.Normal.X) < 0.01 && Math.Abs(pf.Normal.Y) < 0.01 && pf.Normal.Z < )
        {
          TaskDialog.Show("Wall Bottom Face", "Area is " + pf.Area.ToString() + "; Origin = (" + pf.Origin.X.ToString() + "  " + pf.Origin.Y.ToString() + "  " + pf.Origin.Z.ToString() + ")");           break;
        }
      }
    }
    return pf;
  } } [TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class GetColumnBottomFace : IExternalCommand
{
  public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
  {     UIApplication app = commandData.Application;
    Document doc = app.ActiveUIDocument.Document;     //select a column      
    Reference ref1 = app.ActiveUIDocument.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element, "Please pick a column");
    Element elem = doc.GetElement(ref1);
    FamilyInstance column = elem as FamilyInstance;//柱是族实例     Options opt = new Options();
    opt.ComputeReferences = true;
    opt.DetailLevel = Autodesk.Revit.DB.DetailLevels.Medium;     GeometryElement e = column.get_Geometry(opt);     foreach (GeometryObject obj in e.Objects)
    {
      //被切割的族有Solid
      if (obj is Solid)
      {
        Solid solid = obj as Solid;
        FindBottomFace(solid);
      }
      else if (obj is GeometryInstance)//取得族实例几何信息的方法
      {
        GeometryInstance geoInstance = obj as GeometryInstance;
        GeometryElement geoElement = geoInstance.GetInstanceGeometry();
        foreach (GeometryObject obj2 in geoElement.Objects)
        {
          if (obj2 is Solid)
          {
            Solid solid2 = obj2 as Solid;
            if (solid2.Faces.Size > )
              FindBottomFace(solid2);
          }
        }
      }
    }
    return Result.Succeeded;
  }   Face FindBottomFace(Solid solid)
  {
    PlanarFace pf = null;
    foreach (Face face in solid.Faces)
    {
      pf = face as PlanarFace;
      if (null != pf)
      {
        if (Math.Abs(pf.Normal.X) < 0.01 && Math.Abs(pf.Normal.Y) < 0.01 && pf.Normal.Z < )
        {
          TaskDialog.Show("column Bottom Face", "Area is " + pf.Area.ToString() + "; Origin = (" + pf.Origin.X.ToString() + "  "  +pf.Origin.Y.ToString() + "  " + pf.Origin.Z.ToString() + ")");
          
          break;
        }
      }
    }
    return pf;
  } } [TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class GetWallBottomFace : IExternalCommand
{
  public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
  {
    UIApplication app = commandData.Application;
    Document doc = app.ActiveUIDocument.Document;     //select a wall
    Reference ref1 = app.ActiveUIDocument.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element, "Pick a wall");
    Element elem = doc.GetElement(ref1);
    Wall wall = elem as Wall;     Options opt = new Options();
    opt.ComputeReferences = true;
    opt.DetailLevel = Autodesk.Revit.DB.DetailLevels.Medium;     GeometryElement e = wall.get_Geometry(opt);
    foreach (GeometryObject obj in e.Objects)
    {
      Solid solid = obj as Solid;
      if (solid != null && solid.Faces.Size > )
      {
        FindBottomFaces(solid);
      }
    }     return Result.Succeeded;
  }   Face FindBottomFaces(Solid solid)
  {
    PlanarFace pf = null;
    foreach (Face face in solid.Faces)
    {
      pf = face as PlanarFace;
      if(null != pf)
      {
        if(Math.Abs(pf.Normal.X) < 0.01 && Math.Abs(pf.Normal.Y) < 0.01 && pf.Normal.Z < )
        {
          TaskDialog.Show("the bottom face's area is ",  pf.Area.ToString());
        }
      }
    }
    return pf;
  }
}

end

Revit API取得系统族普通族几何信息的方法的更多相关文章

  1. Revit API遍历系统族布置喷头

    系统族可以通过内参遍历,遍历出来是个FamilySymbol喷头属于系统族,但不能通过NewDuct();类似这样的方法布置.必须使用 NewFamilyInstance() );           ...

  2. Revit API判断是不是柱族模板

    OwnerFamily即族模板.获取类别的方法:Document.Settings.Categories.get_Item(BuiltInCategory.OST_Columns); //判断是不是柱 ...

  3. Revit API 加载族并生成实例图元

    在Revit API中加载族可以使用Doc.LoadFamily方法,传入要加载的族文件路径名,但是这种方式有一种缺点,就是如果族文件在当前工程中没有加载的话则返回成功,如果已经加载过,则返回失败,也 ...

  4. TCP/IP协议族(一) HTTP简介、请求方法与响应状态码

    接下来想系统的回顾一下TCP/IP协议族的相关东西,当然这些东西大部分是在大学的时候学过的,但是那句话,基础的东西还是要不时的回顾回顾的.接下来的几篇博客都是关于TCP/IP协议族的,本篇博客就先简单 ...

  5. ASP.NET Web API路由系统:路由系统的几个核心类型

    虽然ASP.NET Web API框架采用与ASP.NET MVC框架类似的管道式设计,但是ASP.NET Web API管道的核心部分(定义在程序集System.Web.Http.dll中)已经移除 ...

  6. ASP.NET Web API路由系统:Web Host下的URL路由

    ASP.NET Web API提供了一个独立于执行环境的抽象化的HTTP请求处理管道,而ASP.NET Web API自身的路由系统也不依赖于ASP.NET路由系统,所以它可以采用不同的寄宿方式运行于 ...

  7. windows API 统计系统字体

    最近工作中遇到一个需求,需要统计当前系统中包含的所有字体.在网上逛了一圈后发现了EnumFontFamiliesEx这个API好像就可以实现这个功能.这里将自己对这个API的理解做一个记录,算是对这块 ...

  8. 【Revit API】梁构件支座检查算法

    一.前言         应该是第二次写关于Revit API的博文了.虽然在BIM企业中工作,从事桌面BIM软件开发,但是我是不怎么喜欢写Revit API相关的代码.平时更多的是在写界面展示,架构 ...

  9. Revit API 判断一个构件在某个视图中的可见性

    查看 Revit API.发现有Element::IsHidden这个方法.通过UI创建一个element,注意要使得这个element在某些视图可见,但是在另一些视图不可见.运行下面的方法,你会发现 ...

随机推荐

  1. linux笔记_day09

    1.运算器.控制器.存储器.输入输出(IO) 地址总线:内存寻址 数据总线:传输数据 控制总线:控制指令 寄存器:cpu暂时存储器 2.系统设定 默认输出设备:标准输出,STDOUT,1(描述符)(显 ...

  2. apache本地配置多域名(wampserver本地配置多域名)

    我们在本地开发时,一般是在浏览器输入 http://localhost/项目文件夹名来测试网页文件,你有没有想过在本地在浏览器输入你自己设定的一个域名进入项目文件夹中去,本地配置多域名可以测试二级域名 ...

  3. Ibatis.Net 动态SQL语句学习(六)

    在学习动态SQL语句之前,首先必须对条件查询有一定了解,先来学习如何向IBatis.Net的映射文件里传入参数吧. 一.条件查询 1.传递单个参数 如根据Id查询: <select id=&qu ...

  4. jenkins主从从服务器发布脚本执行成功但总提示失败 FATAL: Remote call on XXXX failed

    主从jenkins当调用 slave 执行编译脚本后提示如下错误,找了半天怎么也没有问题,后来忽然发现slave上java的版本和master不同,一个 1.8 一个 1.10,将slave降回1.8 ...

  5. shell升级完整记录

    [root@localhost bash-4.3.30]# cat Makefile |grep prefix prefix = /usr/local exec_prefix = ${prefix} ...

  6. c++中的前置声明

    引用google c++编码规范: When you include a header file you introduce a dependency that will cause your cod ...

  7. #JS 前端javascript规范文档

    一.规范目的 为提高团队协作效率,便于前端后期优化维护,输出高质量的文档. 二.基本准则 符合web标准,结构表现行为分离,兼容性优良.页面性能方面,代码要求简洁明了有序, 尽可能的减小服务器负载,保 ...

  8. NET 架构指南频道

    NET 架构指南频道 微软在Visual Studio 2017 正式发布的时候也上线了一个参考应用https://github.com/dotnet/eShopOnContainers , 最近微软 ...

  9. 【AtCoder】ARC092

    C - 2D Plane 2N Points 把能连边的点找到然后跑二分图匹配即可 #include <bits/stdc++.h> #define fi first #define se ...

  10. shiro双realm验证

    假设现在有这样一种需求:存在两张表user和admin,分别记录普通用户和管理员的信息.并且现在要实现普通用户和管理员的分开登录,即需要两个Realm——UserRealm和AdminRealm,分别 ...