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.
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 = 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
'build output
For i = 1 To PCDCommands.Count
Set StrDimID = PCDCommands(i)
If StrDimID.IsDimension Then
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"
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 = 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
'build output
For i = 1 To PCDCommands.Count
Set StrDimID = PCDCommands(i)
If StrDimID.IsDimension Then
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"