Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom CAM toolpaths in siemens NX

Status
Not open for further replies.

Marcoantoniosilva

Industrial
Sep 22, 2013
6
Hello everyone.

I've been searching some sample codes that can provide examples about drpos, dpud, udop functions, used to create custom toolpaths in siemens NX. I need a code that provide information about use of selected geometries used to create reference for the toolpath which will be created. Follow a code that i created on java to use DPUD function, but i found some problemns, like a infinity loop on generate the operation. Someone can help me?

Code:
  public static int dpud(String[] args) throws Exception, NXException {
        int retorno=0;
        initvar();
        UFVariant udpud;
        UFVariant operptr;
        UFVariant udrpos1, udrpos2, udrpos0;
        UFDpud.Purpose purpose;
        String opname;
        UFVariant pathptr;
        Tag operacao = null;


        udpud = theufsession.dpud().askDpud(null);
        operptr = theufsession.dpud().askOper(udpud);
        purpose = theufsession.dpud().askPurpose(udpud);
        opname = theufsession.oper().askName(operptr);
        pathptr = theufsession.oper().askPath(operptr);
        operacao = theufsession.obj().cycleByName(opname, operacao);
        //udrpos0 = theufsession.dpud().askDrpos0(udpud);
        //udrpos1 = theufsession.dpud().askDrpos1(udpud);
        //udrpos2 = theufsession.dpud().askDrpos2(udpud);

        
        
        

        if (purpose == UFDpud.Purpose.USER_PARAMS) {
            theufsession.ui().openListingWindow();
            theufsession.ui().writeListingWindow("USER PARAMS" + "\n");
            theufsession.ui().writeListingWindow("NOME DA OPERACAO: " + opname + "\n");
            theufsession.ui().writeListingWindow("TAG NUMBER : " + operacao + "\n");
            theufsession.ui().writeListingWindow("TAG NAME   : " + theufsession.obj().askName(operacao) + "\n");
            purposeopen();
        } else {
            theufsession.ui().openListingWindow();
            theufsession.ui().writeListingWindow("generate drpos" + "\n");
            //retorno = -1;
        }

        
       
        
        /*
         if (purpose == UFDpud.Purpose.REWIND) {
         theufsession.ui().openListingWindow();
         theufsession.ui().writeListingWindow("REWIND" + "\n");
         }


         if (purpose == UFDpud.Purpose.STOP_PROCESSOR) {
         theufsession.ui().openListingWindow();
         theufsession.ui().writeListingWindow("PAROU A DO PROCESSAMENTO" + "\n");
         }

         if (purpose == UFDpud.Purpose.TAXIS_PARAMS) {
         theufsession.ui().openListingWindow();
         theufsession.ui().writeListingWindow("TAXIS PARAMETERS" + "\n");
         }


         if (purpose == UFDpud.Purpose.PROJ_PARAMS) {
         theufsession.ui().openListingWindow();
         theufsession.ui().writeListingWindow("PROJ PARAMS" + "\n");
         }


         if (purpose == UFDpud.Purpose.INIT_PROCESSOR) {
         theufsession.ui().openListingWindow();
         theufsession.ui().writeListingWindow("INIT PROCESSOR" + "\n");


         //theufsession.param().generate(operacao);


         theufsession.ui().writeListingWindow("GERADO COM SUCESSO" + "\n");

            

         }
         //*/




        return retorno;
    }
 
Replies continue below

Recommended for you

Dr. Mark Rief

Thanks for your repply.

I searched on GTAC Symptom/Solution Database, but i not found a sample code or a sample file that can provide information about dpud and drpos. Only about UDOP. I searched too on the forum that you had recomended, but i dont found what i need.

can you provide me some sample code with dpud, drpos, and another functions to create custom toolpaths on NX that i need?

Thanks for your attention
 
dpud is not so well documented.

