hexagon logo

Another Excel Script Problem

Hey, guys. Trying to make an excel script to output the dimensions that appear on the report. We have several that are not shown on the report that are used in the code for logic purposes.

Problem in code is where the xlsht.Range("D" + Count) = Nominal
code starts. No matter what I put after the equal sign, I get an OLE error.

The other "xlsht.Range" commands in the code work fine.

Suggestions?

xlsht.Range("D" + Count) = Nominal

Sub Main

'Excel Declarations
       Dim xlApp As Object
       Dim xlwrkbks As Object
       Dim xlwrkbk As Object
       Dim xlsht As Object
       Dim Count As Integer


       'PC-DMIS declarations 
       Dim PCDApp As Object
       Set PCDApp = CreateObject("PCDLRN.Application")
       Dim Part As Object
       Set Part = PCDApp.ActivePartProgram
       Dim Cmds As Object
       Set Cmds = Part.Commands
       Dim Cmd As Object
       Dim DCmd As Object
       Dim CCmd As Object
       Dim DCmdID As String






        'Variables From Part Program
        Dim VPART, VSERIALNUMBER, VPROGRAMID, VDATE, VTIME, VDESCRIPTION, VCMMOPERATOR, VLOCALCSV As Object
        Dim VREV As Object

        Set VREV = Part.GetVariableValue("VREV")
        Set VPART = Part.GetVariableValue("VPART")
        Set VDESCRIPTION = Part.GetVariableValue("VDESCRIPTION")
        Set VSERIALNUMBER = Part.GetVariableValue("VSERIALNUMBER")
        Set VPROGRAMID = Part.GetVariableValue("VPROGRAMID")
        Set VDATE = Part.GetVariableValue("VDATE")
        Set VTIME = Part.GetVariableValue("VTIME")
        Set VCMMOPERATOR = Part.GetVariableValue("VCMMOPERATOR")
        Set VLOCALCSV = Part.GetVariableValue("VLOCALCSV")

        'Open Excel And Template File
        Set xlApp = CreateObject("Excel.Application")
        Set xlwrkbks = xlApp.Workbooks
        Set xlwrkbk = xlApp.Workbooks.Open("D:\CMM_PROGRAMS\PC-DMIS_SUPPORT_FILES\EXCEL_FILES\TEMPLATE.CSV")
        Set xlsht = xlwrkbk.Worksheets("TEMPLATE")


        'EXCEL SHEET HEADER INFO
        xlsht.Range("A2").Value = "GE Aviation Batesville Composites Operation"
        xlsht.Range("A3").Value = "Part # :"
        xlsht.Range("A4").Value = "Date :"
        xlsht.Range("A5").Value = "Description :"
        xlsht.Range("A6").Value = "Serial # :"
        xlsht.Range("A7").Value = "Operator :"
        xlsht.Range("A8").Value = "Rev:"

        xlsht.Range("C3").Value = VPART.StringValue
        xlsht.Range("C4").Value = VDATE.StringValue
        xlsht.Range("C5").Value = VDESCRIPTION.StringValue
        xlsht.Range("C6").Value = VSERIALNUMBER.StringValue
        xlsht.Range("C7").Value = VCMMOPERATOR.StringValue
        xlsht.Range("C8").Value = VREV.StringValue

        xlsht.Range("A11").Value = "Dimension Name"
        xlsht.Range("D11").Value = "Nominal"
        xlsht.Range("E11").Value = "+TOL"
        xlsht.Range("F11").Value = "-TOL"
        xlsht.Range("G11").Value = "Measured"
        xlsht.Range("H11").Value = "MAX"
        xlsht.Range("I11").Value = "MIN"
        xlsht.Range("J11").Value = "Deviation"
        xlsht.Range("K11").Value = "OOT"
        xlsht.Range("L11").Value = "Bonus Tol"




        Count = Count + 1



       For Each Cmd In Cmds

            If Cmd.IsDimension Then

                Set DCmd = Cmd.DimensionCommand
                Set DCmdID = DCmd.ID

                If Not DCmd.OutputMode = "None" Then

                   xlsht.Range("D" + Count) = Nominal

                End If
            End If

        Next Cmd


        xlApp.Visible = True



