Face Edge EdgeProxy

Top  Previous  Next

As far as I can tell the EdgeProxy will give you details of where the edge is in the Assembly into which the Part has been inserted.


    // Get the surface bodies from the occurrence...

    CComPtr<SurfaceBodies> pSurfaceBodies;

    hRes = pThisCompOcc->get_SurfaceBodies(&pSurfaceBodies);


    WalertBoxW (L"Occurrence 1 has %d surface bodies\n",pSurfaceBodies->Count);


    // Get the first surface body from the component definition.

    // (There should only ever be one surface body.)

    CComPtr<SurfaceBody> pBody;

    hRes = pSurfaceBodies->get_Item(1, &pBody);


    // Get the shells from the body.

    CComPtr<FaceShells> pShells;

    hRes = pBody->get_FaceShells(&pShells);


    WalertBoxW (L"The surface body has has %d shells\n",pShells->Count) ;


    // Enumerate through the shells.

    long shellCount = 1;

    CComPtr<FaceShell> pShell;

    for (;(hRes = pShells->get_Item(shellCount, &pShell)) == S_OK; pShell.Release())


        TRACE (L"  Shell %d\n", shellCount);


        // Increment the counter and print the current value.



        // Get the faces from the shell.

        CComPtr<Faces> pFaces;

        hRes = pShell->get_Faces(&pFaces);


        // Enumerate through the faces of the current shell.

        long faceCount = 1;

        CComPtr<Face> pFace;

        for (;(hRes = pFaces->get_Item(faceCount, &pFace)) == S_OK;pFace.Release())


            // Increment the counter and print the current value.


            TRACE (L"    Face %d ", faceCount);


            CComPtr <Edges> pEdges  ;

            pFace->get_Edges (&pEdges) ;

            TRACE ("     has %d edges\n",pEdges->Count) ;

            for (long e = 1 ; e <= pEdges->Count ; e++) {

                CComPtr <Edge> pEdge  ;

                pEdges->get_Item (e,&pEdge) ;


                CComQIPtr<EdgeProxy> pEdgeProxy  ;

                pThisCompOcc->CreateGeometryProxy (pEdge,(IDispatch**)&pEdgeProxy) ;


                CComPtr<Vertex> pStartVertex  ;

                pEdgeProxy->get_StartVertex (&pStartVertex) ;


                CComPtr<Point> pStartPoint  ;

                pStartVertex->get_Point (&pStartPoint) ;


                TRACE ("     %.1f %.1f %.1f\n",pStartPoint->GetX(),pStartPoint->GetY(),pStartPoint->GetZ()) ;



            // Get the geometry from the face.

            SurfaceTypeEnum surfaceType;

            hRes = pFace->get_SurfaceType(&surfaceType);


            switch (surfaceType) {

                default :

                    TRACE (L"    Unrecognised surface type:%d\n",surfaceType);

                    break ;


                case kCylinderSurface :

                    TRACE (L"    Cylindrical surface\n");

                    break ;


                case kTorusSurface :

                    TRACE (L"    Cylindrical surface\n");

                    break ;


                case kPlaneSurface :

                    TRACE (L"    Plane surface\n");

                    break ;





Text, images and diagrams © 2021 Owen F. Ransen. All rights reserved. (But copy the source code as much as you want!)