hexagon logo

Launch PC-DMIS in Operator Mode through VB

I searched through the forum and couldn't find a solution for my issue.

I was wondering if it is possible to launch pc-dmis in operator mode from a script.

I made a front end GUI and wanted to be able to display pc dmis (in operator mode) while it's running a program. Right now I just hide everything besides the Execution window.

I'll attach the code I'm using to start pc dmis if it helps

TIA

Sub PCDMISProgramRun()


Dim PCDApp, PCDPartProgram, PCDProgramCommand


''

Set PCDApp = CreateObject("PCDLRN.Application") 'Opens PC-DMIS

    If Not PCDApp.WaitUntilReady(300) Then
        MsgBox "Machine did not initialize, Exiting"
        Exit Sub
    End If

    PCDApp.Visible = False
Parents
  • From the pcd basic manual (aka never used it myself but hey I found info in the help guide!):

    To start PC-DMIS using Automation from another application, use CreateObject or GetObject to return an Application object.
    Launching PC-DMIS With Startup Options

    Because of an inherent weakness in the way Microsoft designed the CreateObject function, the CreateObject doesn't allow startup parameters. This means when the code executes it will launch PC-DMIS always in ONLINE mode.
    However, there is a way around this. Your code can dynamically create a special startup file that will cause PC-DMIS to launch with specific startup options.
    In order to launch PC-DMIS via automation with a startup file you must do the following:
    • Create a text file named AutomationStartupOptions.txt.
    • Create a single line of text in the file with the available startup options. The PC-DMIS specific startup options include the following:
    /f - Launches in Offline mode.
    /o - Launches in Operator mode.
    /d - Launches in Debug mode.
    /r - Launches in Reverse Axes mode
    /postin - Launches in import mode. PC-DMIS will automatically import a specified file.
    /postout - Launches in export mode. PC-DMIS will automatically export a specified file.
    The line of text would look like this: /f /o /d /r /postin /postout
    • Launch PC-DMIS via automation.
    When PC-DMIS starts, it checks to see if the AutomationStartupOptions.txt file exists. If it does, then it uses the file to set the necessary flags. However, when PC-DMIS closes, it will delete the text file. This means that the code you use to launch PC-DMIS must also create the needed text file on the fly or must rename an existing file to AutomationStartupOptions.txt. See the "Example Code from C++" below.
    Automating in Online Mode: If you are trying to launch PC-DMIS in online mode, please note that the AutomationStartupOptions.txt file should not contain the /f startup parameter. Also, the machine parameter specified when using the Open or New methods of the PartPrograms object determines whether or not the measurement routine will run in offline or online modes. Of online mode, this parameter should be "CMM1".

    Example

    Dim App as Object.
    Set App = CreateObject("Pcdlrn.Application")

    C++ example:
    // Create my startup file
    
      int nIndex;
    
      CString szFileName, szLine(_T("/f"));
    
      GetModuleFileName (AfxGetInstanceHandle(), szFileName.GetBuffer (_MAX_PATH), _MAX_PATH);
    
      szFileName.ReleaseBuffer();
    
      nIndex = szFileName.ReverseFind('\\');
    
      szFileName = szFileName.Left(nIndex);
    
      szFileName += _T("\\AutomationStartupOptions.txt");
    
      CStdioFile StartupFile;
    
      if( StartupFile.Open(szFileName, CFile::modeCreate|CFile::modeWrite|CFile::typeText) )
    
      {
    
        StartupFile.WriteString(szLine);
    
        StartupFile.Close();
    
      }
    


    In other words create the text file where ever PCDLRN.exe resides.
Reply
  • From the pcd basic manual (aka never used it myself but hey I found info in the help guide!):

    To start PC-DMIS using Automation from another application, use CreateObject or GetObject to return an Application object.
    Launching PC-DMIS With Startup Options

    Because of an inherent weakness in the way Microsoft designed the CreateObject function, the CreateObject doesn't allow startup parameters. This means when the code executes it will launch PC-DMIS always in ONLINE mode.
    However, there is a way around this. Your code can dynamically create a special startup file that will cause PC-DMIS to launch with specific startup options.
    In order to launch PC-DMIS via automation with a startup file you must do the following:
    • Create a text file named AutomationStartupOptions.txt.
    • Create a single line of text in the file with the available startup options. The PC-DMIS specific startup options include the following:
    /f - Launches in Offline mode.
    /o - Launches in Operator mode.
    /d - Launches in Debug mode.
    /r - Launches in Reverse Axes mode
    /postin - Launches in import mode. PC-DMIS will automatically import a specified file.
    /postout - Launches in export mode. PC-DMIS will automatically export a specified file.
    The line of text would look like this: /f /o /d /r /postin /postout
    • Launch PC-DMIS via automation.
    When PC-DMIS starts, it checks to see if the AutomationStartupOptions.txt file exists. If it does, then it uses the file to set the necessary flags. However, when PC-DMIS closes, it will delete the text file. This means that the code you use to launch PC-DMIS must also create the needed text file on the fly or must rename an existing file to AutomationStartupOptions.txt. See the "Example Code from C++" below.
    Automating in Online Mode: If you are trying to launch PC-DMIS in online mode, please note that the AutomationStartupOptions.txt file should not contain the /f startup parameter. Also, the machine parameter specified when using the Open or New methods of the PartPrograms object determines whether or not the measurement routine will run in offline or online modes. Of online mode, this parameter should be "CMM1".

    Example

    Dim App as Object.
    Set App = CreateObject("Pcdlrn.Application")

    C++ example:
    // Create my startup file
    
      int nIndex;
    
      CString szFileName, szLine(_T("/f"));
    
      GetModuleFileName (AfxGetInstanceHandle(), szFileName.GetBuffer (_MAX_PATH), _MAX_PATH);
    
      szFileName.ReleaseBuffer();
    
      nIndex = szFileName.ReverseFind('\\');
    
      szFileName = szFileName.Left(nIndex);
    
      szFileName += _T("\\AutomationStartupOptions.txt");
    
      CStdioFile StartupFile;
    
      if( StartupFile.Open(szFileName, CFile::modeCreate|CFile::modeWrite|CFile::typeText) )
    
      {
    
        StartupFile.WriteString(szLine);
    
        StartupFile.Close();
    
      }
    


    In other words create the text file where ever PCDLRN.exe resides.
Children
No Data