Click here to Skip to main content
14,238,047 members

CAM simulator

Rate this:
4.95 (14 votes)
Please Sign up or sign in to vote.
4.95 (14 votes)
19 Feb 2002
This program shows how a CN machine works

Sample Image - CAM_simulator.gif


After 6 months of work, here is finally my first MFC program release. This program is a CAM simulator. I am not a software engineer, so please forgive me for errors. If you have questions please let me know. I am sure that you will find them. The lecture of data files was a big problem to me at the beginning, so here is the implementation. I needed to read *.txt files, what the CNC machine generate. Here is an example M X25 Y23 Z25 SPEED1500. This is a block of data, needed to setup the machines. This is a kind of language that the machine use to move on the coordinates over the work space. So in this implementation you can read a full document, splitting the block in the necessary X Y Z and SPEED values. This is my first upload, I have more things to say about this program I will try to improve soon, this short commentary.

void CProgramaDoc::OnFileOpen() 
    CString fichero="archivo de Código G",temp;

    CFileDialog archivos(true,NULL,fichero,OFN_ALLOWMULTISELECT,
        "Codigo G (*.tap)|*.tap|Codigo G (*.act)|*.act||",NULL);

    if (archivos.DoModal() == FALSE) return;

    CFile cfFile (fichero, CFile::modeNoTruncate | CFile::modeRead);
    CArchive ar (&cfFile, CArchive::load); 

    if(!ar.ReadString(temp))  return;

        if(temp.GetLength() == 0) continue;



    int i,j,k,d,sp;
    char aux[30];

    for ( i=0; i<5000; i++)
        x[i] = y[i] = z[i] = 0;

    for (i=0;i<nl;i++)
        if (linea[i][0]=='S');
        if (linea[i][0]=='M');
        sp = 0;
        k = 0;
        d = strlen(linea[i]);

        for (j=0;j<d;j++)
            if ((linea[i][j]=='-')|(isdigit(linea[i][j]))|
                aux[k] = linea[i][j];

            if (linea[i][j]==' ')
                if (sp==1) continue;


                if (sp==2)
                    if ((aux[0]=='-')|(isdigit(aux[0]))|(aux[0]=='.'))
                        x[kn] = atof(aux);
                        x[kn] = x[kn-1];

                if (sp==3) 
                    if ((aux[0]=='-')|(isdigit(aux[0]))|(aux[0]=='.')) 
                        y[kn] = atof(aux);
                        y[kn] = y[kn-1];

                if (sp==4)
                    if ((aux[0]=='-')|(isdigit(aux[0]))|(aux[0]=='.')) 
                        z[kn] = atof(aux);
                        z[kn] = z[kn-1];

                k = 0;

        j = d;
    presentar = 1;


    sumz = 0;
    for (i=0; i<nl; i++)
        sumz += abs(z[i]);

    if (sumz == 0)
        torno = 1;
        fresa = 1;



This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Diego Andrade
United States United States
May 2001 – January 2002 MERCK SHARP & DOHME QUITO, ECUADOR
Project Assistant in the area of Engineering. I am in charge of project 02: Remodeling of the area of Liquids and Laundry: where the syrups Hemocyton and Aurimel are synthesized. I have received courses in Industrial Security and GMP (good manufacturing practices). I designed the systems for vapor, cold, and hot soft water for these areas.

I created this company that is devoted to the service of drawing of plans in AutoCAD through the Internet. I designed the web page and the promotion systems and publicity. I elaborated the operation procedures. Another part of this company is, a database of products and services for contractors and projects, in Quito.
August 1996 – November 2001 Escuela Politécnica del Ejército (ESPE), School of Mechanical Engineering (FIME) , QUITO, ECUADOR
• First prize in a competition of Structures
• Third prize in a Heat Transfer challenge (Adiabatic Processes)
• Attended a seminar on normalized procedures for the assembly of oil facilities
• I have complied with all courses and credits required by the ESPE for the termination of my degree. Upon defending my thesis in November, I was awarded my diploma. My thesis topic was: "Development of a Simulator for Milling and Lathe Machines by means of Numeric Control" for the laboratory of CAD/CAM of the Faculty of Mechanical Engineering.

August 2000 Occidental Petroleum Corporation

• One month internship with OXY, Block 15, Sucumbios (in the Ecuadorian Amazon); completed 337 hours of work.
• I spent time in the areas of mechanical maintenance, plant area and finally in automation and control.

• I was on the basketball team.
• I actively participated in the competitions a

Comments and Discussions

Question"Unable to open this internet site" is the message I receive upon attempting to download project. Pin
RedDk16-Apr-14 7:16
memberRedDk16-Apr-14 7:16 
AnswerRe: "Unable to open this internet site" is the message I receive upon attempting to download project. Pin
RedDk21-Apr-14 10:42
memberRedDk21-Apr-14 10:42 
Generala GCode interpreter written in C/C++ Pin
mushigang200623-Aug-08 5:55
membermushigang200623-Aug-08 5:55 
GeneralMfc42d.dll Pin
Member 280963729-May-08 23:57
memberMember 280963729-May-08 23:57 
GeneralAsk fo open source G code interpreter Pin
Flower30311-Jul-04 23:41
memberFlower30311-Jul-04 23:41 
GeneralNot IEC or ISO Language Pin
LFC6-Oct-03 6:18
memberLFC6-Oct-03 6:18 
QuestionCAM? CN? Pin
Philippe Lhoste27-Feb-02 1:49
memberPhilippe Lhoste27-Feb-02 1:49 
AnswerRe: CAM? CN? Pin
Anonymous9-Feb-03 18:39
memberAnonymous9-Feb-03 18:39 
GeneralRe: CAM? CN? Pin
Philippe Lhoste10-Feb-03 22:48
memberPhilippe Lhoste10-Feb-03 22:48 
GeneralNEW VERSION + OpenGL Pin
Diego Andrade21-Feb-02 13:03
memberDiego Andrade21-Feb-02 13:03 
GeneralRe: NEW VERSION + OpenGL Pin
jiang.j.q16-Feb-05 22:13
memberjiang.j.q16-Feb-05 22:13 
GeneralInteresting work Pin
Jamie Hale21-Feb-02 10:38
memberJamie Hale21-Feb-02 10:38 
I haven't taken the time to read through the code, and since I don't read Spanish(?) I don't see that it would help me! Smile | :)

I worked for a CNC machine shop a little while ago and we fiddled with little utilities for this type of stuff.

You must have some solid modelling code in there someplace? Did you make your own? Did you find a free library to do it? Does you software demo tools other than a lathe?


QuestionEnglish? Pin
Matt Newman20-Feb-02 16:40
memberMatt Newman20-Feb-02 16:40 
AnswerRe: English? Pin
Mazdak20-Feb-02 20:01
memberMazdak20-Feb-02 20:01 
AnswerRe: English? Pin
Jamie Hale21-Feb-02 10:36
memberJamie Hale21-Feb-02 10:36 
GeneralRe: English? Pin
Matt Newman21-Feb-02 11:31
memberMatt Newman21-Feb-02 11:31 
GeneralRe: English? Pin
Diego Andrade21-Feb-02 13:00
memberDiego Andrade21-Feb-02 13:00 
GeneralRe: English? Pin
Cathy28-Feb-02 12:34
memberCathy28-Feb-02 12:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Posted 19 Feb 2002


52 bookmarked