you need to add handling for GET_NEXT and GET_INTERMEDIATE
You might get a clue from this..
Code:
 } else if (purpose == nxopen.uf.UFDpud.Purpose.GET_NEXT) {
            double proj[] = {0.0,0.0,-1.0};
        	drpos0 = dpSess.askDrpos0(dpudPtr);
            coord = path.getNextCoord();
            if(coord==null){
	        	ufDrPos.createFinalLift(drpos0);
            }else{
                pos[0] = coord.x;
                pos[1] = coord.y;
                pos[2] = coord.z;
                ufDrPos.setPosition(drpos0, pos);
                if(id==0){
                	ufDrPos.setProjVec(drpos0, proj);
                	ufDrPos.createFirstCut(drpos0, pos, dir);
                	}
                else{
                	ufDrPos.createCut(drpos0, pos, dir);
                }
            }
            id++;
        } else if (purpose == nxopen.uf.UFDpud.Purpose.GET_INTERMEDIATE) {
            UFVariant drpos1 = null;
            UFVariant drpos2 = null;
//            System.out.println("purpose GET_INTERMEDIATE");
            final double ratio = dpSess.askRatio(dpudPtr);
            drpos1 = dpSess.askDrpos1(dpudPtr);
            drpos2 = dpSess.askDrpos2(dpudPtr);
            double[] pos1 = ufDrPos.askPosition(drpos1);
            double[] pos2 = ufDrPos.askPosition(drpos2);
            double deltaX = pos2[0] - pos1[0];
            double deltaY = pos2[1] - pos1[1];
            double deltaZ = pos2[2] - pos1[2];
            double midpos[] = new double[3];
            midpos[0] = deltaX * ratio + pos1[0];
            midpos[1] = deltaY * ratio + pos1[1];
            midpos[2] = deltaZ * ratio + pos1[2];
            drpos0 = dpSess.askDrpos0(dpudPtr);
            ufDrPos.setPosition(drpos0, midpos);
            id++;
        } else if (purpose == nxopen.uf.UFDpud.Purpose.REWIND) {
            System.out.println("purpose REWIND");
        } else if (purpose == nxopen.uf.UFDpud.Purpose.STOP_PROCESSOR) {
            System.out.println("purpose STOP_PROCESSOR");
            id=-1;
            // must unload so NX don't crash
            unloadType = BaseSession.LibraryUnloadOption.IMMEDIATELY;
        } else {
        	System.out.println("Purpose ??");
        }


 
Wrong formatting in my last post

Code:
       } else if (purpose == nxopen.uf.UFDpud.Purpose.GET_NEXT) {
            double proj[] = {0.0,0.0,-1.0};
        	drpos0 = dpSess.askDrpos0(dpudPtr);
            coord = path.getNextCoord();
            if(coord==null){
	        	ufDrPos.createFinalLift(drpos0);
            }else{
                pos[0] = coord.x;
                pos[1] = coord.y;
                pos[2] = coord.z;
                ufDrPos.setPosition(drpos0, pos);
                if(id==0){
                	ufDrPos.setProjVec(drpos0, proj);
                	ufDrPos.createFirstCut(drpos0, pos, dir);
                	}
                else{
                	ufDrPos.createCut(drpos0, pos, dir);
                }
            }
            id++;
        } else if (purpose == nxopen.uf.UFDpud.Purpose.GET_INTERMEDIATE) {
            UFVariant drpos1 = null;
            UFVariant drpos2 = null;
//            System.out.println("purpose GET_INTERMEDIATE");
            final double ratio = dpSess.askRatio(dpudPtr);
            drpos1 = dpSess.askDrpos1(dpudPtr);
            drpos2 = dpSess.askDrpos2(dpudPtr);
            double[] pos1 = ufDrPos.askPosition(drpos1);
            double[] pos2 = ufDrPos.askPosition(drpos2);
            double deltaX = pos2[0] - pos1[0];
            double deltaY = pos2[1] - pos1[1];
            double deltaZ = pos2[2] - pos1[2];
            double midpos[] = new double[3];
            midpos[0] = deltaX * ratio + pos1[0];
            midpos[1] = deltaY * ratio + pos1[1];
            midpos[2] = deltaZ * ratio + pos1[2];
            drpos0 = dpSess.askDrpos0(dpudPtr);
            ufDrPos.setPosition(drpos0, midpos);
            id++;
        } else if (purpose == nxopen.uf.UFDpud.Purpose.REWIND) {
            System.out.println("purpose REWIND");
        } else if (purpose == nxopen.uf.UFDpud.Purpose.STOP_PROCESSOR) {
            System.out.println("purpose STOP_PROCESSOR");
            id=-1;
            // must unload so NX don't crash
            unloadType = BaseSession.LibraryUnloadOption.IMMEDIATELY;
        } else {
        	System.out.println("Purpose ??");
        }
 
KariH, Hello my friend..

Very thanks for your collaboration...

You save me

you solve all my problems...Thanks a lot
 
KariH, please, can you provide me the an example to use a surface or a line as guide to an operation ??

as example, can i use a surface like a drive or make a contour like mill contour multi axis operation??

I wait anxious your help...

 
Marcoantoniosilva
I don't have any simple example but as you see in my code I have a object named path. It is created from a NX curve. The curve is divided into small segments depending on the resolution I need. Each time I call (or actually NX calls with Purpose.GET_NEXT) path.getNextCoord() it will return the coordinates of the start of the next segment. These coordinates are used to to set the drivegeometry with ufDrPos.setPosition(), when there are no more coordinates i run ufDrPos.createFinalLift()

NX will continue to call the dpud until you run ufDrPos.createFinalLift() if you don't do that you will end up with a infinite loop.

I have never tryed to use surfaces as drive..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor