hexagon logo

Got Visual Studio and the Interop.PCDLRN.dll... Now what?

As I upgraded one CMM to Windows 7 64-bit, my small VBS helpers died in the process (still kickin' butt on XP though).
So, I have begun re-coding them in Visual Studio 2010 (I think). I have gotten so far in the coding where I need to connect to PC-DMIS and start interfacing with it. Now, I managed to find the DLL that is supposed to expose some interfaces and methods and I have successfully added it to my project.

Then what? How do I use the DLL to connect to PC-DMIS and expose the PartPrograms collection for instance?

Oh, I am using C# for this...

Any and all input, examples or suggestions are VERY welcome!

TIA!
Parents
  • vpt,

    I'll start with a question. How would you connect to a currently running program in a PC-DMIS script?
    dim app as object
    set app = CreateObject("PCDLRN.Application")
    


    the c# equivalent is very easy, there is actually a doc burried in the script editor help file called "Windows 7 automation notes"

    the following code is derived from that.

    // code to open pc-dmis, if pc-dmis is open, this c# application will connect to the currently running instance of PC-DMIS
    
    using PCDLRN;
    
    
    // class containing functions for interacting with pcdmis
    public class PCDMISInterop
    {
    Appliction pcdApp; // don't use IAppliction, instances of interface types cannot be created, Interfaces can only be inherated
    
    public Application PCDMISApplication
    {
    get{return this.Application;}
    }
    
    public PCDMISInterop()
    {
    startPCDMIS();
    }
    
    bool StartPCDMIS()
    {
        try
        {
             Type pcdObjType = Type.GetTypeFromProgID("PCDLRN.Application");
             this.pcdApp = Activator.CreateInstance(pcdObjType);
    
     pcdApp.WaitUntilReady(60); 
             return true; //pc-dmis started
        }
        catch
        {
             return false; // an error occured
        }
    }
    
    // Gets the active part program
    }
    
    


    this is how you would use it in the main part of the program

    
    using PCDLRN;
    
    int main(void)
    {
    PCDMISInterop PCDMIS = new PCDMISInterop();
    
    PartProgram pcdProgram = PCDMIS.PCDMISApplication.ActivePartProgram
    
    // the following 2 methods could be put into the PCDMISInterop Class to simplify the coding.
    
    // to open a part program
    PCDMIS.PCDMISApplication.PartPrograms.Open("C:\test.prg","CMM1"); // "CMM1" for online, "OFFLINE" for offline
    
    // to create a new part program
    PCDMIS.PCDMISApplication.PartPrograms.Add("C:\test2.prg",UNITTYPE.INCH/*UNITTYPE.MM for metric*/,"TESTPROBE");
    
    
    }
    
    

    I hope this helps.

    I do a lot of Interop with PC-DMIS in C# so if you need anything send me a PM.
  • Hi Cappy,would you pls send me the help file "Windows 7 automation notes"?
    I need some c# demo for developping pcdmis.
    Thank you very much!
    My mail Add:153667861@qq.com
Reply Children
No Data