hexagon logo

PC-DMIS 2017 (interop.pcdlrn.dll) issue on profile of a surface measurements

Hi,

i am software programer so i dont really know about inspection and CMM.

i am having issue using the library interop.pcdlrn.dll for the command "perimeter scan" for a "profile of surface".


when i'm using the librairy it shows a measurement value of 0 like if the machine is offline. but when i use the software PC-DMIS, i have the good results.


but when i do a "constructed set" for a "profile of surface" i have good results either if im using the library or the software.

i dont't understand how the library can act differently from the software. this strange behavior prevents us to use the custom software on the prod environnment.

because im a software programmer i dont really know how to express myself in this forum so i'm sorry if i dont give enough details

Parents
  • Hi Don,

    See the attached file " samplecode.txt " this is the c# code i'm using to execute the .prg file:

    private void runProgram()
            {
                foreach (var process in Process.GetProcessesByName("PCDLRN"))
                {
                    process.Kill();
                }
                Thread.Sleep(1000);
    
                //COPYING .PRG AND .CAD FILE FROM NETWORK FOLDER TO A LOCAL FOLDER (c:\\TEMPCMM\\)
                themodel.Instance.statusBar = string.Format("PROGRAM DOWNLOADING ...");
                FileInfo tempPrg = new FileInfo(themodel.Instance.programPath);
                FileInfo tempCad = new FileInfo(themodel.Instance.cadPath);
                FileInfo reportPath = new FileInfo(themodel.Instance.reportPath);
    
                DirectoryInfo tempFolder = new DirectoryInfo("c:\\TEMPCMM\\");
    
                if (!Directory.Exists(tempFolder.FullName))
                {
                    Directory.CreateDirectory(tempFolder.FullName);
                }
    
                File.Copy(tempPrg.FullName, Path.Combine(tempFolder.FullName, tempPrg.Name), true);
                File.Copy(tempCad.FullName, Path.Combine(tempFolder.FullName, tempCad.Name), true);
    
                //THE PROGRAM FILE
                tempPrg = new FileInfo(Path.Combine(tempFolder.FullName, tempPrg.Name));
                tempCad = new FileInfo(Path.Combine(tempFolder.FullName, tempCad.Name));
    
                PCDLRN.Application PCDApp = null;
                PCDLRN.IPartPrograms PCDPartPrograms = null;
                PCDLRN.PartProgram pcdActivePart = null;
                ApplicationObjectEvents AppEvents = null;
    
                try
                {
                    initPCDMIS(tempPrg, out PCDApp, out PCDPartPrograms, out pcdActivePart);
                }
                catch (System.Exception)
                {
                    MessageBox.Show("PC-DMIS needs to be started!"); // PC-DMIS needs to be started!
                    Thread.CurrentThread.Abort();
                }
    
    
                if (PCDApp != null && PCDPartPrograms != null && pcdActivePart != null)
                {
                    var pcdCommands = pcdActivePart.Commands;
                    int commandCount = pcdCommands.Count;
    
                    PCDApp.OperatorMode = false;
                    PCDApp.Visible = visible;
    
                    themodel.Instance.statusBar = string.Format("PROGRAM EXECUTION ...");
    
                    try
                    {
                        Thread.Sleep(1000);
    
                        active_probe msgbox = new active_probe("IS THE PROBE " + PCDApp.DefaultProbeFile + " CURRENTLY ACTIVE ?");
    
                        msgbox.ShowDialog();
    
                        if (msgbox.yesno)
                        {
                            Thread.Sleep(2000);
                            //execut
                            pcdActivePart.EXECUTE();
                            pcdActivePart.SaveAs(Path.ChangeExtension(reportPath.FullName, ".PRG"));
                        }
                    }
                    catch (Exception ex)
                    {
                        themodel.Instance.statusBar = string.Format("ERROR DURING EXECUTION");
    
    
                        //try to close the program
                        while (PCDApp.ActivePartProgram != null)
                        {
                            //try to close the program
                            try
                            {
                                pcdActivePart.Quit();
                            }
                            //if it fails to close, wait 0.5 seconds (then the loop runs again)
                            catch { System.Threading.Thread.Sleep(500); }
                        }
    
    
    
                        File.Delete(tempPrg.FullName);
                        File.Delete(tempCad.FullName);
    
                        PCDPartPrograms = null;
                        pcdActivePart = null;
    
    
                        foreach (var process in Process.GetProcessesByName("PCDLRN"))
                        {
                            process.Kill();
                        }
    
                        Thread.CurrentThread.Abort();
                    }
    
                    Thread.Sleep(10000);
    
    
                    //Quit();
                    while (PCDApp.ActivePartProgram != null)
                    {
                        //try to close the program
                        try
                        {
                            pcdActivePart.Quit();
                        }
                        //if it fails to close, wait 0.5 seconds (then the loop runs again)
                        catch { System.Threading.Thread.Sleep(500); }
                    }
    
                    PCDPartPrograms = null;
                    pcdActivePart = null;
                }
            }


    for the library INTEROP.PCDLRN.DLL, i'm using v12.2.0.0, you can see attached file "dll_version.PNG" for more details



    for the software PC-DMIS 2017 R2 64-bit, i'm using the build #1260, you can see attached file "software_version.PNG" for more details.


    for the moment i cannot upload the .PRG file.



    A "perimeter scan" for a "profile of surface" generated from the custom program:




    A "perimeter scan" for a "profile of surface" generated from the software:






    to solve the probleme, the first things i am wondering is:


    what are all the temporary files generated by the program for ?
    do i correctly open and close pc-dmis from my c# program ?
    is there possibility of mismatch between dll version and sotware version ?


    Attached Files
