hexagon logo

Help with OLE Automation

Now that I have information in a way that imports and exports the information correctly, I have been tasked with creating an OLE to automatically import the data into the SPC software. I have one that sort of works (as in opens the program, logs in, opens the right collection plan, etc) and I can get put in static information, but I am unsure how to call the information out of PC DMIS to have it be placed in the spots we need in the SPC software being used.

Has anyone else done this? Can anyone explain to me how find the variable and the measurement output in PC DMIS? I am using version 4.2 if that helps any.

Thanks so much.
Parents
  • 'Declare variables
    Sub main
    Dim PartObj As Object
    Dim CPObj As Object
    Dim DCObj As Object
    Dim DBObj As Object
    Dim UserName As String
    Dim Password As String
    Dim sPart As String
    Dim sVar1 As String
    Dim sVar2 As String
    Dim sCollPlan As String
    Dim PartID As Long
    Dim Var1ID As Long
    Dim Var2ID As Long
    Dim CollPlanID As Long
    Dim Step1ID As Long
    Dim Step2ID As Long
    Dim CollectionPlanID As Object
    Dim dc As Object


    'PCDMIS commands
    Dim ObjApp As Object
    Dim ObjCmds As Object
    Dim ObjCmd As Object
    Dim ObjPart As Object
    Dim ObjDimCmd as Object
    Dim lngNumCmds As Long
    Set ObjApp = CreateObject("PCDLRN.Application")
    Set ObjPart = ObjApp.ActivePartProgram
    Set ObjCmds = ObjPart.Commands
    set lngNumCmds = ObjCmds.Count
    Set ObjDimCmd = ObjCmds.DimensionCommand


    Dim StrDimID As String
    Dim StrDimFeature As String
    Dim StrDimType As String
    Dim StrDimNominal As String
    Dim StrDimUTol As String
    Dim StrDimLTol As String
    Dim StrDimMeasure As String
    Dim MyReading1 As Double
    Dim MyReading2 As Double
    Dim MyReading3 As Double
    Dim MyReading4 As Double
    Dim MyReading5 As Double
    Dim MyReading6 As Double
    Dim MyReading7 As Double
    Dim MyReading8 As Double
    Dim MyReading9 As Double
    Dim MyReading10 As Double
    Dim MyReading11 As Double
    Dim MyReading12 As Double
    Dim MyReading13 As Double
    Dim MyReading14 As Double
    Dim MyReading15 As Double
    Dim MyReading16 As Double


    For Each ObjCmd In ObjCmds
    StrDimDiameter = ObjCmd.GetText (MEAS_DIAM, 0)
    MeasZ = ObjCmd.GetText (DIM_MEASURED, 0)
    If ObjCmd.IsDimension Then
    Set ObjDimCmd = ObjCmd.DimensionCommand
    StrDimID = ObjDimCmd.ID
    StrDimFeature = ObjDimCmd.Feat1
    StrDimType = ObjDimCmd.AxisLetter
    StrDimNominal = ObjDimCmd.Nominal
    StrDimUTol = ObjDimCmd.Plus
    StrDimLTol = ObjDimCmd.Minus
    StrDimMeasure = ObjDimCmd.Measured
    End If

    If I run this like I have it above, then I don't get an error of an unrecognized DimensionCommand, but I still get the zero (I am guessing null) reading for the StrDimDiameter and MeasZ variables. To add in the feature commands, do I write it out like above and do an if ObjCmd.IsFeature then StrDimID = ObjDimCmd.ID, etc?
Reply
  • 'Declare variables
    Sub main
    Dim PartObj As Object
    Dim CPObj As Object
    Dim DCObj As Object
    Dim DBObj As Object
    Dim UserName As String
    Dim Password As String
    Dim sPart As String
    Dim sVar1 As String
    Dim sVar2 As String
    Dim sCollPlan As String
    Dim PartID As Long
    Dim Var1ID As Long
    Dim Var2ID As Long
    Dim CollPlanID As Long
    Dim Step1ID As Long
    Dim Step2ID As Long
    Dim CollectionPlanID As Object
    Dim dc As Object


    'PCDMIS commands
    Dim ObjApp As Object
    Dim ObjCmds As Object
    Dim ObjCmd As Object
    Dim ObjPart As Object
    Dim ObjDimCmd as Object
    Dim lngNumCmds As Long
    Set ObjApp = CreateObject("PCDLRN.Application")
    Set ObjPart = ObjApp.ActivePartProgram
    Set ObjCmds = ObjPart.Commands
    set lngNumCmds = ObjCmds.Count
    Set ObjDimCmd = ObjCmds.DimensionCommand


    Dim StrDimID As String
    Dim StrDimFeature As String
    Dim StrDimType As String
    Dim StrDimNominal As String
    Dim StrDimUTol As String
    Dim StrDimLTol As String
    Dim StrDimMeasure As String
    Dim MyReading1 As Double
    Dim MyReading2 As Double
    Dim MyReading3 As Double
    Dim MyReading4 As Double
    Dim MyReading5 As Double
    Dim MyReading6 As Double
    Dim MyReading7 As Double
    Dim MyReading8 As Double
    Dim MyReading9 As Double
    Dim MyReading10 As Double
    Dim MyReading11 As Double
    Dim MyReading12 As Double
    Dim MyReading13 As Double
    Dim MyReading14 As Double
    Dim MyReading15 As Double
    Dim MyReading16 As Double


    For Each ObjCmd In ObjCmds
    StrDimDiameter = ObjCmd.GetText (MEAS_DIAM, 0)
    MeasZ = ObjCmd.GetText (DIM_MEASURED, 0)
    If ObjCmd.IsDimension Then
    Set ObjDimCmd = ObjCmd.DimensionCommand
    StrDimID = ObjDimCmd.ID
    StrDimFeature = ObjDimCmd.Feat1
    StrDimType = ObjDimCmd.AxisLetter
    StrDimNominal = ObjDimCmd.Nominal
    StrDimUTol = ObjDimCmd.Plus
    StrDimLTol = ObjDimCmd.Minus
    StrDimMeasure = ObjDimCmd.Measured
    End If

    If I run this like I have it above, then I don't get an error of an unrecognized DimensionCommand, but I still get the zero (I am guessing null) reading for the StrDimDiameter and MeasZ variables. To add in the feature commands, do I write it out like above and do an if ObjCmd.IsFeature then StrDimID = ObjDimCmd.ID, etc?
Children
No Data