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
  • But now I need to pull in the information from comment boxes, as in the operators will input their clock number and other information that we have to have as well.

    I think it should go something like this, but I am not completely sure at all:
    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
    'PCDMIS commands
    Dim ObjPP As Object
    Dim ObjCmds As Object
    Dim ObjCmd As Object
    Dim ObjPart As Object
    Dim ComInput As Object
    Dim lngNumCmds As Long
    Set ObjApp = CreateObject("PCDLRN.Application")
    Set ObjPart = ObjApp.ActivePartProgram
    Set ObjCmds = ObjPart.Commands
    set lngNumCmds = ObjCmds.Count
    Set ComInput = ObjPart.Comments

    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 StrDimActual As String
    Dim ComComment As Double
    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
    StrDimID = ObjCmd.DimensionCommand.ID
    StrDimFeature = ObjCmd.DimensionCommand.Feat1
    StrDimActual = ObjCmd.DimensionCommand.Actual
    StrDimType = ObjCmd.DimensionCommand.AxisLetter
    StrDimNominal = ObjCmd.DimensionCommand.Nominal
    StrDimUTol = ObjCmd.DimensionCommand.Plus
    StrDimLTol = ObjCmd.DimensionCommand.Minus
    StrDimMeasure = ObjCmd.DimensionCommand.Measured
    End If

    If ComInput.IsComment Then
    ComComment = ComInput.Comment.Input
    End If

    If StrDimID = "CIRC2 DIA" Then MyReading1 = StrDimMeasure
    If StrDimID = "CIR2 ROUNDNESS" Then MyReading2 = StrDimMeasure
    If StrDimID = "CIRC3 DIA"Then MyReading3 = StrDimMeasure
    If StrDimID = "CIRC4 DIA" Then MyReading4 = StrDimMeasure
    If StrDimID = "CIRC7 DIA" Then MyReading5 = StrDimMeasure
    If StrDimID = "CIRC8 DIA" Then MyReading6 = StrDimMeasure
    If StrDimID = "CIRC6 DIA" Then MyReading7 = StrDimMeasure
    If StrDimID = "CIRC6 ROUNDNESS" Then MyReading8 = StrDimMeasure
    If StrDimID = "POINT1 Z" Then MyReading9 = StrDimMeasure
    If StrDimID = "POINT2 Z" Then MyReading10 = StrDimMeasure
    If StrDimID = "POINT3 z" Then MyReading11 = StrDimMeasure
    If StrDimID = "POINT4 Z" Then MyReading12 = StrDimMeasure
    If StrDimID = "DIST1" Then MyReading13 = StrDimMeasure
    If StrDimID = "CONC1" Then MyReading14 = StrDimMeasure
    If StrDimID = "CONC2" Then MyReading15 = StrDimMeasure
    If StrDimID = "PLANE5 Z" Then MyReading16 = StrDimMeasure
    Next




    '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 = ComComment
    dc.CurrentStep = 0
    dc.Value = MyReading1
    dc.CurrentStep = 1
    dc.Value = MyReading2
    dc.CurrentStep = 2
    dc.Value = MyReading3
    dc.CurrentStep = 3
    dc.Value = MyReading4
    dc.CurrentStep = 4
    dc.Value = MyReading5
    dc.CurrentStep = 5
    dc.Value = MyReading6
    dc.CurrentStep = 6
    dc.Value = MyReading7
    dc.CurrentStep = 7
    dc.Value = MyReading8
    dc.CurrentStep = 8
    dc.Value = MyReading9
    dc.CurrentStep = 9
    dc.Value = MyReading10
    dc.CurrentStep = 10
    dc.Value = MyReading11
    dc.CurrentStep = 11
    dc.Value = MyReading12
    dc.CurrentStep = 12
    dc.Value = MyReading13
    dc.CurrentStep = 13
    dc.Value = MyReading14
    dc.CurrentStep = 14
    dc.Value = MyReading15
    dc.CurrentStep = 15
    dc.Value = MyReading16

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


    Any thoughts on this part of my little OLE project? Thank you again, for your help and patience.
