Your Products have been synced, click here to refresh
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.
Set MyReading1 = StrDimID.StrDimMeasure
So are you talking to change it like this:
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. Measure ' unsure about this data enumerator, could be 'Actual' instead of 'Measure'
And then, I wasn't meaning the tolerances, but the AX, which I only assume is axis and tells whether you are on the x axis, the y axis, z axis, or measuring a diameter (d). Which I have a variable of StrDimType on top for it, but it isn't called out in the code you laid out for me. And of course that has gotten me all confused again.
Thank you so much for your patience and help.
Kelly
© 2024 Hexagon AB and/or its subsidiaries. | Privacy Policy | Cloud Services Agreement |