hexagon logo

Set Flag if Dimension Out-of-Tolerance

Here's what I'm trying to do - Display a message, prior to printing results, that says "There are N dimensions out-of-tolerance, do you still want to print the report?" Of course, I could accomplish this by doing a whole lot of computations with expressions, but I'd thought I'd first inquire if PC-DMIS can set a flag, based upon the Dimension command, that I can convert into a counter.
Parents
  • Try this:

    Sub CheckOOT()
    Dim PCDApp, PCDPartPrograms, PCDPartProgram, PCDCommands, PCDCommand, PCDDimension
    
    Set PCDApp = CreateObject("PCDLRN.Application")
    Set PCDPartPrograms = PCDApp.PartPrograms
    Set PCDPartProgram = PCDApp.ActivePartProgram
    Set PCDCommands = PCDPartProgram.Commands
    
    Dim cnt As Integer
    Dim state As Integer
    Dim ID As String
    Dim Msg As String
    
    State = 1 ' Set state To 'Normal'
    
    For cnt = 1 To PCDCommands.Count
        Set PCDCommand = PCDCommands.Item(cnt)
    
        If PCDCommand.IsDimension Then
          Set PCDDimension = PCDCommand.DimensionCommand
    
          Select Case State
    
            Case 1 '  If it is a 'normal' dimension evaluation
    
                ID = PCDDimension.ID
    
                If (PCDCommand.Type = DIMENSION_TRUE_START_POSITION) Then
                  State = 2 ' If we reached a TP dimension, Set state To 'True Position' (2)
                ElseIf (PCDCommand.Type = DIMENSION_START_LOCATION) Then
                  State = 3 ' If we reached a LOCation dimension, Set state To 'LOCation' (3)
                End If
    
                If (State = 1) Then ' If it is a 'normal' dimension And out of tol, Do stuff below            
                  If (Abs(PCDDimension.OutTol) > 0.00005) Then Msg = Msg & ID & Chr(10) ' Adds the ID To our message
                End If
    
            Case 2 '  If it is a TP dimension evaluation And out of tol, Do stuff below
                  If (Abs(PCDDimension.OutTol) > 0.00005) Then Msg = Msg & ID & Chr(10) ' Adds the ID To our message
    
            Case 3 '  If it is a LOCation dimension evaluation And out of tol, Do stuff below
                  If (Abs(PCDDimension.OutTol) > 0.00005) Then Msg = Msg & ID & Chr(10) ' Adds the ID To our message
    
          End Select
    
          Set PCDDimension = Nothing ' Reset the PCDDimension Object
    
        ElseIf (PCDCommand.Type = DIMENSION_TRUE_END_POSITION) Then
          State = 1 ' Return state To 'Normal' As we have encountered the End of the TP dimension
    
        ElseIf (PCDCommand.Type = DIMENSION_END_LOCATION) Then 
          State = 1 ' Return state To 'Normal' As we have encountered the End of the LOCation dimension
    
        End If
    
        Set PCDCommand = Nothing ' Reset the PCDCommand Object
    
      Next cnt ' Move To the Next command
    
    MsgBox Msg ' Display the ID's that are out of tolerance
    
    End Sub


    Found it in my script repository but I don't know how good/bad it works for your applications/programs.
    Eyeball it/doublecheck the report when using it for the first time/s to see that it captures all OOT.
Reply
  • Try this:

    Sub CheckOOT()
    Dim PCDApp, PCDPartPrograms, PCDPartProgram, PCDCommands, PCDCommand, PCDDimension
    
    Set PCDApp = CreateObject("PCDLRN.Application")
    Set PCDPartPrograms = PCDApp.PartPrograms
    Set PCDPartProgram = PCDApp.ActivePartProgram
    Set PCDCommands = PCDPartProgram.Commands
    
    Dim cnt As Integer
    Dim state As Integer
    Dim ID As String
    Dim Msg As String
    
    State = 1 ' Set state To 'Normal'
    
    For cnt = 1 To PCDCommands.Count
        Set PCDCommand = PCDCommands.Item(cnt)
    
        If PCDCommand.IsDimension Then
          Set PCDDimension = PCDCommand.DimensionCommand
    
          Select Case State
    
            Case 1 '  If it is a 'normal' dimension evaluation
    
                ID = PCDDimension.ID
    
                If (PCDCommand.Type = DIMENSION_TRUE_START_POSITION) Then
                  State = 2 ' If we reached a TP dimension, Set state To 'True Position' (2)
                ElseIf (PCDCommand.Type = DIMENSION_START_LOCATION) Then
                  State = 3 ' If we reached a LOCation dimension, Set state To 'LOCation' (3)
                End If
    
                If (State = 1) Then ' If it is a 'normal' dimension And out of tol, Do stuff below            
                  If (Abs(PCDDimension.OutTol) > 0.00005) Then Msg = Msg & ID & Chr(10) ' Adds the ID To our message
                End If
    
            Case 2 '  If it is a TP dimension evaluation And out of tol, Do stuff below
                  If (Abs(PCDDimension.OutTol) > 0.00005) Then Msg = Msg & ID & Chr(10) ' Adds the ID To our message
    
            Case 3 '  If it is a LOCation dimension evaluation And out of tol, Do stuff below
                  If (Abs(PCDDimension.OutTol) > 0.00005) Then Msg = Msg & ID & Chr(10) ' Adds the ID To our message
    
          End Select
    
          Set PCDDimension = Nothing ' Reset the PCDDimension Object
    
        ElseIf (PCDCommand.Type = DIMENSION_TRUE_END_POSITION) Then
          State = 1 ' Return state To 'Normal' As we have encountered the End of the TP dimension
    
        ElseIf (PCDCommand.Type = DIMENSION_END_LOCATION) Then 
          State = 1 ' Return state To 'Normal' As we have encountered the End of the LOCation dimension
    
        End If
    
        Set PCDCommand = Nothing ' Reset the PCDCommand Object
    
      Next cnt ' Move To the Next command
    
    MsgBox Msg ' Display the ID's that are out of tolerance
    
    End Sub


    Found it in my script repository but I don't know how good/bad it works for your applications/programs.
    Eyeball it/doublecheck the report when using it for the first time/s to see that it captures all OOT.
Children
No Data