Reply
  • But now I need to pull in the information from comment boxes, as in the operators will input their clock number and other information that we have to have as well.

    I think it should go something like this, but I am not completely sure at all:
    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
    'PCDMIS commands
    Dim ObjPP As Object
    Dim ObjCmds As Object
    Dim ObjCmd As Object
    Dim ObjPart As Object
    Dim ComInput As Object
    Dim lngNumCmds As Long
    Set ObjApp = CreateObject("PCDLRN.Application")
    Set ObjPart = ObjApp.ActivePartProgram
    Set ObjCmds = ObjPart.Commands
    set lngNumCmds = ObjCmds.Count
    Set ComInput = ObjPart.Comments

    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 StrDimActual As String
    Dim ComComment As Double
    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
    StrDimID = ObjCmd.DimensionCommand.ID
    StrDimFeature = ObjCmd.DimensionCommand.Feat1
    StrDimActual = ObjCmd.DimensionCommand.Actual
    StrDimType = ObjCmd.DimensionCommand.AxisLetter
    StrDimNominal = ObjCmd.DimensionCommand.Nominal
    StrDimUTol = ObjCmd.DimensionCommand.Plus
    StrDimLTol = ObjCmd.DimensionCommand.Minus
    StrDimMeasure = ObjCmd.DimensionCommand.Measured
    End If

    If ComInput.IsComment Then
    ComComment = ComInput.Comment.Input
    End If

    If StrDimID = "CIRC2 DIA" Then MyReading1 = StrDimMeasure
    If StrDimID = "CIR2 ROUNDNESS" Then MyReading2 = StrDimMeasure
    If StrDimID = "CIRC3 DIA"Then MyReading3 = StrDimMeasure
    If StrDimID = "CIRC4 DIA" Then MyReading4 = StrDimMeasure
    If StrDimID = "CIRC7 DIA" Then MyReading5 = StrDimMeasure
    If StrDimID = "CIRC8 DIA" Then MyReading6 = StrDimMeasure
    If StrDimID = "CIRC6 DIA" Then MyReading7 = StrDimMeasure
    If StrDimID = "CIRC6 ROUNDNESS" Then MyReading8 = StrDimMeasure
    If StrDimID = "POINT1 Z" Then MyReading9 = StrDimMeasure
    If StrDimID = "POINT2 Z" Then MyReading10 = StrDimMeasure
    If StrDimID = "POINT3 z" Then MyReading11 = StrDimMeasure
    If StrDimID = "POINT4 Z" Then MyReading12 = StrDimMeasure
    If StrDimID = "DIST1" Then MyReading13 = StrDimMeasure
    If StrDimID = "CONC1" Then MyReading14 = StrDimMeasure
    If StrDimID = "CONC2" Then MyReading15 = StrDimMeasure
    If StrDimID = "PLANE5 Z" Then MyReading16 = StrDimMeasure
    Next




    '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 = ComComment
    dc.CurrentStep = 0
    dc.Value = MyReading1
    dc.CurrentStep = 1
    dc.Value = MyReading2
    dc.CurrentStep = 2
    dc.Value = MyReading3
    dc.CurrentStep = 3
    dc.Value = MyReading4
    dc.CurrentStep = 4
    dc.Value = MyReading5
    dc.CurrentStep = 5
    dc.Value = MyReading6
    dc.CurrentStep = 6
    dc.Value = MyReading7
    dc.CurrentStep = 7
    dc.Value = MyReading8
    dc.CurrentStep = 8
    dc.Value = MyReading9
    dc.CurrentStep = 9
    dc.Value = MyReading10
    dc.CurrentStep = 10
    dc.Value = MyReading11
    dc.CurrentStep = 11
    dc.Value = MyReading12
    dc.CurrentStep = 12
    dc.Value = MyReading13
    dc.CurrentStep = 13
    dc.Value = MyReading14
    dc.CurrentStep = 14
    dc.Value = MyReading15
    dc.CurrentStep = 15
    dc.Value = MyReading16

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


    Any thoughts on this part of my little OLE project? Thank you again, for your help and patience.
Children
No Data