首页 > Windows开发 > 详细

Revit Family API 找到实体某一方向上的面。

时间:2014-02-18 15:52:34      阅读:387      评论:0      收藏:0      [点我收藏+]
PlanarFace.Normal取得向量。IsAlmostEqualTo判断向量是否一致。
bubuko.com,布布扣
// ===============================================================
// helper function: given a solid, find a planar 
//Extrusion实体,给一个实体,给一个方向,找到与此方向一致的面。
// face with the given normal (version 2)
// this is a slightly enhaced version of the previous 
// version and checks if the face is on the given reference plane.
// ===============================================================
PlanarFace findFace(Application app, Extrusion pBox, XYZ normal, ReferencePlane refPlane)
{
    // get the geometry object of the given element
    
//
    Options op = new Options();
    op.ComputeReferences = true;
    GeometryObjectArray geomObjs = pBox.get_Geometry(op).Objects;

    // loop through the array and find a face with the given normal
    
//
    foreach (GeometryObject geomObj in geomObjs)
    {
        if (geomObj is Solid)  // solid is what we are interested in.
        {
            Solid pSolid = geomObj as Solid;
            FaceArray faces = pSolid.Faces;
            foreach (Face pFace in faces)
            {
                PlanarFace pPlanarFace = (PlanarFace)pFace;
                // check to see if they have same normal
                
//face.Normal是面的向量。IsAlmostEqualTo();
                if ((pPlanarFace != null) && pPlanarFace.Normal.IsAlmostEqualTo(normal))
                {
                    // additionally, we want to check if the face is on the reference plane
                    
//还要判断面是否在参考平面上。
                    XYZ p0 = refPlane.BubbleEnd;//终点?
                    XYZ p1 = refPlane.FreeEnd;//起点?
                    Line pCurve = app.Create.NewLineBound(p0, p1);
                    if (pPlanarFace.Intersect(pCurve) == SetComparisonResult.Subset)//子集
                    {
                        return pPlanarFace; // we found the face
                    }
                }
            }
        }

        // will come back later as needed.
        
//
        
//else if (geomObj is Instance)
        
//{
        
//}
        
//else if (geomObj is Curve)
        
//{
        
//}
        
//else if (geomObj is Mesh)
        
//{
        
//}
    }

    // if we come here, we did not find any.
    return null;
}
bubuko.com,布布扣
url:http://greatverve.cnblogs.com/p/revit-family-api-find-face.html

Revit Family API 找到实体某一方向上的面。

原文:http://www.cnblogs.com/greatverve/p/revit-family-api-find-face.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!