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.
  • It seems to be from the thread starter. Googling did not give any active hits. Maybe one of the .NET decompilers available out there can give usable source code back from it.


    I tried Jetbrains dot Peek which is how I was able to see what interop it was written with. I'm going to have to learn some more about .peek to see if it can de-compile and if so how. I was really starting to get excited about using C# to learn how to write front ends but now it looks like It won't be an option. I really don't want to learn VB.
  • Decompile? You sure you are allowed to do that? Astonished

    Make it your task to code an interop that works regardless of version or have your coding colleagues release some how-to's to use the (existing) interop. Last time I tried to connect to PC-DMIS via GetMarshalActiveObject, PC-DMIS was not available in the ROT... Maybe they fixed that?
  • Jetbrains should be able to show the decompiled source code, even create a Visual Studio project for it. I don't have JB installed for the moment, so I don't know exactly how to do it, but it should be easy if the file is not protected in som strange way. Probably just double-click somewhere...

    I have ILSpy, and that could show decompiled source code, so I'm sure Jetbrains can do it too.
  • Decompile? You sure you are allowed to do that? Astonished


    As the OP said (in first post)

    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.

    I think it's fair game to decompile and look at it.

    NOTE: The PCDMISSESSION.DLL is not really needed to do automation with C#, it is a helper library that the OP started to write. You may get information on how to do automation in C# by looking at it, but don't need the dll. C# should work almost the same as VB.
  • So I'm not exactly sure of anything I'm doing but I was able to export code from the DLL but having no clue what I'm doing it was a fools errand Smiley !

    What VPT.SE said did give me pause, but after reading the OP comments I think that's permission at least for what I'm doing which is just trying to learn C#.
  • when I try to use any other version of PC-DMIS other than 2011MR1 (6.1) that it fails to find the executable.


    I'm using PcDmis 2015.0 SP4 with Visual Studio 2015 worked just fine, I'm also totally new to this - FYI


  • I'm using PcDmis 2015.0 SP4 with Visual Studio 2015 worked just fine, I'm also totally new to this - FYI


    I believe the reason my computer is having issues is because I have about 10 version of PC-DMIS installed. But I was able to view the DLL source and I'm working on a recompile to allow for this. (No idea what I'm doing).
  • I believe the reason my computer is having issues is because I have about 10 version of PC-DMIS installed.


    If you are connecting to "PCDLRN.Application" the registry entry HKEY_CLASSES_ROOT\PCDLRN.Application\CLSID will be used to decide which PC-DMIS you will connect to. If any other version is already started it will not work.

    The easiest way to write a certain version into that Registry entry is to start the PC-DMIS you want to automate with right click + "Run as admin" - this allows PC-DMIS to write its connection info in that Registry key. Then close PC-DMIS and every time you start it by automation, this will be the version started. Starting PC-DMIS as 'normal user' will not have enough access rights to change this key.

    Alternatively you can start a certain version by adding a version number to the connect string, for example "PCDLRN.Application.10.1" for 2015.1.