hexagon logo

PCDMIS Automation with Visual CSharp 2010 Express

Introduction to PCDMIS Automation

It will take a number of postings in this thread to present all the topics needed to understand and implement my particular method of PCDMIS automation. If you're interested in this thread or want to comment on some part of it, would you consider doing so by email to me. I will reserve the questions and comments and include them in the relevant posting that should answer the question(s). I think this way the thread stays organized and on topic.

Everything I post will work with PCDMIS any version 3.7 and up and MS Visual C Sharp 2010 Express. Sorry no VB Express examples at this time, maybe later after the entire method is presented, I'll go back and add VB. But if you haven't used C Sharp or the MS Visual C Sharp Express IDE, don't worry, the C Sharp code will be very easy to follow and there will be a number of postings that will explain the IDE and how to use it.

For more in-depth exposure to programming in C Sharp I recommend any of the Visual C Sharp 2010 books available. I'm going to try and stay on topic and focus on presenting the method of PCDMIS automation. If I see that a few of you are stuck on a particular C Sharp issue, I'll present a short side bar, so to speak, to maybe help you out.

I make no claims of expertise in the 'correct method' to measure features using CMM. In fact I frequent this forum to learn of such things from others.

To follow this series of postings you will need:
1. Any version of PCDMIS 3.7 and higher.
2. Online or offline.
3. MS Visual C Sharp Express 2010, installed using default settings.

Express 2010 can be downloaded free at:

https://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-csharp-express

In addition to the above items, I also recommend using the following PCDMIS file path settings, once you see how things work and interact with each other, then you can modify the code so that your preferred file path settings will still work.

PCDMIS Search Path Settings
Set 'Default Part Program Directory' to anything other than the default installation directory of PCDMIS. I use c:\PcdmisApps\.

Set 'Probe Directory' to a folder located in part program directory. I use c:\PcdmisApps\Probes.

Set 'Recall Directory' to another folder in the part program directory. I use c:\PcdmisApps\Alignments.

At some point we will be creating an application folder, also located in the part program directory. Name this folder something that leaves no doubt what part the application is to measure. I use the name of the part being measured. When ever I use *App-folder* I mean for you to substitute the name that you gave the application folder. I will reference this a lot.

Inside the *App-folder* are several standard folders which I use inside every application folder. They are:
Doc - Contains application user documentation and/or other notes.
Data-sets - Contains data used by application.
Subroutines - PCDMIS subprograms.
DotNet - The DotNet executable and libraries.
Reports - Reports generated by PCDMIS or DotNet application.

All PCDMIS programs (.PRG files) used by the application are located in the *App-folder* for which is was written.

The method for automating PCDMIS being presented here was developed to answer the following requirements.

1. Parametric PCDMIS programs for the measurement of a family of parts using one PCDMIS program.
2. Hide the PCDMIS IDE from the CMM operator.
3. Internationalization (multi-language user interface)
4. Bidirectional interaction with databases for part data and measurements.
5. Bidirectional interaction with Quality documents in MS Excel or Open Office.
6. To resolve performance and maintenance issues with PCDMIS code.

The first objective is to learn how to create a C Sharp application uses the PcdmisSession library to interact with the PCDLRN in various ways.

The second objective is to demonstrate how to create a PCDMIS parametric program

The third objective is explain the contents PcdmisSession library, so that you can make changes to suit your requirements. This library is where the actual connection to PCDMIS happens. I built this library so that I wouldn't have to write the same code for each application.

The fourth objective is to demonstrate how to read/write measurement data from the PCDLRN to a spreadsheet.

I am interested in hearing from you if any of the code shown in this thread is not working for you, please email me if something doesn't seem to work as demonstrated.

In the next post I will start by providing the PcdmisSession library (dll) file which contains everything needed to connect to and bidirectionally interact with PCDMIS or more accurately the PCDLRN process. As I mentioned before, details or source code for the library will be presented last.

