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
  • Begin VB.Form Form1
    caption = "Visual Basic OLE Client for WinSPC"
    ClientHeight = 4485
    ClientLeft = 60
    ClientTop = 630
    ClientWidth = 6150
    LinkTopic = "Form1"
    ScaleHeight = 4485
    ScaleWidth = 6150
    Begin VB.TextBox Text1
    Height = 4455
    Left = 0
    MultiLine = -1 'True
    ScrollBars = 2 'Vertical
    TabIndex = 0
    Top = 0
    Width = 6135
    End
    Begin VB.Menu RunMenu
    Caption = "&Run"
    End
    End
    Attribute VB_Name = "Form1"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredID = True
    Attribute VB_Expose = False





    '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



    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 StrDimDiameter As String
    Dim MeasZ 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
    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
    ElseIf ObjCmd.IsFeature Then
    StrDimID = ObjCmd.FeatureCommand.ID
    StrDimDiameter = ObjCmd.FeatureCommand.MeasDiam
    MeasZ = ObjCmd.GetText(MEAS_Z,0)
    End If





    If StrDimID = "CIR2- OUTER CIRCLE ABOVE STEP" Then MyReading1 = StrDimDiameter
    If StrDimID = "CIR2 ROUNDNESS" Then MyReading2 = StrDimMeasure
    If StrDimID = "CIR3- RADIUS OF STEP OUTER EDGE" Then MyReading3 = StrDimDiameter
    If StrDimID = "CIR4- SNOUT OD" Then MyReading4 = StrDimDiameter
    If StrDimID = "CIR7- SNOUT ID" Then MyReading5 = StrDimDiameter
    If StrDimID = "CIR8- SMALL PORT INSIDE SNOUT" Then MyReading6 = StrDimDiameter
    If StrDimID = "CIR6- OUTER CIRCLE UNDER STEP" Then MyReading7 = StrDimDiameter
    If StrDimID = "CIRC6 ROUNDNESS" Then MyReading8 = StrDimMeasure
    If StrDimID = "POINT1- ON STEP" Then MyReading9 = MeasZ
    If StrDimID = "POINT2- ON STEP" Then MyReading10 = MeasZ
    If StrDimID = "POINT3- ON STEP" Then MyReading11 = MeasZ
    If StrDimID = "POINT4- ON STEP" Then MyReading12 = MeasZ
    If StrDimID = "DIST1" Then MyReading13 = StrDimMeasure
    If StrDimID = "CONC1" Then MyReading14 = StrDimMeasure
    If StrDimID = "CONC2" Then MyReading15 = StrDimMeasure
    If StrDimID = "PLANE5- TOP SURFACE OF BAFFLE" Then MyReading16 = MeasZ
    Next

    After this you place the MyReading# variables in the locations or the other program that you need the information in.

    Why the MeasZ statement works when it is in the functioncommand block and not in the dimension command block or just after the for each objcmd in objcmds statement I don't know. It doesn't make sense to me. But we now have a functional way to export information from PCDMIS and place specific information in specific places.

    Again, thank you for all your help.
Reply
  • Begin VB.Form Form1
    caption = "Visual Basic OLE Client for WinSPC"
    ClientHeight = 4485
    ClientLeft = 60
    ClientTop = 630
    ClientWidth = 6150
    LinkTopic = "Form1"
    ScaleHeight = 4485
    ScaleWidth = 6150
    Begin VB.TextBox Text1
    Height = 4455
    Left = 0
    MultiLine = -1 'True
    ScrollBars = 2 'Vertical
    TabIndex = 0
    Top = 0
    Width = 6135
    End
    Begin VB.Menu RunMenu
    Caption = "&Run"
    End
    End
    Attribute VB_Name = "Form1"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredID = True
    Attribute VB_Expose = False





    '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



    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 StrDimDiameter As String
    Dim MeasZ 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
    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
    ElseIf ObjCmd.IsFeature Then
    StrDimID = ObjCmd.FeatureCommand.ID
    StrDimDiameter = ObjCmd.FeatureCommand.MeasDiam
    MeasZ = ObjCmd.GetText(MEAS_Z,0)
    End If





    If StrDimID = "CIR2- OUTER CIRCLE ABOVE STEP" Then MyReading1 = StrDimDiameter
    If StrDimID = "CIR2 ROUNDNESS" Then MyReading2 = StrDimMeasure
    If StrDimID = "CIR3- RADIUS OF STEP OUTER EDGE" Then MyReading3 = StrDimDiameter
    If StrDimID = "CIR4- SNOUT OD" Then MyReading4 = StrDimDiameter
    If StrDimID = "CIR7- SNOUT ID" Then MyReading5 = StrDimDiameter
    If StrDimID = "CIR8- SMALL PORT INSIDE SNOUT" Then MyReading6 = StrDimDiameter
    If StrDimID = "CIR6- OUTER CIRCLE UNDER STEP" Then MyReading7 = StrDimDiameter
    If StrDimID = "CIRC6 ROUNDNESS" Then MyReading8 = StrDimMeasure
    If StrDimID = "POINT1- ON STEP" Then MyReading9 = MeasZ
    If StrDimID = "POINT2- ON STEP" Then MyReading10 = MeasZ
    If StrDimID = "POINT3- ON STEP" Then MyReading11 = MeasZ
    If StrDimID = "POINT4- ON STEP" Then MyReading12 = MeasZ
    If StrDimID = "DIST1" Then MyReading13 = StrDimMeasure
    If StrDimID = "CONC1" Then MyReading14 = StrDimMeasure
    If StrDimID = "CONC2" Then MyReading15 = StrDimMeasure
    If StrDimID = "PLANE5- TOP SURFACE OF BAFFLE" Then MyReading16 = MeasZ
    Next

    After this you place the MyReading# variables in the locations or the other program that you need the information in.

    Why the MeasZ statement works when it is in the functioncommand block and not in the dimension command block or just after the for each objcmd in objcmds statement I don't know. It doesn't make sense to me. But we now have a functional way to export information from PCDMIS and place specific information in specific places.

    Again, thank you for all your help.
Children
No Data