hexagon logo

PC-DMIS not scripting into Excel Properly.

Good day!

So, when attempting to script out the results of a program into Excel, I am having an issue regarding the GDT results. For some reason, the results for these inspection points will only populate the first column of my excel sheet. I have other dimensions that are working fine. All other dimensions are coming in fine, and I have the scripting set to append the results from PC-DMIS so I can run an entire job and look at the results when it is done. For some reason though, the GDT results keep populating in the first column of the Excel sheet and write over the previous results, meaning if I run ten parts, I will have the results for all the inspection points in nice, neat columns and rows; however, the GDT results look like I only have one results and the rest of the columns are blank (I have a picture what my excel sheet looks like).

I added pictures of the Settings I have selected to attempt to get the script out. Here is the actual script from the program --> Script.txt

I hope someone understands what I am trying to do and can help. Thank you.





Attached Files
  • Hi, I've not played much with pulling GD&T/Geotol results in scripts, but what is the usage of this syntax in brackets? Just to help me better understand, I noticed GD&T is the only thing in brackets in your script.
    xlSheet.Cells(RCount, 4).Value = Cmd.GetText(ID, 0) & "." & "GDT [Ref:" & sPuffer & "]" ' id


    Could you also expand the cell that has the GD&T text data or paste the current cell values shown? It could help backtrack the error and troubleshoot.
  • That is a good question, and I did not see that. I will have to look into that. I know brackets and parathesis can change how the script is read, but I'm unsure why this is brackets and not parathesis. Thank you! I will give it a try.
  • After a quick glance tbh it looks to me like you are using a variable RCount to track which row it is inputting on, but its being reset to 6 every iteration. There are commands in excel VBA where you can find the first empty row or column. Probably a good idea to use those.
  • Hello,

    As you can see here, with "xlSheet.Cells(RCount, 4).Value" the CCount is not counted up, so it is always in the same column.

    In addition, only one line is needed at this point
    As you can see from the FCF example, 5 values are written into the same cell (and only the last value is visible)​


    Wrong:

    'Fill In measured data
    [...]
    ' -- Do FCF --------------------------------------------------------
    If Cmd.Type = 184 Then
    ReportDim = Cmd.GetText(OUTPUT_TYPE, 0)
    If ReportDim = "BOTH" Or ReportDim = "STATS" Then
    xlSheet.Cells(RCount, CCount).Value = Cmd.GetText(ID, 0) & "." & "FCF"
    xlSheet.Cells(RCount, CCount).Value = "0"
    xlSheet.Cells(RCount, CCount).Value = Cmd.GetText(LINE2_PLUSTOL, 1)
    xlSheet.Cells(RCount, CCount).Value = "0"
    xlSheet.Cells(RCount, CCount).Value = Cmd.GetText(LINE2_DEV, 1)
    RCount = RCount + 1
    End If
    End If

    ' -- Do GDT --------------------------------------------------------
    'new 06.10.2021
    If (Cmd.Type = ISO_TOLERANCE_COMMAND) Or (Cmd.Type = ASME_TOLERANCE_COMMAND) Then
    ReportDim = Cmd.GetText(OUTPUT_TYPE, 0)
    If ReportDim = "BOTH" Or ReportDim = "STATS" Then

    LoopIndex = 1
    sPuffer = Cmd.GetText(REF_ID, LoopIndex)
    While sPuffer <> ""
    xlSheet.Cells(RCount, 4).Value = Cmd.GetText(ID, 0) & "." & "GDT [Ref:" & sPuffer & "]" ' id
    xlSheet.Cells(RCount, 1).Value = "0" ' Nominals
    xlSheet.Cells(RCount, 2).Value = Cmd.GetText(FORM_TOLERANCE, 1) ' Tol plus
    xlSheet.Cells(RCount, 3).Value = "0" ' Tol minus
    xlSheet.Cells(RCount, 5).Value = Cmd.GetTextEx(DIM_DEVIATION, LoopIndex, "SEG=1") ' Meas

    RCount = RCount + 1
    LoopIndex = LoopIndex + 1
    sPuffer = Cmd.GetText(REF_ID, LoopIndex)
    Wend

    End If
    End If 'Do GDT​


    better:

    'Fill In measured data
    [...]
    ' -- Do FCF --------------------------------------------------------
    If Cmd.Type = 184 Then
    ReportDim = Cmd.GetText(OUTPUT_TYPE, 0)
    If ReportDim = "BOTH" Or ReportDim = "STATS" Then
    xlSheet.Cells(RCount, CCount).Value = Cmd.GetText(LINE2_DEV, 1)
    RCount = RCount + 1
    End If
    End If

    ' -- Do GDT --------------------------------------------------------
    'new 06.10.2021
    If (Cmd.Type = ISO_TOLERANCE_COMMAND) Or (Cmd.Type = ASME_TOLERANCE_COMMAND) Then
    ReportDim = Cmd.GetText(OUTPUT_TYPE, 0)
    If ReportDim = "BOTH" Or ReportDim = "STATS" Then

    LoopIndex = 1
    sPuffer = Cmd.GetText(REF_ID, LoopIndex)
    While sPuffer <> ""
    xlSheet.Cells(RCount, CCount).Value = Cmd.GetTextEx(DIM_DEVIATION, LoopIndex, "SEG=1") ' Meas

    RCount = RCount + 1
    LoopIndex = LoopIndex + 1
    sPuffer = Cmd.GetText(REF_ID, LoopIndex)
    Wend

    End If
    End If 'Do GDT​
  • What is CCount?


    maybe something like this might help a little?

    Dim wsCopy As Worksheet
    Dim wsDest As Worksheet
    Dim lCopyLastRow As Long
    Dim lDestLastRow As Long

    Dim wk As Workbook
    Set wk = Workbooks.Open("\\location of worksheet\excelworkbook.xlsx")

    Set wsCopy = ThisWorkbook.Worksheets(1)

    Set wsDest = Workbooks("excelworkbook.xlsx").Worksheets(1)

    lCopyLastRow = wsCopy.Cells(wsCopy.Rows.Count, "A").End(xlUp).Row

    lDestLastRow = wsDest.Cells(wsDest.Rows.Count, "A").End(xlUp).Offset(1).Row

    wsCopy.Range("A3:T" & lCopyLastRow).Copy _
    wsDest.Range("A" & lDestLastRow)
  • I didn't invent this script, but "CCount" is apparently the colum counter that determines which column the measured value is written into.
    As I marked in the code, this was not used and therefore the measured value was always written in the same column.

    please take a look at the script A.Neal attached
  • I attempted Henniger123's idea. It makes sense what you did, and it looks like it would work but unfortunately it does not. All it did was move all the dimension results one column over (the dimensions start in column marked "Part 2" instead of "Part 1") and the same problem stated is still there, but the GDT issues are still in the "Part 1" column.

    Thank you for the attempt. Still trying to figure it out.

    Attached Files
  • I attempted to do what you suggested. Take a gander below (at my most recent comment) of a picture of what happens with the new script. Thanks again.