当前位置:网站首页>Revit secondary development - get the thickness / length / height of the beam
Revit secondary development - get the thickness / length / height of the beam
2022-07-07 22:22:00 【Hey, hey, hey, hey, hey】
Thickness of beam / length / Height cannot be obtained directly , It can be calculated according to geometric information .
/// <summary>
/// Get beam thickness / wide / length
/// </summary>
/// <param name="inst"></param>
/// <returns></returns>
public double GetBeamThick(FamilyInstance inst)
{
double dThick = 0;
Line loc = (inst.Location as LocationCurve).Curve as Line;
XYZ dir = loc.Direction;
Options opts = new Options();
GeometryElement gelem = inst.get_Geometry(opts);
foreach (GeometryObject gobj in gelem)
{
if (gobj is GeometryInstance)
{
GeometryInstance gins = gobj as GeometryInstance;
GeometryElement ge = gins.GetInstanceGeometry();
foreach (GeometryObject go in ge)
{
Solid solid = go as Solid;
if (solid != null && solid.Volume > 0)
{
foreach (Face face in solid.Faces)
{
XYZ faceDir = face.ComputeNormal(new UV());
if (faceDir.IsAlmostEqualTo(dir) || faceDir.IsAlmostEqualTo(-dir))
{
BoundingBoxUV uvBox = face.GetBoundingBox();
XYZ min = face.Evaluate(uvBox.Min);
XYZ max = face.Evaluate(uvBox.Max);
double height = Math.Abs(max.Z - min.Z);
double length = max.DistanceTo(min);
dThick = Math.Sqrt(length*length-height*height );
break;
}
}
}
}
}
else if (gobj is Solid)
{
Solid solid = gobj as Solid;
if (solid != null && solid.Volume > 0)
{
foreach (Face face in solid.Faces)
{
XYZ faceDir = face.ComputeNormal(new UV());
if (faceDir.IsAlmostEqualTo(dir) || faceDir.IsAlmostEqualTo(-dir))
{
BoundingBoxUV uvBox = face.GetBoundingBox();
XYZ min = face.Evaluate(uvBox.Min);
XYZ max = face.Evaluate(uvBox.Max);
double height = Math.Abs(max.Z - min.Z);
double length = max.DistanceTo(min);
dThick = Math.Sqrt(length*length-height*height);
break;
}
}
}
}
}
return dThick * 304.8;
}
边栏推荐
- Pdf document signature Guide
- [advanced MySQL] index details (I): index data page structure
- 怎样写一个增广矩阵到txt文件中
- 变量与常量
- Kaggle-Titanic
- Codemail auto collation code of visual studio plug-in
- Paint basic graphics with custompaint
- 为什么Win11不能显示秒数?Win11时间不显示秒怎么解决?
- Get the week start time and week end time of the current date
- [interview arrangement] 0211 game engine server
猜你喜欢
How to make agile digital transformation strategy for manufacturing enterprises
嵌入式开发:如何为项目选择合适的RTOS?
三元表达式、各生成式、匿名函数
The latest Android interview collection, Android video extraction audio
Application practice | the efficiency of the data warehouse system has been comprehensively improved! Data warehouse construction based on Apache Doris in Tongcheng digital Department
Px4 autonomous flight
Two kinds of updates lost and Solutions
[azure microservice service fabric] how to transfer seed nodes in the service fabric cluster
Pdf document signature Guide
648. Word replacement
随机推荐
DBSync新增对MongoDB、ES的支持
Use json Stringify() to realize deep copy, be careful, there may be a huge hole
The whole network "chases" Zhong Xuegao
vite Unrestricted file system access to
OpenGL configuration vs2019
反爬通杀神器
[open source] Net ORM accessing Firebird database
使用 CustomPaint 绘制基本图形
Build your own website (18)
Blender exchange group, welcome to the water group ~
Jerry's manual matching method [chapter]
建立自己的网站(18)
PDF文档签名指南
PKPM 2020软件安装包下载及安装教程
Jerry's key to initiate pairing [chapter]
海外代理推荐
L2: current situation, prospects and pain points of ZK Rollup
Typescript TS basic knowledge type declaration
Welcome to CSDN markdown editor
This experimental syntax requires enabling the parser plugin: ‘optionalChaining‘