I'm going to assume that most have not used the C Sharp Express IDE, so I will present some pointers to help you get started and include an avi movie file of my screen as I demonstrate concepts.
  • In the Mainform class of the PcdmisMenu application there is a line: probeList = CMMsession.ProbeList(); . This line is nested in a try statement. The PcdmisHelper class, after connecting with Pcdmis, checks the registry for the path to the probe folder (method InitHelper in PcdmisHelper class) . It sets the global variable pcdProbeFolderPath with the path to your probe file. It is dependent on your having set the probe search paths. The try statement fails if the pcdProbeFolderPath is not set or it set to a folder that doesn't exist.

    You set this value when you open the PCDMIS menu Edit->Set Search Path. In the Search for pull down select Probe Directory. Check the checkbox for the Search specified directory: and make sure your probe folder path is correct in the text box above the OK,Cancel and Apply buttons.

    Let me know if you still have this problem after making sure you have the search path set correctly.

    If you do, I'll show you how you can debug into the Pcdmis Helper class from the PcdmisMenu application.
  • Actually let me back up a little...


    It was hanging up at PcdmisHelper.cs "reg1.Close();"

    After a quick google search I figuring out how to debug this thing and I noticed that in PcdmisHelper "version = "V" = version;" version is 2013 MR1(preview I get when hovering over it while debugging) I am running 2015.0 offline seat Win7 64-bit. I commented out:
    • CMMsession = new PcdmisHelper(Settings.Default.PcdmisVersion, UNIT_OPTION.MM);
    • with CMMsession = new PcdmisHelper("2015", UNIT_OPTION.IN);

    So that got me going but got the error previously mentioned which I'm assuming has something to do with it not reading the registry....maybe? PcDmis matched what registry is and folder does exist.
  • It sounds like you got it going. It's been a while since I wrote some of this code but I seem to remember that in the switch statement the switch labels had to start with a letter, without the first character being a letter the switch got screwed up. So I added the V to the version in the switch, now I had to decide if I had to require the user to remember to put the V in front of the version or if I would just add the V just before the switch. I decided on the later. Your line with the "2015" should of worked.

    By the way, for others who would like to know how to debug into the PcdmisHelper from the PcdmisMenu application. Put a break on the CMMsession = new PcdmisHelp... line.
    When the program stops on this line, single step until you drop into the PcdmisHelp source code. Once you're in the code you can scroll to any other part of the code and put breaks where ever you're interested in examining what is actually going on in that section of code.
  • Your line with the "2015" should of worked.


    It worked but it threw the "Missing Probe Folder ParameterNotFound" after I published it. I will see if I can manually point it to my probe directory. I want to look at the results that it yields, so exciting!

    Put a break on the CMMsession = new PcdmisHelp... line.


    That is where I put my breakpoint.

    , Thanks

  • Bummed to say I never got this to work. I've exhausted everything. PcdmisVersion wont switch to my version, it's stuck at 2013 MR1...
  • Sorry to hear that it's not working for you, maybe we can get to the bottom of this by checking a few things.

    The following is a piece of code from my production version of PcdmisHelper.cs
    The first part is a comment reminding me what string of characters to use to start which version of PC-DMIS.

    /* Pcdmis version selection - Input string must be one of the following
    * "2011 MR1" = Internal version 6.1
    * "2012" = Internal version 7.0
    * "2012 MR1" = Internal version 7.1
    * "2013" = Internal version 8.0
    * "2015" = (64-bit) Internal version 10.0
    * "2015.1 = (64-bit) Internal version 10.1
    * Default is the last version that was executed */

    version = "V" + version;
    switch (version)
    {
    case "V2011 MR1":
    PCDMIS_CLSID = getCLSID_RegisterValue(version, "6.1");
    break;
    case "V2012":
    PCDMIS_CLSID = getCLSID_RegisterValue(version, "7.0");
    break;
    case "V2012 MR1":
    PCDMIS_CLSID = getCLSID_RegisterValue(version, "7.1");
    break;
    case "V2013":
    PCDMIS_CLSID = getCLSID_RegisterValue(version, "8.0");
    break;
    case "V2013 MR1":
    PCDMIS_CLSID = getCLSID_RegisterValue(version, "8.1");
    break;
    case "V2015":
    PCDMIS_CLSID = getCLSID_RegisterValue(version, "10.0");
    break;
    case "V2015.1":
    PCDMIS_CLSID = getCLSID_RegisterValue(version, "10.1");
    break;
    default:
    PCDMIS_CLSID = getCLSID_RegisterValue("", "");
    break;

    To see what list of PC-DMIS you have installed and registered:
    Click on windows start button and type in the 'search program and files' box the word 'regedit' (without the single quotes)

    In the regedit window click on Computer then click on Edit->Find. In the Find window enter 'PCDLRN.Application' (without the singles quotes) and click on find next.

    The first stop or find should be on a folder with a name like this - {9A6CFD2C-FA36-4CD6-BEA8-00018F90FD91} this number is the CLSID register number, you may have different numbers and letters. In this folder is a folder of interest named LocalServer32, clicking on this folder will reveal data which is the path to an installed version of PC-DMIS PCDLRN.exe file.

    You should have the above for each version of PC-DMIS you have installed. You can repeatedly click on F3 button to search for the next copy.

    As you repeatedly click on the F3 button to continue searching for the PCDLRN.Application phrase you will eventually stop on a folder with the name PCDLRN.Application. If you have more than one version of PC-Dmis installed you should see other folders with version numbers appended (example: PCDLRN.Application.10.0).

    If you don't see any of these folders for the PC-Dmis you have installed it's probably because you haven't started that version in admin mode which is needed to write these registry entries.

    Let me know what you have found on your PC.
  • Kneislyd thanks for your reply....


    I only have one install of Pcdmis and it is 2015 or 10.0. When I run the code in VS 2015 "version" is set to "2013 MR1" not sure why. I can change in the "watch" window to 2015 and it works but you would think it should do that automatically...correct?

    -Kp61dude!
  • In the source code PcdmisMain.cs there is a line as follows:

    CMMsession = new PcdmisHelper(Settings.Default.PcdmisVersion, UNIT_OPTION.MM);

    The property setting for PcdmisVersion by default in the copy of this program I uploaded is '2013 MR1' you can look up this in the settings section by right clicking on PcdmisMenu in the Solution Explorer and select properties when you see the properties window select settings you should see the property PcdmisVersion and it's current setting value.

    Or you could hard code your version into the program by replacing 'Settings.Default.PcdmisVersion' in the above line with "2015" (include the quotes).
  • One of those easy ones that was impossible for me to figure out without you, thanks it runs.

    I'm getting a "Missing Probe Folder ParameterNotFound" error. All my search paths are set-up as previously mentioned...

    Thanks for your patience.
  • The InitHelper() method in the PcdmisHelper.cs source code obtains the probe folder from the registery entry "LoadProbeUserSearchDirectory". You can confirm that this exist in the registry by opening the registry Editor and using the find menu to search for 'LoadProbeUserSearchDirectory' (without single quote). It should be under the following path: HKEY_CURRENT_USER/Software/WAI/PC-DMIS/2015.0/Options. If the LoadProbeUserSearchDirectory property is not present the application will return the 'Missing Probe Folder' message.

    For other users with only one version installed the 2015.0 folder will be what ever version you have installed. Those of you with multiple versions installed, you should see multiple folders under PC_DMIS folder, one for each version you have installed. Regardless of your version you should have an Option folder in your version folder with a property called LoadProbeUserSearchDirectory if you had set up a PC-DMIS search path to it.

    If you do not see this property you need to start up that version of PC-DMIS. From the Edit menu select Set Search Path, in the Search for: pull down menu select Probe Directory. Select the check box for specified directory and click on the button with the 3 dots to open the navigator window. Navigate to the folder containing probe files for that version. Click on the folder and select OK. Select Apply on the Search Path pop-up. That should create the missing property.

    Because I have multiple copies of PC-Dmis I have a data folder for each version. On my D: drive I have the following folders:

    D:\PCDMIS2011_DATA\
    D:\PCDMIS2012_DATA\
    D:\PCDMIS2015_DATA\

    In each of the above folders there is a Probes and Alignments folder:

    D:\PCDMIS####_DATA\Probes
    D:\PCDMIS####_DATA\Alignments

    Under the PCDCMIS####_DATA folder I also create individual folders for each PC-DMIS application I develop in which I put the measurement programs for that application.

    When setting the Probe Directory and Recall Directory to these paths I make sure the 'Search specified directory' check box is checked because I don't want PC-Dmis to look anywhere else.