Reply
  • Hi Don,

    See the attached file " samplecode.txt " this is the c# code i'm using to execute the .prg file:

    private void runProgram()
            {
                foreach (var process in Process.GetProcessesByName("PCDLRN"))
                {
                    process.Kill();
                }
                Thread.Sleep(1000);
    
                //COPYING .PRG AND .CAD FILE FROM NETWORK FOLDER TO A LOCAL FOLDER (c:\\TEMPCMM\\)
                themodel.Instance.statusBar = string.Format("PROGRAM DOWNLOADING ...");
                FileInfo tempPrg = new FileInfo(themodel.Instance.programPath);
                FileInfo tempCad = new FileInfo(themodel.Instance.cadPath);
                FileInfo reportPath = new FileInfo(themodel.Instance.reportPath);
    
                DirectoryInfo tempFolder = new DirectoryInfo("c:\\TEMPCMM\\");
    
                if (!Directory.Exists(tempFolder.FullName))
                {
                    Directory.CreateDirectory(tempFolder.FullName);
                }
    
                File.Copy(tempPrg.FullName, Path.Combine(tempFolder.FullName, tempPrg.Name), true);
                File.Copy(tempCad.FullName, Path.Combine(tempFolder.FullName, tempCad.Name), true);
    
                //THE PROGRAM FILE
                tempPrg = new FileInfo(Path.Combine(tempFolder.FullName, tempPrg.Name));
                tempCad = new FileInfo(Path.Combine(tempFolder.FullName, tempCad.Name));
    
                PCDLRN.Application PCDApp = null;
                PCDLRN.IPartPrograms PCDPartPrograms = null;
                PCDLRN.PartProgram pcdActivePart = null;
                ApplicationObjectEvents AppEvents = null;
    
                try
                {
                    initPCDMIS(tempPrg, out PCDApp, out PCDPartPrograms, out pcdActivePart);
                }
                catch (System.Exception)
                {
                    MessageBox.Show("PC-DMIS needs to be started!"); // PC-DMIS needs to be started!
                    Thread.CurrentThread.Abort();
                }
    
    
                if (PCDApp != null && PCDPartPrograms != null && pcdActivePart != null)
                {
                    var pcdCommands = pcdActivePart.Commands;
                    int commandCount = pcdCommands.Count;
    
                    PCDApp.OperatorMode = false;
                    PCDApp.Visible = visible;
    
                    themodel.Instance.statusBar = string.Format("PROGRAM EXECUTION ...");
    
                    try
                    {
                        Thread.Sleep(1000);
    
                        active_probe msgbox = new active_probe("IS THE PROBE " + PCDApp.DefaultProbeFile + " CURRENTLY ACTIVE ?");
    
                        msgbox.ShowDialog();
    
                        if (msgbox.yesno)
                        {
                            Thread.Sleep(2000);
                            //execut
                            pcdActivePart.EXECUTE();
                            pcdActivePart.SaveAs(Path.ChangeExtension(reportPath.FullName, ".PRG"));
                        }
                    }
                    catch (Exception ex)
                    {
                        themodel.Instance.statusBar = string.Format("ERROR DURING EXECUTION");
    
    
                        //try to close the program
                        while (PCDApp.ActivePartProgram != null)
                        {
                            //try to close the program
                            try
                            {
                                pcdActivePart.Quit();
                            }
                            //if it fails to close, wait 0.5 seconds (then the loop runs again)
                            catch { System.Threading.Thread.Sleep(500); }
                        }
    
    
    
                        File.Delete(tempPrg.FullName);
                        File.Delete(tempCad.FullName);
    
                        PCDPartPrograms = null;
                        pcdActivePart = null;
    
    
                        foreach (var process in Process.GetProcessesByName("PCDLRN"))
                        {
                            process.Kill();
                        }
    
                        Thread.CurrentThread.Abort();
                    }
    
                    Thread.Sleep(10000);
    
    
                    //Quit();
                    while (PCDApp.ActivePartProgram != null)
                    {
                        //try to close the program
                        try
                        {
                            pcdActivePart.Quit();
                        }
                        //if it fails to close, wait 0.5 seconds (then the loop runs again)
                        catch { System.Threading.Thread.Sleep(500); }
                    }
    
                    PCDPartPrograms = null;
                    pcdActivePart = null;
                }
            }


    for the library INTEROP.PCDLRN.DLL, i'm using v12.2.0.0, you can see attached file "dll_version.PNG" for more details



    for the software PC-DMIS 2017 R2 64-bit, i'm using the build #1260, you can see attached file "software_version.PNG" for more details.


    for the moment i cannot upload the .PRG file.



    A "perimeter scan" for a "profile of surface" generated from the custom program:




    A "perimeter scan" for a "profile of surface" generated from the software:






    to solve the probleme, the first things i am wondering is:


    what are all the temporary files generated by the program for ?
    do i correctly open and close pc-dmis from my c# program ?
    is there possibility of mismatch between dll version and sotware version ?


    Attached Files
Children
No Data