IBRepFeaturePrism_DG exception

Technical discussions
Rene20
Posts: 1
Joined: Thu Mar 19, 2020 1:29 am

IBRepFeaturePrism_DG exception

Postby Rene20 » Thu Mar 19, 2020 1:39 am

Hello
I am having a problem with IBRepFeaturePrism_DG. I need to 'drill' a semi-circular hole in a flat face of a solid. I got it working by copying code from Solids example. It uses IBRepFeaturePrism_DG.Perform(length). I need to make it more generic. Perform1(IBRepShape_DG shapeUntil) sounds close. I need it to cut through the whole solid. But I am getting an exception on a call to Perform1().
I would be grateful for a bit of help.
Thanks

Prashant Kande
Posts: 51
Joined: Mon Apr 04, 2016 4:55 am

Re: IBRepFeaturePrism_DG exception

Postby Prashant Kande » Fri Mar 20, 2020 1:35 am

Hi Rene20
We intend to add bunch of tests to the C# samples code where we do basic calls to all methods. It should be out in a few weeks. Here is the related modification of Solids sample:

Code: Select all

        private IModel_DG m_iModel;
        private IObjectGenerator_DG m_iGener;
        private IStdShape_DG m_iStdShape;
        private IBRepBuilder_DG m_iBuilder;
        private IView_DG m_iView;
       
       private void BuildPrismAdd(bool extrusion)
        {
            // Extrusion
            IEntity_DG iEntityBox = m_iStdShape.Box(400, 250, 300);

            IBRepGeometry_DG iBrepGeom = iEntityBox.GetGeometry() as IBRepGeometry_DG;

            IBRepShape_DG iShape = iBrepGeom.GetShape();

            IBRepSolid_DG iSolid = iShape as IBRepSolid_DG;
            IBRepShell_DG iShell = iSolid.GetOuterShell(false);

            // Get nicely oriented face with normal (0,0,1) or (1,0,0)
            IBRepFace_DG iFace = iShell.GetFace(extrusion ? 5 : 1);

            IUVSurface_DG surface = iFace.GetSurface();

            IBRepFace_DG iFacePrism = m_iBuilder.CreateFace6(surface);

            //BuildWire(iFacePrism, extrusion);
            IBRepWire_DG wire = iFacePrism.AddNewWire();

            // Edge down along front vertical right box edge
            IBRepVertex_DG iVtx0 = m_iGener.Create("BRepVertex_DG") as IBRepVertex_DG;
            iVtx0.SetPosition(400, 200, 300);
            wire.AddVertex(iVtx0);
            IBRepVertex_DG iVtx1 = m_iGener.Create("BRepVertex_DG") as IBRepVertex_DG;
            iVtx1.SetPosition(400, 100, 300);
            IBRepEdge_DG edge0 = wire.AddVertex(iVtx1);
            IBRepVertex_DG iVtx2 = m_iGener.Create("BRepVertex_DG") as IBRepVertex_DG;
            iVtx2.SetPosition(400, 100, 200);
            wire.AddVertex(iVtx2);
            wire.CloseWire();

            IBRepFeaturePrism_DG iMakePrism = m_iGener.Create("BRepFeaturePrism_DG") as IBRepFeaturePrism_DG;

            IBRepShape_DG iShapePrism = iFacePrism as IBRepShape_DG;

            VectDg normal = GetSurfaceNormal(surface);   //GetFaceNormal(iFace, normal);   should work too

            if (!extrusion)
                normal.SwapDirection();

            iMakePrism.Init(iBrepGeom, iShapePrism, iFace, normal, extrusion);

            IBRepFace_DG iFaceZMax = iShell.GetFace(5);
            VectDg nZ = iFaceZMax.GetNormalAtRatios(new Dg_2D(0.5, 0.5));

            iMakePrism.Add(edge0, iFaceZMax);

            int idTest = 6;

            if (idTest == 0)
            {
                iMakePrism.Perform(200);
            }
            else if (idTest == 1)
            {

                IBRepFace_DG iFaceZMin = iShell.GetFace(0);
                VectDg n0 = iFaceZMin.GetNormalAtRatios(new Dg_2D(0.5, 0.5));

                iMakePrism.Perform1(iFaceZMin as IBRepShape_DG);
            }
            else if (idTest == 2)
            {

                IBRepFace_DG iFaceXMin = iShell.GetFace(0);
                VectDg n0 = iFaceXMin.GetNormalAtRatios(new Dg_2D(0.5, 0.5));   // Check the correct face in debugger
                IBRepFace_DG iFaceXMax = iShell.GetFace(1);
                VectDg n1 = iFaceXMax.GetNormalAtRatios(new Dg_2D(0.5, 0.5));

                iMakePrism.Perform2(iFaceXMax as IBRepShape_DG, iFaceXMin as IBRepShape_DG);
            }
            else if (idTest == 3)
            {
                iMakePrism.PerformUntilEnd();
            }
            else if (idTest == 4)
            {
                IBRepFace_DG iFaceZMin = iShell.GetFace(0);
                iMakePrism.PerformFromEnd(iFaceZMin as IBRepShape_DG);
            }
            else if (idTest == 5)
            {
                iMakePrism.PerformThruAll();
            }
            else if (idTest == 6)
            {
                IBRepFace_DG iFaceZMin = iShell.GetFace(0);
                iMakePrism.PerformUntilHeight(iFaceZMin as IBRepShape_DG, 200);
            }

            m_iModel.AddEntity(iEntityBox);
        }

Try each case. idTest=1 or 5 sounds like what you need.
Cheers


Return to “General Issues”

Who is online

Users browsing this forum: No registered users and 3 guests