hexagon logo

Script Help Needed - Export Xactmeasure dimensions

I have a program that reports several Xactmeasure line profiles. I have to put the max/min values of each profile into a spreadsheet. Right now I do that by hand. I'm looking for a way to automate the process using a script. I have a script that I use to extract nominal and measured values for points and am thinking I can modify it but I have no idea how to "find" the Xactmeasure profile dimensions in my program within the script. Any ideas?
Parents
  • Its looping, so it's grabbing everything. Looks like you want to stop after 2nd time through the loop. One way to do this would be, after I=I+1 add: If I > 2 then Exit While


    Yeah, I knew it was looping just wasn't sure why it was picking up the individual points used to evaluate the profile. However, you did get me thinking and I came up with a solution that does exactly what I want. I deleted the whole While-Wend condition and looked only for a dimension with a specific naming convention. After cleaning up extra commands here's what I end up with.


    Sub Main'     Original CSV Ouput Script by Jay Hall of Hexagon Metrology
    '      Modified by Josh Carpenter, Mike Grones, Andy Mears,  And Jay Hall of Hexagon Metrology     August 2011
    '        Modified by John Szanto 05-10-2013
    '        Modifications: Captures all Xactmeasure Non-Position data And exports measured, max, And min values To a csv file.
    '                                Also names CSV file With part Name, lot number, And serial number
    ' Notes:
    '       Variable "V_SERIALNUMBER" For Serial Number must be present In PC-DMIS part program
    '       Variable "V_LOT" For Lot Number must be present In PC-DMIS part program
    '        Exports CSV data To C:\YOUR_FOLDER_HERE\CSV Data Output\, change below On Line 34
    '        PC-DMIS v2011 Release: when using Xactmeasure To dimension Position of multiple holes, make sure the required axis are of the Feature Set are checked.
    
    
    'pcdlrn declarations And Open ppg
    Dim App As Object
    Set App = CreateObject("PCDLRN.Application")
    Dim Part As Object
    Set Part = App.ActivePartProgram
    Dim Cmds As Object
    Set Cmds = Part.Commands
    Dim Cmd As Object
    Dim str As String
    
    
    Dim Int As Integer
    Dim strType As String
    
    
    
    
    Dim Serial As Object
    Dim LotNo As Object
    Set Serial = Part.GetVariableValue ("V_SERIALNUMBER")
    Set LotNo = Part.GetVariableValue ("V_LOT")
    
    
    'Open file **** Change File Path If needed *****************************************************************************************************************************************************************
    
    
    FileName = "J:\CMM\Data Export\" & Part.PartName & "_Lot " & LotNo.StringValue & "_SN " & Serial.StringValue & "_Min-Max_Output" & ".csv"
    Open FileName For Output As #1
    Print #1, "Part,Lot #,Serial #,Date,Time"
    Print #1, Part.PartName & "," & LotNo.StringValue & "," & Serial.StringValue & "," & Month(Date) & Day(Date) & Year(Date) & ","  & Hour(Time) & Minute(Time)
    Print #1, "Section,Measured,Max,Min"
    
    
    'Sort Program*********************************************************************************************************************************************************************
    For Each Cmd In Cmds
    
    
    '_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _Process Xactmeasure GD&T _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    If Cmd.Type = 184 Then ' looks For Xactmeasure dimensions
    
    
     If Left(Cmd.ID, 5) = "SECT_" Then ' Look only dimensions With certain naming convention 
    
    
        strType = Cmd.GetText (GDT_SYMBOL, 0)
    
    
        If strType <> "POSITION" Then 'All Non-Position GD&T Get Meas, Max, And Min
          Int = 1
          str = Cmd.GetText (ID, 0) & "," & Format(cdbl(Cmd.GetText (LINE2_MEAS, Int)),"0.0000") & "," & Format(cdbl(Cmd.GetText (LINE2_MAX, Int)),"0.0000") & "," & Format(cdbl(Cmd.GetText (LINE2_MIN, Int)),"0.0000") 	
          Print #1, str
        End If ' is Not Position
    
    
      End If ' specific dimension names
    
    
    End If ' is Cmd.Type 184 Xactmeasure GD&T
    
    
    Next Cmd
    
    
    'Save And Cleanup*******************************************************************************************************************************************************************
    Close #1
    
    
    End Sub



    Thanks seppley for send me the original script and DJAMS for helping me think this through.
