Your Products have been synced, click here to refresh
Just reading through this whole post for my own interest and I was thinking the same thing about this needing to be done for each and every program. I really have no coding skills. But, if I were looking to make a generic program to grab all this information, the first thing I would do is set some ground rules for the CMM programmers. Tell them that for all dimensions that need to be tracked or added to spc, they must be the only dimensions named a specific way and only that way. This would make your job a little easier. They need to work with you, not cause more issues. I agree though with DJAMS that if it can be done much easier with a purchased software then do it that way. Forgive my intrusion.
Here's a script for exporting all legacy dimensions (no FCF) in a program to a CSV formatted text file. Maybe it can give you some ideas?
Note that some dimensions (LOCATION and POSITION) show up as multiple commands when looping through the program code:
- a dimension START command (with the name, but no data)
- one command for each axis that you dimension (X, Y, Z etc.) (with the data, but no name)
- a dimension END command
' ================================================================ ' The export file format: ' FeatType,FeatName,ValueID,Meas,Theo,Dev,-Tol,+Tol,OutTol,Comment ' ================================================================ ' ' Change history ' ' 2005-11-16 PCDMIS bugs With True position: ' ' We can have OutTol <> 0 (very small number) even when Deviation = 0, also ' Deviation can be a very small number (looks like conversion artifacts Single <--> Double) ' ' If Abs(Dev) < 0.00005 Set elDev = 0 Else Set elDev = Deviation ' If Abs(OutTol) < 0.00005 Set elOutTol = 0 Else Set elOutTol = OutTol ' ' True Position can have Nominal = 0, Measured = 0 but Deviation <> 0 ' Solved by setting elAct = Nominal + elDev ' ' Note: This script does *not* handle FCF dimensions ' ================================================================ ' Dim elType As String Dim elName As String Dim elValueType As String Dim elAct As Double Dim elNom As Double Dim elDev As Double Dim elMtol As Double Dim elPtol As Double Dim elOutTol As Double Dim elComment As String Dim elStarted As Integer ' ================================================================ Sub ClearRecord elType = "type" elName = "name" elValueType = "valuetype" elAct = 0 elNom = 0 elDev = 0 elMtol = 0 elPtol = 0 elOutTol = 0 elComment = "" End Sub Sub PrintLine(FileNum%) If elStarted Then Print #FileNum, elType; ","; elName; ","; elValueType; ","; elAct; ","; elNom; ","; elDev; "," ; elMtol; ","; elPtol; ","; elOutTol; ","; elComment elStarted = 0 End If End Sub Sub ExportAsCSV(FileName$) Dim DmisApp As Object Dim DmisPart As Object Dim DmisCommands As Object Dim DmisCommand As Object Dim DmisDimension As Object Dim ix As Integer Dim fNum As Integer Dim ID As String Dim State As Integer Dim DoOutput As Integer fNum = FreeFile Open FileName$ For Output As fNum ' 2005-11-17 Print #fNum, "' FeatType,FeatName,ValueID,Meas,Theo,Dev,-Tol,+Tol,OutTol,Comment" ' ---------- Set DmisApp = CreateObject("PCDLRN.Application") Set DmisPart = DmisApp.ActivePartProgram Set DmisCommands = DmisPart.Commands elStarted = 0 State = 1 For ix = 1 To DmisCommands.Count Set DmisCommand = DmisCommands(ix) If DmisCommand.IsDimension Then Set DmisDimension = DmisCommand.DimensionCommand Select Case State Case 1 ' Normal Case If (DmisDimension.OutputMode <> DIMOUTPUT_NONE) Then DoOutput = 1 Else DoOutput = 0 End If ID = DmisDimension.ID If (DmisCommand.Type = DIMENSION_TRUE_START_POSITION) Then State = 2 ElseIf (DmisCommand.Type = DIMENSION_START_LOCATION) Then State = 3 End If If (DoOutput = 1) And (State = 1) Then PrintLine(fNum) ClearRecord elType = DmisCommand.TypeDescription elName = ID ' 2005-11-17 If DmisDimension.AxisLetter = "D" Then elValueType = "DIAM" Elseif DmisDimension.AxisLetter = "R" Then elValueType = "RAD" Else elValueType = DmisDimension.AxisLetter End If ' --------- elNom = DmisDimension.Nominal ' 2005-11-16 If (Abs(DmisDimension.Deviation) > 0.00005) Then elDev = DmisDimension.Deviation Else elDev = 0 End If elAct = DmisDimension.Nominal + elDev ' --------- elMtol = -DmisDimension.Minus elPtol = DmisDimension.Plus ' 2005-11-16 If (Abs(DmisDimension.OutTol) > 0.00005) Then elOutTol = DmisDimension.OutTol Else elOutTol = 0 End If ' --------- elComment = "" elStarted = 1 End If Case 2 ' True Position If (DoOutput = 1) Then PrintLine(fNum) ClearRecord elType = DmisCommand.TypeDescription elName = ID ' 2005-11-17 If DmisDimension.AxisLetter = "D" Then elValueType = "DIAM" Elseif DmisDimension.AxisLetter = "R" Then elValueType = "RAD" Else elValueType = DmisDimension.AxisLetter End If ' --------- elNom = DmisDimension.Nominal ' 2005-11-16 If (Abs(DmisDimension.Deviation) > 0.00005) Then elDev = DmisDimension.Deviation Else elDev = 0 End If elAct = DmisDimension.Nominal + elDev ' --------- elMtol = -DmisDimension.Minus elPtol = DmisDimension.Plus ' 2005-11-16 If (Abs(DmisDimension.OutTol) > 0.00005) Then elOutTol = DmisDimension.OutTol Else elOutTol = 0 End If ' --------- elComment = "" elStarted = 1 End If Case 3 ' Location If (DoOutput = 1) Then PrintLine(fNum) ClearRecord elType = DmisCommand.TypeDescription elName = ID ' 2005-11-17 If DmisDimension.AxisLetter = "D" Then elValueType = "DIAM" Elseif DmisDimension.AxisLetter = "R" Then elValueType = "RAD" Else elValueType = DmisDimension.AxisLetter End If ' --------- elNom = DmisDimension.Nominal ' 2005-11-16 If (Abs(DmisDimension.Deviation) > 0.00005) Then elDev = DmisDimension.Deviation Else elDev = 0 End If elAct = DmisDimension.Nominal + elDev ' --------- elMtol = -DmisDimension.Minus elPtol = DmisDimension.Plus ' 2005-11-16 If (Abs(DmisDimension.OutTol) > 0.00005) Then elOutTol = DmisDimension.OutTol Else elOutTol = 0 End If ' --------- elComment = "" elStarted = 1 End If End Select Set DmisDimension = Nothing ElseIf (DmisCommand.Type = DIMENSION_TRUE_END_POSITION) Then State = 1 ElseIf (DmisCommand.Type = DIMENSION_END_LOCATION) Then State = 1 End If Set DmisCommand = Nothing Next ix Set DmisCommands = Nothing Set DmisPart = Nothing Set DmisApp = Nothing PrintLine(fNum) Close #fNum Print "Klart" End Sub Sub Main(FileName$) 'ExportAsCSV(FileName$) ' For deployment ExportAsCSV("EXPORT.TXT") ' For testing End Sub
Adding FCF dimensions to this is non-trivial, and nearly doubles the script size...
if I were looking to make a generic program to grab all this information, the first thing I would do is set some ground rules for the CMM programmers. Tell them that for all dimensions that need to be tracked or added to spc, they must be the only dimensions named a specific way and only that way.
No need to complicate things and reinvent exiting wheels. Every dimension has a 'print flag' which can be NONE, REPORT, STATS, BOTH. That's the "DmisDimension.OutputMode" that my script above checks (although that script writes to a file everything which doesn't have the flag "NONE", no discrimination between REPORT/STATS/BOTH).
If/when the programs have this flag correctly set for all dimensions it's easy. Those that are flagged STATS or BOTH are the ones that should be sent on, irrespective of their name.
The SPC system may place restrictions on names, too, but that shouldn't concern this script.
(Unless I have completely misunderstood something)
Sub PCDinfo 'Gather Information from part program Set ObjApp = CreateObject ("PCDLRN.Application") Set ObjPart = ObjApp.ActivePartProgram Set ObjCmds = ObjPart.Commands State = 1 For ix = 1 To ObjCmds.Count Set ObjCmd = ObjCmds(ix) For Each ObjCmd in ObjCmds If ObjCmd.IsComment Then If ObjCmd.CommentCommand.CommentType = PCD_COMMENT_INPUT Then If ObjCmd.ID = "C1" Then StrC1 = ObjCmd.CommentCommand.Input End If End If End If If ObjCmd.IsComment Then If ObjCmd.CommentCommand.CommentType = PCD_COMMENT_INPUT Then If ObjCmd.ID = "C2" Then StrC2 = ObjCmd.CommentCommand.Input End If End If End If If ObjCmd.IsDimension Then Set ObjDimCmd = ObjCmd.DimensionCommand Select Case State Case 1 'Normal case If (ObjDimCmd.OutputMOde <> DIMOUTPUT_NONE) Then DoOutPut = 1 Else DoOutPut = 0 End If StrDimID = ObjDimCmd.ID If (ObjDimCmd.Type = DIMENSION_TRUE_START_POSITION) Then State = 2 ElseIf (ObjDimCmd.Type = DIMENSION_START_LOCATION) Then State = 3 End If If (DoOutPut = 1) and (State = 1) Then StrDimType = ObjDimCmd.TypeDescription StrDimValueType = ObjDimCmd.AxisLetter End If StrDimNom = ObjDimCmd.Nominal StrDimDev = ObjDimCmd.Deviation StrDimAct = StrDimNom + StrDimDev Case 2 'True Position If (DoOutPut = 1) Then StrDimID = ObjDimCmd.ID StrDimType = ObjDimCmd.TypeDescription StrDimValueType = ObjDimCmd.AxisLetter End If StrDimNom = ObjDimCmd.Nominal StrDimDev = ObjDimCmd.Deviation StrDimAct = StrDimNom + StrDimDev Case 3 'Location If (DoOutPut = 1) Then StrDimID = ObjDimCmd.ID StrDimType = ObjDimCmd.TypeDescription StrDimValueType = ObjDimCmd.AxisLetter End If StrDimNom = ObjDimCmd.Nominal StrDimDev = ObjDimCmd.Deviation StrDimAct = StrDimNom + StrDimDev End Select If (ObjDimCmd.Type = DIMENSION_TRUE_END_POSITION) Then State = 1 ElseIf (ObjDimCmd.Type = DIMENSION_END_LOCATION) Then State = 1 End If If (StrDimID = "CIRC2 DIA") Then MyReading1 = StrDimAct End If If (StrDimID = "ROUNDNESS CIRC2") Then MyReading2 = StrDimAct End If If (StrDimID = "CIRC3 DIA") Then MyReading3 = StrDimAct End If If (StrDimID = "CIRC6 DIA") Then MyReading4 = StrDimAct End If If (StrDimID = "ROUNDNESS CIRC6") Then MyReading5 = StrDimAct End If If (StrDimID = "CONC1") Then MyReading6 = StrDimAct End If If (StrDimID = "CONC2") Then MyReading7 = StrDimAct If (StrDimID = "POINT 1Z") Then MyReading8 = StrDimAct End If If (StrDimID = "POINT 2Z") Then MyReading9 = StrDimAct End If If (StrDimID = "POINT 3Z") Then MyReading10 = StrDimAct End If If (StrDimID = "POINT 3Z") Then MyReading10 = StrDimAct End If If (StrDimID = "PLANE4 Z") Then MyReading12 = StrDimAct End If If (StrDimID = "PLANE5 Z") Then MyReading13 = StrDimAct End If If (StrDimID = "POINT5Z") Then MyReading14 = StrDimAct End If If (StrDimID = "POINT6Z") Then MyReading15 = StrDimAct End If If (StrDimID = "POINT7Z") Then MyReading16 = StrDimAct End If If (StrDimID = "POINT8Z") Then MyReading17 = StrDimAct End If Next
If (ObjDimCmd.Type = DIMENSION_TRUE_END_POSITION) Then
Maybe?
Try
If (ObjDimCmd.Type = DIMENSION_END_TRUE_POSITION) Then
If (ObjDimCmd.Type = DIMENSION_TRUE_END_POSITION) Then
Maybe?
Try
If (ObjDimCmd.Type = DIMENSION_END_TRUE_POSITION) Then
'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 = 8533 dc.TagIndex = 0 dc.TagValue = "P566290" dc.TagIndex = 1 dc.TagValue = StrC2 dc.TagIndex = 2 dc.TagValue = StrC1 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.CurrentStep = 16 dc.Value = MyReading17 dc.CollectionPlanID = 0 dc.UserName = "" set dc = Nothing End Sub
© 2024 Hexagon AB and/or its subsidiaries. | Privacy Policy | Cloud Services Agreement |