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
  • Try this, it should set some of your variables.
    Untested though.

    OK, I thought I had a clue, but apparently not. So here is the code that works...and is not pulling in the dimensions since I can't seem to figure out how to do it, still.

    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

    'Open WinSPC and Collection Plan
    Set dc = CreateObject("WinSPC.DataCollectionAuto")
    dc.Visible = True
    dc.RunHeadless = False
    While dc.ReadyForLogin = "F"
    Wend
    dc.UserName = "1675 CMM"
    dc.Password = "1675"

    dc.CollectionPlanID = 8544
    dc.TagIndex = 0
    dc.TagValue = "KKH"
    dc.CurrentStep = 0
    dc.Value = MyReading1
    dc.CurrentStep = 1
    dc.Value = 0.00011
    dc.CurrentStep = 2
    dc.Value = 3.643
    dc.CurrentStep = 3
    dc.Value = 1.565
    dc.CurrentStep = 4
    dc.Value = 1.345
    dc.CurrentStep = 5
    dc.Value = 7.89
    dc.CurrentStep = 6
    dc.Value = 3.726
    dc.CurrentStep = 7
    dc.Value = 0.00012
    dc.CurrentStep = 8
    dc.Value = .215
    dc.CurrentStep = 9
    dc.Value = .215
    dc.CurrentStep = 10
    dc.Value = .215
    dc.CurrentStep = 11
    dc.Value = .215
    dc.CurrentStep = 12
    dc.Value = .83
    dc.CurrentStep = 13
    dc.Value = 0.000015
    dc.CurrentStep = 14
    dc.Value = 0.000014
    dc.CurrentStep = 15
    dc.Value = .215

    dc.CollectionPlanID = 0
    dc.UserName = " "
    Set dc = Nothing
    End Sub

    And here is the code, that I thought I knew what to do with your hint in it.

    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
    Dim ObjApp As Object
    Dim ObjPP As Object
    Dim ObjCmds As Object
    Dim ObjCmd As Object
    Dim ObjPart As Object
    Dim lngNumCmds As Long

    'Open PCDMIS and ready for output
    Set ObjApp = CreateObject ("PCDLRN.Application")
    Set ObjPart = ObjApp.ActivePartProgram
    Set ObjCmds = ObjPart.Commands
    Set lngNumCmds = ObjCmds.Count

    'Declare output variables
    Dim StrDimID As Object
    Dim StrDimFeature As String
    Dim StrDimType As Object
    Dim StrDimNominal As String
    Dim StrDimUTol As String
    Dim StrDimLTol As String
    Dim StrDimMeasure As String
    Dim i As Integer
    Dim MyReading1 as Double
    Dim ObjDimCmd as Object
    'build output
    For i = 1 To PCDCommands.Count
    Set StrDimID = PCDCommands(i)
    If StrDimID.IsDimension Then
    Set ObjDimCmd = StrDimID.DimensionCommand
    Set StrDimFeature = StrDimID.ID
    Set StrDimNominal = ObjDimCmd.Nominal
    Set StrDimUTol = ObjDimCmd.Plus
    Set StrDimLTol = ObjDimCmd.Minus

    Set MyReading1 = StrDimID.StrDimMeasure

    'Open WinSPC and Collection Plan
    Set dc = CreateObject("WinSPC.DataCollectionAuto")
    dc.Visible = True
    dc.RunHeadless = False
    While dc.ReadyForLogin = "F"
    Wend
    dc.UserName = "1675 CMM"
    dc.Password = "1675"

    dc.CollectionPlanID = 8544
    dc.TagIndex = 0
    dc.TagValue = "KKH"
    dc.CurrentStep = 0
    dc.Value = MyDimensionCmd
    dc.CurrentStep = 1
    dc.Value = 0.00011
    dc.CurrentStep = 2
    dc.Value = 3.643
    dc.CurrentStep = 3
    dc.Value = 1.565
    dc.CurrentStep = 4
    dc.Value = 1.345
    dc.CurrentStep = 5
    dc.Value = 7.89
    dc.CurrentStep = 6
    dc.Value = 3.726
    dc.CurrentStep = 7
    dc.Value = 0.00012
    dc.CurrentStep = 8
    dc.Value = .215
    dc.CurrentStep = 9
    dc.Value = .215
    dc.CurrentStep = 10
    dc.Value = .215
    dc.CurrentStep = 11
    dc.Value = .215
    dc.CurrentStep = 12
    dc.Value = .83
    dc.CurrentStep = 13
    dc.Value = 0.000015
    dc.CurrentStep = 14
    dc.Value = 0.000014
    dc.CurrentStep = 15
    dc.Value = .215

    dc.CollectionPlanID = 0
    dc.UserName = " "
    Set dc = Nothing
    End Sub


    Please help me, because I am so lost and confused.
