下载app免费领取会员
在Revit里梁的宽和高一般都会有对应的参数,要获取大多数情况可以使用GetParameter,
但这个参数名称是用户自己定义的,不同的梁对应的参数名不一样,所以可以考虑通过梁的截面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;
}
}
}
}
}
}
本文版权归腿腿教学网及原创作者所有,未经授权,谢绝转载。