PC-DMIS 2022.1 Object Library
OpenEx Method
See Also  Example  Send Topic Feedback | See Object Hierarchy Chart
FileName
Required String. The file name of the PartProgram to open.
MachineName
Required String. This is the identifying string for your machine. If you're running in offline mode, use "Offline". If you're running in online mode use "CMM1".
IncludeCAD

Required Boolean.

This determines whether to load the corresponding CAD model with the measurement routine.

  • True means it opens the associated CAD file with the routine and shows the CAD model in the Graphic Display window.
  • False means it opens the routine only and doesn't open the CAD in the Graphic Display window.

 

out_StatusCode
out_StatusCode lets you see the status of the OpenEx operation.
PCDLRN ActiveX DLL > PartPrograms Object : OpenEx Method

Glossary Item Box

Description

This function opens a measurement routine and adds it to the PartPrograms collection.

This method differs from the Open method because it includes some additional parameters: IncludeCAD and OpenRoutineStatus * out_StatusCode

The IncludeCAD parameter corresponds to the Include CAD checkbox on the Open dialog box in PC-DMIS.

Syntax

Visual Basic
Public Function OpenEx( _
   ByVal FileName As String, _
   ByVal MachineName As String, _
   ByVal IncludeCAD As Boolean, _
   ByRef out_StatusCode As OpenRoutineStatus _
) As PartProgram

Parameters

FileName
Required String. The file name of the PartProgram to open.
MachineName
Required String. This is the identifying string for your machine. If you're running in offline mode, use "Offline". If you're running in online mode use "CMM1".
IncludeCAD

Required Boolean.

This determines whether to load the corresponding CAD model with the measurement routine.

  • True means it opens the associated CAD file with the routine and shows the CAD model in the Graphic Display window.
  • False means it opens the routine only and doesn't open the CAD in the Graphic Display window.

 

out_StatusCode
ValueDescription
BranchMismatchErrorPC-DMIS cannot open the routine due to a branch mismatch error. This has a value of 8.
CannotOpenRoutineFilePC-DMIS cannot open the routine. This status has a value of 4.
DeserializationErrorPC-DMIS cannot open the routine because of a deserialization error. This has a value of 7.
ErrorClosingRoutineFilePC-DMIS cannot open the routine because it cannot close the routine after it reads it. This has a value of 5.
InternalErrorPC-DMIS cannot open the routine because of an internal error. This has a value of 3.
OpenedBackupCopyPC-DMIS opened a backup copy of the routine instead of the main routine. This has a value of 2.
PcdmisIsOpeningAnotherRoutinePC-DMIS cannot open the routine because it is in the process of opening another routine. This has a value of 10.
RoutineFileDoesNotExistPC-DMIS cannot open the routine because the routine file does not exist. This has a value of 6.
RoutineIsNewerErrorPC-DMIS cannot open the routine because the routine is newer than the version of PC-DMIS. This has a value of 9.
RoutineOpenedPC-DMIS opened the routine without any errors. This has a value of 1.
UnknownStatusPC-DMIS cannot open the routine due to an unknown cause. This has a value of 0.
out_StatusCode lets you see the status of the OpenEx operation.

Return Type

PartProgram object

Example

This example is tied to a button click in Microsoft Excel. When clicked the code opens a measurement routine as well as the the CAD model in the Graphic Display window. If there's a problem, it displays an error message with the routine's status.
Example (Visual Basic)Copy Code
Private Sub cmdOpenRoutine_Click()

    Dim app As PCDLRN.Application
    Set app = CreateObject("PCDLRN.Application")
    app.Visible = True
    MsgBox "PC-DMIS is here."
   
    Dim PartProgs As PartPrograms
    Set PartProgs = app.PartPrograms
   
    Dim openedPP As PartProgram
          
    Dim strFile As String
    strFile = "C:\Users\Public\Documents\Hexagon\PC-DMIS\2020 R2\TestRoutine.prg"

    Dim RoutineOpenedStatus As PCDLRN.OpenRoutineStatus
   
    RoutineOpenedStatus = InternalError
   
    Set openedPP = PartProgs.OpenEx(strFile, "Offline", True, RoutineOpenedStatus)
    If RoutineOpenedStatus = RoutineOpened Or RoutineOpenedStatus = OpenedBackupCopy Then
      MsgBox "The measurement routine is now open."
    Else
       OpenStatusString = Str(RoutineOpenedStatus)
       MsgBox "The measurement routine Failed to open. Error Code = " + OpenStatusString
    End If

End Sub

See Also

Copyright © 2022. Hexagon Manufacturing Intelligence – Metrology Software, Inc. All Rights Reserved.