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.
Thank you for the other stuff, but here is where I am right now.
This code works and puts the information where I need it and is great.
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
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
StrDimType = ObjCmd.DimensionCommand.AxisLetter
StrDimNominal = ObjCmd.DimensionCommand.Nominal
StrDimUTol = ObjCmd.DimensionCommand.Plus
StrDimLTol = ObjCmd.DimensionCommand.Minus
StrDimMeasure = ObjCmd.DimensionCommand.Measured
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
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"
Never worked with the DimData object, so I can't tell for sure.
You must assign the DimData to an existing dimension evaluation (I think) otherwise it will be zero/nothing?
If we work with the DimensionCommand further, what data are you missing that you can't fetch from that?
It gives me a zero, like it is null. My guess is either I am working with the wrong set up for the variables or that I am calling them out wrong. I am just not sure. So if I say that the measurement of circ2 dia is the output for reading1, I get a zero, but the roundness of circ2 gives me the measurement. I really am not sure what is wrong in the code, but it is not working quite as expected.
Thanks for any ideas you may have to fix this issue.
Here is what I have found through investigating. If the measurement I want has an AX (I assume axis) of M, then I get the readout. If it has another AX (D, Z, etc) then I get a null reading (0). So there must be something in there that I need to pull out.
So, I tried this (example): If StrDimID = "CIRC2 DIA" And StrDimType= "D" Then MyReading1 = StrDimMeasure, but that gave me a null reading as well. Maybe And is not a valid command word?
Is the actual dimension named "CIRC2 DIA" in the partprogram?
...or are you trying to grab the diameter from a feature (a measured circle)?
What you can do, is export the partprogram to a BASIC file, preferrably the exact program you are working with.
That way, you will get the syntax and other valuable stuff directly in the BASIC flavour.
(sorry for not suggesting this earlier, it just hit me)