Reply
  • Its looping, so it's grabbing everything. Looks like you want to stop after 2nd time through the loop. One way to do this would be, after I=I+1 add: If I > 2 then Exit While


    Yeah, I knew it was looping just wasn't sure why it was picking up the individual points used to evaluate the profile. However, you did get me thinking and I came up with a solution that does exactly what I want. I deleted the whole While-Wend condition and looked only for a dimension with a specific naming convention. After cleaning up extra commands here's what I end up with.


    Sub Main'     Original CSV Ouput Script by Jay Hall of Hexagon Metrology
    '      Modified by Josh Carpenter, Mike Grones, Andy Mears,  And Jay Hall of Hexagon Metrology     August 2011
    '        Modified by John Szanto 05-10-2013
    '        Modifications: Captures all Xactmeasure Non-Position data And exports measured, max, And min values To a csv file.
    '                                Also names CSV file With part Name, lot number, And serial number
    ' Notes:
    '       Variable "V_SERIALNUMBER" For Serial Number must be present In PC-DMIS part program
    '       Variable "V_LOT" For Lot Number must be present In PC-DMIS part program
    '        Exports CSV data To C:\YOUR_FOLDER_HERE\CSV Data Output\, change below On Line 34
    '        PC-DMIS v2011 Release: when using Xactmeasure To dimension Position of multiple holes, make sure the required axis are of the Feature Set are checked.
    
    
    'pcdlrn declarations And Open ppg
    Dim App As Object
    Set App = CreateObject("PCDLRN.Application")
    Dim Part As Object
    Set Part = App.ActivePartProgram
    Dim Cmds As Object
    Set Cmds = Part.Commands
    Dim Cmd As Object
    Dim str As String
    
    
    Dim Int As Integer
    Dim strType As String
    
    
    
    
    Dim Serial As Object
    Dim LotNo As Object
    Set Serial = Part.GetVariableValue ("V_SERIALNUMBER")
    Set LotNo = Part.GetVariableValue ("V_LOT")
    
    
    'Open file **** Change File Path If needed *****************************************************************************************************************************************************************
    
    
    FileName = "J:\CMM\Data Export\" & Part.PartName & "_Lot " & LotNo.StringValue & "_SN " & Serial.StringValue & "_Min-Max_Output" & ".csv"
    Open FileName For Output As #1
    Print #1, "Part,Lot #,Serial #,Date,Time"
    Print #1, Part.PartName & "," & LotNo.StringValue & "," & Serial.StringValue & "," & Month(Date) & Day(Date) & Year(Date) & ","  & Hour(Time) & Minute(Time)
    Print #1, "Section,Measured,Max,Min"
    
    
    'Sort Program*********************************************************************************************************************************************************************
    For Each Cmd In Cmds
    
    
    '_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _Process Xactmeasure GD&T _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    If Cmd.Type = 184 Then ' looks For Xactmeasure dimensions
    
    
     If Left(Cmd.ID, 5) = "SECT_" Then ' Look only dimensions With certain naming convention 
    
    
        strType = Cmd.GetText (GDT_SYMBOL, 0)
    
    
        If strType <> "POSITION" Then 'All Non-Position GD&T Get Meas, Max, And Min
          Int = 1
          str = Cmd.GetText (ID, 0) & "," & Format(cdbl(Cmd.GetText (LINE2_MEAS, Int)),"0.0000") & "," & Format(cdbl(Cmd.GetText (LINE2_MAX, Int)),"0.0000") & "," & Format(cdbl(Cmd.GetText (LINE2_MIN, Int)),"0.0000") 	
          Print #1, str
        End If ' is Not Position
    
    
      End If ' specific dimension names
    
    
    End If ' is Cmd.Type 184 Xactmeasure GD&T
    
    
    Next Cmd
    
    
    'Save And Cleanup*******************************************************************************************************************************************************************
    Close #1
    
    
    End Sub



    Thanks seppley for send me the original script and DJAMS for helping me think this through.
Children
No Data