End Sub
  • Find out what value the variable is with a MsgBox,

    msgbox = "DcmdId.Type", the message will be an integer. Look it up through the help menu (number value will indicate whether it is a double, string, etc)

    Then in your code assign that variable with the default value it is looking for

    xlsht.Range("A", Count) = DCmdID.Double or .String or whatever

    That's what that error message is looking for, the variable type method after the variable name.


    Tried putting the message box in, but it returned error "Assignment not allowed here" ?



    Sub Main
    
    'Excel Declarations
           Dim xlApp As Object
           Dim xlwrkbks As Object
           Dim xlwrkbk As Object
           Dim xlsht As Object
           Dim Count As Integer
    
    
           'PC-DMIS declarations 
           Dim PCDApp As Object
           Set PCDApp = CreateObject("PCDLRN.Application")
           Dim Part As Object
           Set Part = PCDApp.ActivePartProgram
           Dim Cmds As Object
           Set Cmds = Part.Commands
           Dim Cmd As Object
           Dim DCmds As Object
           Dim DCmd As Object
           Dim CCmd As Object
           Dim DCmdID As Object
    
    
    
    
            'Variables From Part Program
            Dim VPART, VSERIALNUMBER, VPROGRAMID, VDATE, VTIME, VDESCRIPTION, VCMMOPERATOR, VLOCALCSV As Object
            Dim VREV As Object
    
            Set VREV = Part.GetVariableValue("VREV")
            Set VPART = Part.GetVariableValue("VPART")
            Set VDESCRIPTION = Part.GetVariableValue("VDESCRIPTION")
            Set VSERIALNUMBER = Part.GetVariableValue("VSERIALNUMBER")
            Set VPROGRAMID = Part.GetVariableValue("VPROGRAMID")
            Set VDATE = Part.GetVariableValue("VDATE")
            Set VTIME = Part.GetVariableValue("VTIME")
            Set VCMMOPERATOR = Part.GetVariableValue("VCMMOPERATOR")
            Set VLOCALCSV = Part.GetVariableValue("VLOCALCSV")
    
            'Open Excel And Template File
            Set xlApp = CreateObject("Excel.Application")
            Set xlwrkbks = xlApp.Workbooks
            Set xlwrkbk = xlApp.Workbooks.Open("D:\CMM_PROGRAMS\PC-DMIS_SUPPORT_FILES\EXCEL_FILES\TEMPLATE.CSV")
            Set xlsht = xlwrkbk.Worksheets("TEMPLATE")
    
    
            'EXCEL SHEET HEADER INFO
            xlsht.Range("A2").Value = "GE Aviation Batesville Composites Operation"
            xlsht.Range("A3").Value = "Part # :"
            xlsht.Range("A4").Value = "Date :"
            xlsht.Range("A5").Value = "Description :"
            xlsht.Range("A6").Value = "Serial # :"
            xlsht.Range("A7").Value = "Operator :"
            xlsht.Range("A8").Value = "Rev:"
    
            xlsht.Range("C3").Value = VPART.StringValue
            xlsht.Range("C4").Value = VDATE.StringValue
            xlsht.Range("C5").Value = VDESCRIPTION.StringValue
            xlsht.Range("C6").Value = VSERIALNUMBER.StringValue
            xlsht.Range("C7").Value = VCMMOPERATOR.StringValue
            xlsht.Range("C8").Value = VREV.StringValue
    
            xlsht.Range("A11").Value = "Dimension Name"
            xlsht.Range("D11").Value = "Nominal"
            xlsht.Range("E11").Value = "+TOL"
            xlsht.Range("F11").Value = "-TOL"
            xlsht.Range("G11").Value = "Measured"
            xlsht.Range("H11").Value = "MAX"
            xlsht.Range("I11").Value = "MIN"
            xlsht.Range("J11").Value = "Deviation"
            xlsht.Range("K11").Value = "OOT"
            xlsht.Range("L11").Value = "Bonus Tol"
    
            Count = Count + 13
    
    
        
    For Each Cmd In Cmds
    
      If Cmd.IsDimension  Then
    
                     
             Set DCmd = Cmd.DimensionCommand
             Set DCmdID = DCmd.ID
    
    MsgBox = "DCmdID.Type"
                          
              xlsht.Range("A" & Count).Value = DCmdID.StringValue
              xlsht.Range("D" & Count).Value = DCmd.Nominal
              xlsht.Range("E" & Count).Value = DCmd.Plus
              xlsht.Range("F" & Count).Value = DCmd.Minus
              xlsht.Range("G" & Count).Value = DCmd.Measured
              xlsht.Range("H" & Count).Value = DCmd.Max
              xlsht.Range("I" & Count).Value = DCmd.Min
              xlsht.Range("J" & Count).Value = DCmd.Deviation
              xlsht.Range("K" & Count).Value = DCmd.OutTol
              'xlsht.Range("L" & Count).Value = DCmd.BTol
    
              FeatureList(Fcntr) = DCmd.ID 
              Fcntr = Fcntr + 1
            
     
    
    
      End If
    
     
    
    
    
    Next Cmd
    
    
        
    
             
    
    
    xlApp.Visible = True
    
    
    End Sub
  • Decided to go a different way with this and adapt a script written by AndersI previously shared in this thread.(Thank You to both of you)

    The company IT dept is working on the VB installed on my computer as it is totally screwed, so I cannot use it for reference.


    ' Sub To Clear the Write variables
    
    Sub ClearRecord
      elType = "type"
      elName = "name"
      elValueType = "valuetype"
      elAct = 0
      elNom = 0
      elMax = 0
      elMin  = 0
      elDev = 0
      elMtol = 0
      elPtol = 0
      elOutTol = 0
      elBonusTol  = 0
    End Sub
    
    
    'Sub To Print a Line And space after the Line
    Sub PrintLine(FileNum%)
      If elStarted Then 
          Print #FileNum, elName; ","; elType; ","; elValueType; ","; elNom; ","; elAct; ","; elPtol; ","; elMtol; ","; elDev; ","; elOutTol; ","; elBonusTol
          Print #FileNum, ""
          elStarted = 0
      End If 
    
    End Sub
    
    
    
    Sub ExportAsCSV(FileName$)
    
    
    'PC-DMIS declarations 
    Dim PCDApp As Object
    Set PCDApp = CreateObject("PCDLRN.Application")
    Dim Part As Object
    Set Part = PCDApp.ActivePartProgram
    Dim Cmds As Object
    Set Cmds = Part.Commands
    Dim Cmd As Object
    Dim ID As String
    
    
    
    
    Dim ix As Integer
    Dim DCmd As  Object
    Dim DoOutput As Integer
    Dim State As Integer
    
    fNum = FreeFile
    Open FileName$ For Output As fNum
    
           
    'Variables From Part Program
            Dim VPART, VSERIALNUMBER, VPROGRAMID, VDATE, VTIME, VDESCRIPTION, VCMMOPERATOR, VLOCALCSV As Object
            Dim VREV As Object
    
            Set VREV = Part.GetVariableValue("VREV")
            Set VPART = Part.GetVariableValue("VPART")
            Set VDESCRIPTION = Part.GetVariableValue("VDESCRIPTION")
            Set VSERIALNUMBER = Part.GetVariableValue("VSERIALNUMBER")
            
            Set VDATE = Part.GetVariableValue("VDATE")
            
            Set VCMMOPERATOR = Part.GetVariableValue("VCMMOPERATOR")
            Set VLOCALCSV = Part.GetVariableValue("VLOCALCSV")
    
    Print #fNum, "GE Aviation - Batesville Composites Operation"
    Print #fNum, ""
    Print #fNum, "Part #:"; ","; ""; VPART.StringValue
    Print #fNum, "Serial #:"; ","; ""; VSERIALNUMBER.StringValue
    Print #fNum, "Description:"; ","; ""; VDESCRIPTION.StringValue
    Print #fNum, "Date:"; ","; ""; VDATE.StringValue
    Print #fNum, "CMM Operator:"; ","; ""; VCMMOPERATOR.StringValue
    Print #fNum, ""
    Print #fNum, "Dimension Name,Axis, Type, Nominal, Measured, +TOL, -TOL, Max, Min, Deviation, OutTol, BonusTol"
    
    elStarted = 0
    State = 1
    
    'Begin the Cases For the dimension types And actual data export
    '_______________________________________________________________
    
    For Each Cmd In Cmds
    
          If Cmd.IsDimension Then
    
                Set DCmd = Cmd.DimensionCommand
    
                 Select Case State
    
                          Case 1 
                            
                                    If (DCmd.OutputMode <> DIMOUTPUT_NONE) Then
                                        DoOutput = 1
                                     Else
                                         DoOutput = 0
                                      End If



    This section of the code is giving me trouble. The ".Type" returns an "unknown name" error. No idea. If I could use the VB library I could check to see if that was a valid command. I think it is...not sure what is wrong...

    Any ideas?


                                    If (DCmd.Type = DIMENSION_TRUE_START_POSITION) Then
                                         State = 2
                                    ElseIf (DCmd.Type = DIMENSION_START_LOCATION) Then
                                         State = 3
                                    End If
                                    
                                    If (DoOutput = 1) And (State = 1) Then
    
                     PrintLine(fNum)
                     ClearRecord
                     elType = DCmd.TypeDescription
                     elName = ID
                                     
                     If DCmd.AxisLetter = "D" Then
                            elValueType = "DIAM"
                     Elseif DCmd.AxisLetter = "R" Then
                     elValueType = "RAD"
                     Else
                     elValueType = DCmd.AxisLetter
                     End If
    
    
     ' ---------
                   elNom = DCmd.Nominal
                   ' 2005-11-16
                   If (Abs(DCmd.Deviation) > 0.00005) Then
     	              elDev = DCmd.Deviation
                   Else
                   	elDev = 0
                   End If
                    elAct = DCmd.Nominal + elDev
                   ' ---------
                   elMtol = DCmd.Minus
                   elPtol = DCmd.Plus
                   ' 2005-11-16
                   If (Abs(DCmd.OutTol) > 0.00005) Then
     	              elOutTol = DCmd.OutTol
                   Else
                   	elOutTol = 0
                   End If
                   ' ---------
                   elComment = ""
                   elStarted = 1
    
                 End If
    
                          Case 2                                                                            'True Position
    
     If (DoOutput = 1) Then
                   PrintLine(fNum)
                   ClearRecord
                    elType = DCmd.TypeDescription
                    elName = ID
                   ' 2005-11-17
                   If DCmd.AxisLetter = "D" Then
                       elValueType = "DIAM"
                    ElseIf DCmd.AxisLetter = "R" Then
                       elValueType = "RAD"
                   Else
                     elValueType = DCmd.AxisLetter
                   End If
                  ' ---------
                   elNom = DCmd.Nominal
                  ' 2005-11-16
                   If (Abs(DmisDimension.Deviation) > 0.00005) Then
    	               elDev = DCmd.Deviation
                   Else
                   	elDev = 0
                   End If
                   elAct = DCmd.Nominal + elDev
                   ' ---------
                   elMtol = DCmd.Minus
                   elPtol = DCmd.Plus
                   ' 2005-11-16
                   If (Abs(v.OutTol) > 0.00005) Then
     	              elOutTol = DCmd.OutTol
                   Else
                   	elOutTol = 0
                   End If
                   ' ---------
                   elComment = ""
                   elStarted = 1
                 End If
    
             Case 3 '                                                                                       Location
    
                 If (DoOutput = 1) Then
                   PrintLine(fNum)
                   ClearRecord
                   elType = DCmd.TypeDescription
                   elName = ID
                   ' 2005-11-17
                   If DCmd.AxisLetter = "D" Then
                       elValueType = "DIAM"
                   ElseIf DCmd.AxisLetter = "R" Then
                       elValueType = "RAD"
                   Else
                      elValueType = DCmd.AxisLetter
                   End If
                   ' ---------
                   elNom = DCmd.Nominal
                   ' 2005-11-16
                  If (Abs(DCmd.Deviation) > 0.00005) Then
    	              elDev = DCmd.Deviation
                  Else
                  	elDev = 0
                  End If
                  elAct = DCmd.Nominal + elDev
                  ' ---------
                  elMtol = -DCmd.Minus
                  elPtol = DCmd.Plus
                  ' 2005-11-16
                  If (Abs(DCmd.OutTol) > 0.00005) Then
    	              elOutTol = DCmd.OutTol
                  Else
                  	elOutTol = 0
                  End If
                  ' ---------
                  elComment = ""
                  elStarted = 1
                End If
    
          End Select
    
    Set DCmd = Nothing
    
                  End If
    
        Set DCmd = Nothing
    
    
    
    
    
    Next Cmd
    
    End Sub
    
    Sub Main(FileName$)
    
        'ExportAsCSV(FileName$) 'For Deployment
        ExportAsCSV("Export.CSV") 'For Testing
    
    End Sub
  • I'm baffled - I see the same problem loading your code, I see no problem loading my original code, but I can't see any important difference!

    My only tip would be: Go back to my original code, and slowly add your modifications step by step, testing the script between each increment.
  • Try change this:

    If (DCmd.Type = DIMENSION_TRUE_START_POSITION) Then
       State = 2
    ElseIf (DCmd.Type = DIMENSION_START_LOCATION) Then
       State = 3
    End If
    


    ...to this:

    If ([COLOR="#FF0000"]Cmd[/COLOR].Type = DIMENSION_TRUE_START_POSITION) Then
       State = 2
    ElseIf ([COLOR="#FF0000"]Cmd[/COLOR].Type = DIMENSION_START_LOCATION) Then
       State = 3
    End If
    
  • I'm baffled - I see the same problem loading your code, I see no problem loading my original code, but I can't see any important difference!

    My only tip would be: Go back to my original code, and slowly add your modifications step by step, testing the script between each increment.


    Thank you so much for posting this script, AndersI. It is exactly what I was looking for. I'll do as you suggest.

    What version of PC-DMIS were you using when you composed this?
  • Working pretty good now except that it is only outputting postion and location dimensions. I added a case for profiles with the same format as AndersI and it is not outputting the profile data.

    Not sure what is happening. Not much experience with Select Case Statements.


    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 elMax As Double
    Dim elMin As Double
    Dim elBTol As Double
    Dim elComment As String
    Dim elStarted As Integer
    
    ' ================================================================
    
    Sub ClearRecord
      elType = "type"
      elName = "name"
      elValueType = "valuetype"
      elAct = 0
      elNom = 0
      elDev = 0
      elMax = 0
      elMin = 0
      elMtol = 0
      elPtol = 0
      elOutTol = 0
      elBTol = ""
    End Sub
    
    Sub PrintLine(FileNum%)
      If elStarted Then
        Print #FileNum, elName; ","; elType; ","; elValueType; ","; elNom; ","; elPtol; ","; elMtol; "," ; elAct; ","; elMax; ","; elMin; ","; elDev; ","; elOutTol; ","; elBTol
        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
    
      Set DmisApp = CreateObject("PCDLRN.Application")
      Set DmisPart = DmisApp.ActivePartProgram
      Set DmisCommands = DmisPart.Commands
    
      Dim VPART, VDESCRIPTION, VSERIALNUMBER, VDATE, VCMMOPERATOR As Object
    
      Set VPART = DmisPart.GetVariableValue("VPART")
      Set VDESCRIPTION = DmisPart.GetVariableValue("VDESCRIPTION")
      Set VSERIALNUMBER = DmisPart.GetVariableValue("VSERIALNUMBER")
      Set VDATE = DmisPart.GetVariableValue("VDATE")
      Set VCMMOPERATOR = DmisPart.GetVariableValue("VCMMOPERATOR")
    
    
      fNum = FreeFile
      Open FileName$ For Output As fNum
      ' 2005-11-17
      Print #fNum, "Company Name"
      Print #fNum, ""
      Print #fNum, "Part #:"; ","; VPART.StringValue
      Print #fNum, "Serial #:"; ","; VSERIALNUMBER.StringValue
      Print #fNum, "Description:"; ","; VDESCRIPTION.StringValue
      Print #fNum, "Date:"; ","; VDATE.StringValue
      Print #fNum, "CMM Operator:"; ","; VCMMOPERATOR.StringValue
    
      
      Print #fNum, ""
      Print #fNum, " Dimension Name,Dimension Type,Axis,Nominal,(+)Tol,(-)Tol,Measured,Max,Min,Dev,OutTol,BonusTol"
      Print #fNum, ""
      
    
      elStarted = 0
      State = 1
    
      For Each DmisCommand In DmisCommands
    
        
    
        If DmisCommand.IsDimension Then
    
          Set DmisDimension = DmisCommand.DimensionCommand
    
                If (DmisDimension.OutputMode <> DIMOUTPUT_NONE) Then
                  DoOutput = 1
                Else
                  DoOutput = 0
                End If
    
    
                  If (DmisCommand.Type = DIMENSION_TRUE_START_POSITION) Then
                  State = 2
                  ElseIf (DmisCommand.Type = DIMENSION_START_LOCATION) Then
                  State = 3
                  ElseIf (DmisCommand.Type = DIMENSION_PROFILE)  Then
                  State =4
                
                  End If
    
          Select Case State
    
            Case 1 '  Normal Case
    
                ID = DmisDimension.ID
    
               
    
                If (DoOutput = 1) And (State = 1) Then
    
                If (DmisDimension.OutputMode <> DIMOUTPUT_NONE) Then
                  DoOutput = 1
                Else
                  DoOutput = 0
                End If
    
    
                  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.00009) 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.00009) Then
    	              elOutTol = DmisDimension.OutTol
                  Else
                  	elOutTol = 0
                  End If
                  ' ---------
                  
                   elMax = ""
                  elMin = ""
    
                  If (Abs(DmisDimension.Bonus) > .00009) Then
                             elBTol = DmisDimension.Bonus
                  Else
                            elBTol = 0
                  End If 
    
    
                  elStarted = 1
    
                End If
    
            Case 2 '  True Position
    
                If (DoOutput = 1)  And (State =2) Then
    
                If (DmisDimension.OutputMode <> DIMOUTPUT_NONE) Then
                  DoOutput = 1
                Else
                  DoOutput = 0
                End If
    
    
    
                  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.00009) 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.00009) Then
    	              elOutTol = DmisDimension.OutTol
                  Else
                  	elOutTol = 0
                  End If
                  ' ---------
                  elMax = ""
                  elMin = ""
    
                  If (Abs(DmisDimension.Bonus) > .00009) Then
                             elBTol = DmisDimension.Bonus
                  Else
                            elBTol = 0
                  End If 
    
    
                  elStarted = 1
                End If
    
    
  • Had to split the code into 2 sections.

    Case 3 '  Location
    
                If (DmisDimension.OutputMode <> DIMOUTPUT_NONE) Then
                  DoOutput = 1
                Else
                  DoOutput = 0
                End If
    
    
    
                If (DoOutput = 1) And (State = 3) 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.00009) 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.00009) Then
    	              elOutTol = DmisDimension.OutTol
                  Else
                  	elOutTol = 0
                  End If
                  ' ---------
    
                   elMax = ""
                  elMin = ""
    
                  If (Abs(DmisDimension.Bonus) > .00009) Then
                             elBTol = DmisDimension.Bonus
                  Else
                            elBTol = 0
                  End If 
    
    
                  elStarted = 1
                End If
    
    
          Case 4        'For Profile Dimensions
    
    
            If (DoOutput = 1) And (State = 4) Then
    
                If (DmisDimension.OutputMode <> DIMOUTPUT_NONE) Then
                  DoOutput = 1
                Else
                  DoOutput = 0
                End If
    
    
    
                  PrintLine(fNum)
                  ClearRecord
                  elType = DmisCommand.TypeDescription
                  elName = ID
    
                  If DmisDimension.AxisLetter = "D"  Then
                      elValueType = "DIAM"
                  ElseIf DmisDimension.AxisLetter = "R" Then
                      elValueType = "RAD"
                  Else
                    elValueType = DmisDimension.AxisLetter
                  End If
    
                  '---------------------------------
    
                  elNom = DmisDimension.Nominal
    
                  '--------------------------------------------
                  elMtol = -DmisDimension.Minus
                  elPtol = DmisDimension.Plus
    
                  '-------------------------------------------
    
                  If (Abs(DmisDimension.Max) >.00009) Then
                        elMax = DmisDimension.Max
                  Else 
                        elMax = 0
                  End If
    
                  '-------------------------------------------
    
                  If (Abs(DmisDimension.Min) >.00009) Then
                        elMax = DmisDimension.Min
                  Else 
                        elMin = 0
                  End If
    
    
    
                  '---------------------------------
                  elDev = ""
                  elAct = ""
                  elBTol = ""
                  '----------------------------------
    
    
    
    
            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 Cmd
    
      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.csv") ' For testing
    End Sub
  • The reason for your first version not working is probably the change I suggested, which you have implemented (unknowingly perhaps) in the later version:

    If ([COLOR="#FF0000"]DmisDimension[/COLOR].OutputMode <> DIMOUTPUT_NONE) Then
       DoOutput = 1 Else
       DoOutput = 0 
    End If 
    
    If ([COLOR="#008000"]DmisCommand[/COLOR].Type = DIMENSION_TRUE_START_POSITION) Then
       State = 2 
    ElseIf ([COLOR="#008000"]DmisCommand[/COLOR].Type = DIMENSION_START_LOCATION) Then
       State = 3 
    ElseIf ([COLOR="#008000"]DmisCommand[/COLOR].Type = DIMENSION_PROFILE) Then 
       State =4
    End If
  • The reason for your first version not working is probably the change I suggested, which you have implemented (unknowingly perhaps) in the later version:

    If ([COLOR="#FF0000"]DmisDimension[/COLOR].OutputMode <> DIMOUTPUT_NONE) Then
       DoOutput = 1 Else
       DoOutput = 0 
    End If 
    
    If ([COLOR="#008000"]DmisCommand[/COLOR].Type = DIMENSION_TRUE_START_POSITION) Then
       State = 2 
    ElseIf ([COLOR="#008000"]DmisCommand[/COLOR].Type = DIMENSION_START_LOCATION) Then
       State = 3 
    ElseIf ([COLOR="#008000"]DmisCommand[/COLOR].Type = DIMENSION_PROFILE) Then 
       State =4
    End If


    I took your advice to heart vpt. Any ideas why it would not be outputting the profile data? Also it is outputting the dimensions that are set to "NONE" in the output toggle in the part program.

    Got code in the script telling it not to do that.