Reply
  • Try this, it should set some of your variables.
    Untested though.

    OK, I thought I had a clue, but apparently not. So here is the code that works...and is not pulling in the dimensions since I can't seem to figure out how to do it, still.

    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

    'Open WinSPC and Collection Plan
    Set dc = CreateObject("WinSPC.DataCollectionAuto")
    dc.Visible = True
    dc.RunHeadless = False
    While dc.ReadyForLogin = "F"
    Wend
    dc.UserName = "1675 CMM"
    dc.Password = "1675"

    dc.CollectionPlanID = 8544
    dc.TagIndex = 0
    dc.TagValue = "KKH"
    dc.CurrentStep = 0
    dc.Value = MyReading1
    dc.CurrentStep = 1
    dc.Value = 0.00011
    dc.CurrentStep = 2
    dc.Value = 3.643
    dc.CurrentStep = 3
    dc.Value = 1.565
    dc.CurrentStep = 4
    dc.Value = 1.345
    dc.CurrentStep = 5
    dc.Value = 7.89
    dc.CurrentStep = 6
    dc.Value = 3.726
    dc.CurrentStep = 7
    dc.Value = 0.00012
    dc.CurrentStep = 8
    dc.Value = .215
    dc.CurrentStep = 9
    dc.Value = .215
    dc.CurrentStep = 10
    dc.Value = .215
    dc.CurrentStep = 11
    dc.Value = .215
    dc.CurrentStep = 12
    dc.Value = .83
    dc.CurrentStep = 13
    dc.Value = 0.000015
    dc.CurrentStep = 14
    dc.Value = 0.000014
    dc.CurrentStep = 15
    dc.Value = .215

    dc.CollectionPlanID = 0
    dc.UserName = " "
    Set dc = Nothing
    End Sub

    And here is the code, that I thought I knew what to do with your hint in it.

    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
    Dim ObjApp As Object
    Dim ObjPP As Object
    Dim ObjCmds As Object
    Dim ObjCmd As Object
    Dim ObjPart As Object
    Dim lngNumCmds As Long

    'Open PCDMIS and ready for output
    Set ObjApp = CreateObject ("PCDLRN.Application")
    Set ObjPart = ObjApp.ActivePartProgram
    Set ObjCmds = ObjPart.Commands
    Set lngNumCmds = ObjCmds.Count

    'Declare output variables
    Dim StrDimID As Object
    Dim StrDimFeature As String
    Dim StrDimType As Object
    Dim StrDimNominal As String
    Dim StrDimUTol As String
    Dim StrDimLTol As String
    Dim StrDimMeasure As String
    Dim i As Integer
    Dim MyReading1 as Double
    Dim ObjDimCmd as Object
    'build output
    For i = 1 To PCDCommands.Count
    Set StrDimID = PCDCommands(i)
    If StrDimID.IsDimension Then
    Set ObjDimCmd = StrDimID.DimensionCommand
    Set StrDimFeature = StrDimID.ID
    Set StrDimNominal = ObjDimCmd.Nominal
    Set StrDimUTol = ObjDimCmd.Plus
    Set StrDimLTol = ObjDimCmd.Minus

    Set MyReading1 = StrDimID.StrDimMeasure

    'Open WinSPC and Collection Plan
    Set dc = CreateObject("WinSPC.DataCollectionAuto")
    dc.Visible = True
    dc.RunHeadless = False
    While dc.ReadyForLogin = "F"
    Wend
    dc.UserName = "1675 CMM"
    dc.Password = "1675"

    dc.CollectionPlanID = 8544
    dc.TagIndex = 0
    dc.TagValue = "KKH"
    dc.CurrentStep = 0
    dc.Value = MyDimensionCmd
    dc.CurrentStep = 1
    dc.Value = 0.00011
    dc.CurrentStep = 2
    dc.Value = 3.643
    dc.CurrentStep = 3
    dc.Value = 1.565
    dc.CurrentStep = 4
    dc.Value = 1.345
    dc.CurrentStep = 5
    dc.Value = 7.89
    dc.CurrentStep = 6
    dc.Value = 3.726
    dc.CurrentStep = 7
    dc.Value = 0.00012
    dc.CurrentStep = 8
    dc.Value = .215
    dc.CurrentStep = 9
    dc.Value = .215
    dc.CurrentStep = 10
    dc.Value = .215
    dc.CurrentStep = 11
    dc.Value = .215
    dc.CurrentStep = 12
    dc.Value = .83
    dc.CurrentStep = 13
    dc.Value = 0.000015
    dc.CurrentStep = 14
    dc.Value = 0.000014
    dc.CurrentStep = 15
    dc.Value = .215

    dc.CollectionPlanID = 0
    dc.UserName = " "
    Set dc = Nothing
    End Sub


    Please help me, because I am so lost and confused.
Children
No Data