下載app免費領取會員
在Revit里梁的寬和高一般都會有對應的參數(shù),要獲取大多數(shù)情況可以使用GetParameter,
但這個參數(shù)名稱是用戶自己定義的,不同的梁對應的參數(shù)名不一樣,所以可以考慮通過梁的截面Face來獲取
FamilyInstance inst = doc.GetElement(uidoc.Selection.PickObject(ObjectType.Element)) as FamilyInstance;
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)
{
GeometryInstance gins = gobj as GeometryInstance;
if(gins!=null)
{
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 h = Math.Abs(max.Z - min.Z);
double l = max.DistanceTo(min);
double w = Math.Sqrt(l * l - h * h);
MessageBox.Show("H" + Math.Round(h * 304.8).ToString() + "\n" + "W" + Math.Round(w * 304.8).ToString());
break;
}
}
}
}
}
}
本文版權歸腿腿教學網及原創(chuàng)作者所有,未經授權,謝絕轉載。
上一篇:二次開發(fā)教程:WPF 使用net 資源多語言