Revit API取得系统族普通族几何信息的方法
系统族,可以直接转化为对应的类(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取得系统族普通族几何信息的方法的更多相关文章
- Revit API遍历系统族布置喷头
系统族可以通过内参遍历,遍历出来是个FamilySymbol喷头属于系统族,但不能通过NewDuct();类似这样的方法布置.必须使用 NewFamilyInstance() ); ...
- Revit API判断是不是柱族模板
OwnerFamily即族模板.获取类别的方法:Document.Settings.Categories.get_Item(BuiltInCategory.OST_Columns); //判断是不是柱 ...
- Revit API 加载族并生成实例图元
在Revit API中加载族可以使用Doc.LoadFamily方法,传入要加载的族文件路径名,但是这种方式有一种缺点,就是如果族文件在当前工程中没有加载的话则返回成功,如果已经加载过,则返回失败,也 ...
- TCP/IP协议族(一) HTTP简介、请求方法与响应状态码
接下来想系统的回顾一下TCP/IP协议族的相关东西,当然这些东西大部分是在大学的时候学过的,但是那句话,基础的东西还是要不时的回顾回顾的.接下来的几篇博客都是关于TCP/IP协议族的,本篇博客就先简单 ...
- ASP.NET Web API路由系统:路由系统的几个核心类型
虽然ASP.NET Web API框架采用与ASP.NET MVC框架类似的管道式设计,但是ASP.NET Web API管道的核心部分(定义在程序集System.Web.Http.dll中)已经移除 ...
- ASP.NET Web API路由系统:Web Host下的URL路由
ASP.NET Web API提供了一个独立于执行环境的抽象化的HTTP请求处理管道,而ASP.NET Web API自身的路由系统也不依赖于ASP.NET路由系统,所以它可以采用不同的寄宿方式运行于 ...
- windows API 统计系统字体
最近工作中遇到一个需求,需要统计当前系统中包含的所有字体.在网上逛了一圈后发现了EnumFontFamiliesEx这个API好像就可以实现这个功能.这里将自己对这个API的理解做一个记录,算是对这块 ...
- 【Revit API】梁构件支座检查算法
一.前言 应该是第二次写关于Revit API的博文了.虽然在BIM企业中工作,从事桌面BIM软件开发,但是我是不怎么喜欢写Revit API相关的代码.平时更多的是在写界面展示,架构 ...
- Revit API 判断一个构件在某个视图中的可见性
查看 Revit API.发现有Element::IsHidden这个方法.通过UI创建一个element,注意要使得这个element在某些视图可见,但是在另一些视图不可见.运行下面的方法,你会发现 ...
随机推荐
- mysql high availability 概述
一.什么是高可用性 1.可用性是指服务不间断运转的时间,通常用百分比来表示,例如 99.999%表示每年最多允许5分钟的宕机时间 2.可用性的效果和开销比例呈线性增长 3.可用性的意义往往也不尽相同, ...
- win7下PHP+MySQL+CoreSeek中文检索引擎配置
1.Windows下的coreseek安装测试 (64位win7旗舰版) 官方参考:http://www.coreseek.cn/products-install/install_on_windows ...
- laravel 网站地图轮子
https://github.com/Laravelium/laravel-sitemap add the following to your composer.json file : For Lar ...
- SCU 4444: Travel(最短路)
Travel The country frog lives in has n towns which are conveniently numbered by 1,2,…,n . Among n(n− ...
- 20165330《网络对抗技术》Exp0 Kali安装
Kali安装 下载地址 Kali官网 VMware 安装步骤 参考在虚拟机中安装kali linux 安装Kali Linux的镜像和VMware 打开VMware,选择文件-新建虚拟机,出现对话框选 ...
- Java编程的逻辑 (36) - 泛型 (中) - 解析通配符
本系列文章经补充和完善,已修订整理成书<Java编程的逻辑>,由机械工业出版社华章分社出版,于2018年1月上市热销,读者好评如潮!各大网店和书店有售,欢迎购买,京东自营链接:http:/ ...
- NET-知识点:C#中Equals和==比较
第一.相等性比较 其实这个问题的的本质就是C#的相等比较,相等比较可以分两类: 1.引用相等性,引用相等性指两个对象引用均引用同一基础对象. 2.值相等性,值相等性指两个对象包含相同的一个或多个值,其 ...
- hdu 1690 构图后Floyd 数据很大
WA了好多次... 这题要用long long 而且INF要设大一点 Sample Input2 //T1 2 3 4 1 3 5 7 //L1-L4 C1-C4 距离和花费4 2 //结点数 询问次 ...
- VisualSVN Server搭建SVN服务器<转>
使用 VisualSVN Server来搭建本地的代码管理库是非常方便的.svn的那些“检查修改”.“代码版本自由回滚”.“版本日志”等等很多比较牛逼的功能. 在开发当中可谓是理想的开发助手.而且人脑 ...
- 【测试工具】http协议调试利器fiddler使用教程
转自:http协议调试利器fiddler使用教程http://bbs.phpchina.com/thread-207418-1-1.html Fiddler真乃神器!它和市面上常见的很多web调试器. ...