hexagon logo

OUTTOLS Script help

I am using the OUTTOLS script found here but need help modifying it for my needs.

We have a part that gets checked on the CMM then data is written to a csv file to be uploaded to a customers database. However if a part has an OOT dimension we rework the part and check it again. I need a way to evaluate for an OOT condition and if there is one to NOT send any data to my csv file. How can I modify the aforementioned script to pass a variable back to PCD? I will then use that variable in an IF/THEN statement to determine whether or not to export the data. Thanks!
  • That script is designed to tell you if there are features out of tolerance in the report.
    Its not designed to tell you what that error is or how many there are.
  • Thanks! I was able to get the variable passed back to PCD.

    Now I have another issue. When I run the program and a dimension is OOT a msg box pops up with the name of the offending feature. However, it's giving me the wrong name. Upon further examination the feature listed is the one immediately prior to the OOT dimension. The only thing I can come up with is the OOT dimension reported using XactMeasure and the feature listed as OOT is a legacy dimension. I know the script is supposed to look at both types but it appears to not be working correctly. The script I'm using is:

    Sub Main()
    
    'This *.bas is a simple, modified version of Craigs modified outtol.bas (whose original author nobody seems To know).
    'Jan.
    'Modified 9/23/09 DGG To include feature ID In the outtol comment. 
    'Works With anything up To 2 features, including reference features. 
    'TP callouts using more than 2 features will Not show reference datums
    'beyond the first one. 
    
    
    Dim objApp As Object
    Set objApp = CreateObject("PCDLRN.Application")
    Dim objPart As Object
    Set objPart = objApp.ActivePartProgram
    Dim objCmds As Object
    Set objCmds = objPart.Commands
    Dim objCmd As Object
    Dim objDimCmd As Object
    Dim dblOutTol As Long
    dblOutTol = 0
    Dim dblTotalMeas As Long
    dblTotalMeas = 0
    Dim objOutTol As Object
    Set objOutTol = objPart.GetVariableValue("NUMBEROUTTOL")               'number of outtols found
    
    
    Dim prevIDName As String
    Dim count1
    Dim count2
    Dim prevcount1
    Dim prevcount2
    Dim prevID2Name As String
    Dim objCmdDeviation As Double
    Dim objCmdOuttol As Double
    Dim ID As String
    Dim ID2 As String
    Dim DimensionName As String
    Dim Msg As String
    
    
    Dim cnt As Integer
      
    For cnt = 1 To objCmds.Count
     Set objCmd = objCmds.Item(cnt)
    
    
    If objCmd.marked = True Then   'CHECK For MARKED DIMENSIONS HERE
    
    
        If objCmd.IsDimension Then
            Set DimensionName = objCmd.DimensionCommand
            ID = DimensionName.feat1          'capture the ID Name of the command that is being looked at.
            count1 = cnt
            If ID = "" Then            'Make sure that commands always have a Name.
                 ID = prevIDName
                 count1 = prevcount1
            End If
            prevIDName = ID       'Save the old Name just In Case the Next one is ""
            prevcount1 = count1
    
    
    
    
            ID2 = DimensionName.feat2
            count2 = cnt
            If ID2 = "" Then
                 ID2 = prevID2Name
                 count2 = prevcount2
            End If
            prevID2Name = ID2
            prevcount2 = count2
    
    
            If count1 = count2 Then       'If .feat1 And .feat2 names were found On the same Line, Then assign them both To the ID thats outtol
               ID = ID & "-" & ID2
            End If
        End If
    
    
        
            'Second Step: first possibility: hunt For legacy dimensions
            
            If objCmd.IsDimension And objCmd.Type <> 1000 Then
                dblTotalMeas = dblTotalMeas + 1
                Set objDimCmd = objCmd.DimensionCommand
                If objDimCmd.OutTol <> 0 Then
                    dblOutTol = dblOutTol + 1
                    Msg = Msg & ID & Chr(10)
                End If 'objDimCmd.OutTol<>0
            End If 'objCmd.IsDimension
    
    
            'Third Step: second possibility: hunt For XactMeasure GD&T dimensions
    
    
            If objCmd.Type = 184 Then         'this seems To be the way To find an XactMeasure GD&T Call.
    
    
                If objCmd.gettext(LINE1_OUTTOL, 1) <> "" Then 'look In Line 1 For an OUTTOL
                    dblTotalMeas = dblTotalMeas + 1
                    If objCmd.gettext(LINE1_OUTTOL, 1) <> 0 Then 'If there is an OUTTOL In Line 1, is it Not zero?
                        dblOutTol = dblOutTol + 1
                        Msg = Msg & ID & Chr(10)
                    End If 'objCmd.gettext(LINE1_OUTTOL,1)<>0
                End If 'objCmd.gettext(LINE1_OUTTOL,1)<>""
               
                If objCmd.gettext(LINE2_OUTTOL, 1) <> "" Then 'look In Line 2 For an OUTTOL
                    dblTotalMeas = dblTotalMeas + 1
                    If objCmd.gettext(LINE2_OUTTOL, 1) <> 0 Then 'If there is an OUTTOL In Line 2, is it Not zero?
                        dblOutTol = dblOutTol + 1
                        Msg = Msg & ID & Chr(10)
                    End If 'objCmd.gettext(LINE1_OUTTOL,1)<>0
                End If 'objCmd.gettext(LINE2_OUTTOL,1)<>""
    
    
                If objCmd.gettext(LINE3_OUTTOL, 1) <> "" Then 'look In Line 3 For an OUTTOL
                    dblTotalMeas = dblTotalMeas + 1
                    If objCmd.gettext(LINE3_OUTTOL, 1) <> 0 Then 'If there is an OUTTOL In Line 3, is it Not zero?
                        dblOutTol = dblOutTol + 1
                        Msg = Msg & ID & Chr(10)
                    End If 'objCmd.gettext(LINE3_OUTTOL,1)<>0
                End If 'objCmd.gettext(LINE3_OUTTOL,1)<>""
    
    
    
    
            End If 'objCmd.Type=184
    
    
         End If    'objcmd.marked = True        'End marked search here
      
    
    
    Next cnt
    
    
    If dblOutTol = 0 Then
       MsgBox "Part is GOOD!"
    End If
    
    
    
    
    If dblOutTol > 0 Then
       MsgBox "Part is BAD!" & Chr(10) & "Number of Dimensions Out of Tolerance: " & dblOutTol & Chr(10) & "Features out of tolerance: " & Chr(10) & Msg ' Display the ID's that are out of tolerance
    End If
    
    
    Set objOutTol.DoubleValue=dblOutTol
    objPart.SetVariableValue "NUMBEROUTTOL",objOutTol 
    
    
    
    
    End Sub


    It's pretty much copied from another post here except for a couple lines at the end. Any ideas?


    How are you getting the variabel passed back to PC-DMIS? I am unable to get this portion to work. Thank you!
  • I'm not at my Machine right now but you need to add an assign command as follows:

    ASSIGN/NUMBEROUTTOL=""

    I think that's the syntax in my program. I'll check when I get in tomorrow and let you know.

    Sent from my GT-N5110 using Tapatalk 2
  • Wow this is old!

    This was only really designed to give me a total dimensions out count at the end of a part execution. I used to send this stuff to a database and track OOT dimensions over long periods of time based on part number. Chart it up at the end of the month, and the problem jobs pop out. The messagebox DID display the correct feature....when used with PC-DMIS 2009....
  • Wow this is old!

    This was only really designed to give me a total dimensions out count at the end of a part execution. I used to send this stuff to a database and track OOT dimensions over long periods of time based on part number. Chart it up at the end of the month, and the problem jobs pop out. The messagebox DID display the correct feature....when used with PC-DMIS 2009....


    Old, but works very well! The messagebox works fine for me in 2011 MR1.

    This is the code I have in my part program:

    ASSIGN/NUMBEROUTTOL=0
    CS4        =SCRIPT/FILENAME= J:\CMM\REPORTING\SCRIPTS\OUTTOL.BAS
    FUNCTION/Main,SHOW=NO,,
    STARTSCRIPT/
    ASSIGN/NUMOUTTOL=NUMBEROUTTOL
    IF/NUMOUTTOL==0
    END_IF/
    ELSE_IF/NUMOUTTOL>0
    COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
    "Part is Bad. There are "+NUMOUTTOL+" dimensions out of tolerance."
    END_ELSEIF/


    I actually end up with two message boxes, one from the script and one from the above code. That way the operator is sure to see (and hopefully read) one of them. We use this for sending data to a customer database. Data is only sent if no dim's are OOT. If there are OOT dim's the operator must re-work the parts until all dim's are in tolerance.
  • Old, but works very well! The messagebox works fine for me in 2011 MR1.

    This is the code I have in my part program:

    ASSIGN/NUMBEROUTTOL=0
    CS4        =SCRIPT/FILENAME= J:\CMM\REPORTING\SCRIPTS\OUTTOL.BAS
    FUNCTION/Main,SHOW=NO,,
    STARTSCRIPT/
    ASSIGN/NUMOUTTOL=NUMBEROUTTOL
    IF/NUMOUTTOL==0
    END_IF/
    ELSE_IF/NUMOUTTOL>0
    COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
    "Part is Bad. There are "+NUMOUTTOL+" dimensions out of tolerance."
    END_ELSEIF/


    I actually end up with two message boxes, one from the script and one from the above code. That way the operator is sure to see (and hopefully read) one of them. We use this for sending data to a customer database. Data is only sent if no dim's are OOT. If there are OOT dim's the operator must re-work the parts until all dim's are in tolerance.


    Thank you! I will give it a try soon. I am testing this out in 2011 MR1 but the message box gives me the feature and not the actual dimension. Not sure what I am doing wrong...oh well, at least it gives me something....lol
  • Nice to see it being used.



    I actually end up with two message boxes, one from the script and one from the above code. That way the operator is sure to see (and hopefully read) one of them. We use this for sending data to a customer database. Data is only sent if no dim's are OOT. If there are OOT dim's the operator must re-work the parts until all dim's are in tolerance.



    To make this even better, I used to bury it in subroutines. Each program would simply call a begin and end subroutine. Then, if I ever wanted to change my 'administrative and cleanup' code, I changed it once, in the subroutine, instead of across every program.
  • Thank you! I will give it a try soon. I am testing this out in 2011 MR1 but the message box gives me the feature and not the actual dimension. Not sure what I am doing wrong...oh well, at least it gives me something....lol


    This does not give any dimension values, only which dimensions are OOT. More code would be needed to do what you want.
  • This does not give any dimension values, only which dimensions are OOT. More code would be needed to do what you want.


    I'm sorry if I wasnt clear. It will give me the features....cir1, scn2, cyl3... not DIA1, PROF2 or DIA3

    It will say...

    Your part is bad!
    You have 3 dims out
    Cir1
    SCN2
    Cyl3

    when it should say

    Your part is bad!
    You have 3 dims out
    DIA1
    PROF2
    DIA3
  • It was designed to list feature names...not dimension names.

    I named my features- For example:
    Cir1= Datum B
    SCN2=Top_Profile
    etc....

    Name the features with Blueprint characteristics if that's what you want, or change the code.