Start PC-DMIS in Operator Mode via Code

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Start PC-DMIS in Operator Mode via Code

    I would like to start PC-DMIS in operator mode, specifically to disable the Edit Window. Here is the snippet of the C# code:
    Code:
    app = (PCDLRN.Application)Activator.CreateInstance(Type.GetTypeFromProgID("PCDLRN.Application"));
    progs = app.PartPrograms;
    events = app.ApplicationEvents;
    app.Visible = true;
    app.OperatorMode = true;
    Unfortunately, the user can still open the Edit Window (View -> Edit Window) to make changes to the program. Does anyone have a sample code that does what I'm trying to do?

    Thanks.

  • #2
    why not just open it in operator mode?
    Ex-Hex

    Comment


    • #3
      We created a tool that uses the API to automatically export the measurement to a specific format after the program is executed. To ensure a robust connection between the PC-DMIS application and the tool, we need to run the tool and then start PC-DMIS application.

      Comment


      • #4
        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 part program 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")
        Hope this helps.
        PC-DMIS CAD++ 2o19 R1 SP11

        Comment


        • #5
          vpt.se Yes, thanks for posting the solution. It works! However, using the AutomationStartupOption.txt file, I'm seeing a difference in the PC-DMIS behavior when exiting the application. Open PC-DMIS in operator mode ("C:\Program Files\Hexagon\PC-DMIS xxx\Launcher\HexagonLauncher.exe" LauncherPC-DMIS.config /o), it forces the PC to sign out the user when exiting the application. Using the AutomationStartupOption.txt and automation, it does not. Have you observed similar behavior as well? I would like to sign out the user. Is there a way to do so? Thanks!

          Comment


          • AndersI
            AndersI commented
            Editing a comment
            Verify that the setting OMLogout in Settings Editor is set to TRUE

        • #6
          No clue - it "should" behave the same as when starting it with command-line switches. Are you starting PC-DMIS using your application, or is it already started when your app connects to it?

          Maybe try closing your app (that started PC-DMIS) before closing PC-DMIS to see if it will logoff?
          PC-DMIS CAD++ 2o19 R1 SP11

          Comment


          • #7
            What AndersI said, that just happened to me.

            Comment


            • #8
              Verified that the setting OMLogout in Settings Editor is indeed set to TRUE. Tried closing the app before closing PC-DMIS. The behavior still exists.

              Comment


              • #9
                Originally posted by cmshieh View Post
                I would like to start PC-DMIS in operator mode, specifically to disable the Edit Window. Here is the snippet of the C# code:
                Code:
                app = (PCDLRN.Application)Activator.CreateInstance(Type.GetTypeFromProgID("PCDLRN.Application"));
                progs = app.PartPrograms;
                events = app.ApplicationEvents;
                app.Visible = true;
                app.OperatorMode = true;
                Unfortunately, the user can still open the Edit Window (View -> Edit Window) to make changes to the program. Does anyone have a sample code that does what I'm trying to do?

                Thanks.
                Loop your code non-stop! As soon as the operator opens the Edit window the loop should be coming around the bend to hide it again before operator can even distinguish the text in the Edit window. Not the best solution but a multi threader never hurt no one.

                Edit:
                Grab a hold of the window handle and simulate the exit button (they're not 'send-keys' though). Did something similar though it was to use the ESC key to exit absolutely anything sub-menu opened in PcDmis like it would in MasterCam, Solidworks, etc everyone else!

                Use of Microsoft Spy++ and http://www.pinvoke.net/ should get you moving quickly.

                Here's more: https://www.codeproject.com/Articles...omation-Framew

                It's called "UI Automation" btw I just remembered.
                Last edited by Kp61dude!; 08-28-2019, 04:54 PM.
                PcDmis 2015.1 SP10 CAD++
                Global 7-10-7 DC800S

                Comment


                • #10
                  Just look for the PCDLRN.Application all the time. As soon as app = null/nil/nothing in your code above, trigger a computer logoff in your app.
                  PC-DMIS CAD++ 2o19 R1 SP11

                  Comment


                  • #11
                    vpt.se Based on your comment, I have found a solution. Instead of looking for "app = null", one needs to look for "app.Visible = false" and then trigger a computer to sign out. This is because when launching PCDMIS via automation with AutomationStartupOptions.txt, PCDMIS does not truly "exit" when exiting. Instead PC-DMIS becomes a background process, and when it happens, app.Visible = false. Problem solved!

                    Comment


                    • AndersI
                      AndersI commented
                      Editing a comment
                      What happens if someone clicks the "Minimize" Icon on the PC-DMIS Window - wouldn't that also make .Visible=False? Or is it only setting .WindowState?

                    • vpt.se
                      vpt.se commented
                      Editing a comment
                      What AndersI said. Make sure that minimizing PC-DMIS does not trigger a computer shutdown...

                  Related Topics

                  Collapse

                  Working...
                  X