<HTML><HEAD><link type="text/css" href="../css/main_styles.css" rel="stylesheet"></HEAD>
<BODY><TITLE>%mqc_check_dimension_tolerance</TITLE><H1>%mqc_check_dimension_tolerance </H1><P CLASS="Paragraph">Classname: <B>%mqc_check_dimension_tolerance </B></P><P CLASS="Paragraph">Inherits from: <B><A href=..\checkmate\xug_base_checker.html>%ug_base_checker </A></B></P><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"> </PRE><PRE STYLE=\"text-align : left;\" CLASS=\"Code\">
<B>Description:</B>
   Check if dimension tolerances are within max and min ranges
   Lower tolerance increases manufacturing difficulties.
   Higher tolerance reflects poor design quality.
Parameters:
   ( Number )  min_linear_tol     -  Minimum linear tolerance (in Millimeter)
                                     The value should be positive, greater than or equal to 0.0.
                                     Default is 0.0.
                                     Not to check if given negative value.
   ( Number )  max_linear_tol     -  Maximum linear tolerance (in Millimeter)
                                     The value should be positive, greater than or equal to 0.0.
                                     Default is 0.0.
                                     Not to check if given negative value.
   ( Number )  min_angular_tol    -  Allowed minimum angular tolerance (in Degree)
                                     The value should be positive, greater than or equal to 0.0.
                                     Default is 0.0.
                                     Not to check if given negative value.
   ( Number )  max_angular_tol    -  Allowed maximum angular tolerance (in Degree)
                                     The value should be positive, greater than or equal to 0.0.
                                     Default is 0.0.
                                     Not to check if given negative value.
    (Boolean)  disabled?          -  If it is true, the checker is disabled.
                                     Default is False.
    (Boolean)  save_log_in_part   -  The flag indicates whether the checking results can
                                     be saved to the part file
                                     Default is True.
    (Integer)  log_type           -  Indicate which logging type to use to report the violation.
                                     1 - LOG_ERROR,
                                     2 - LOG_WARNING,
                                     3 - LOG_INFO,
                                     Default is 1 to log error.
    (String)   log_msg            -  User defined message to be added when the system
                                     reports the violation.
                                     Default is an empty string.
Results:
   PASS     - Dimension tolerances are within ranges.
   FAILED   - Any dimension tolerance is outside of the ranges.
============================================================================================
How to customize the checker: ( Change checker parameters)
  1.  Modify checker parameters:
         - Minimum linear tolerance,
         - Maximum linear tolerance,
         - Minimum angular tolerance,
         - Maximum angular tolerance.
      If negative value is entered, it means not to check.
  2. Specify log type and/or add log message if it is desired
         - Select Log option,
         - Enter Log Message.
How to create a new checker from this template:  (For checker author)
1. Change class name, category name and display name:
         New checker's class name must be unique.
         Remember to remove "template" word from the test_category: attribute
         Enter proper test_category: name for the new checker
         checker display name should be unique in the same category.
2. Provide values for checker parameters:
       - (Number) min_linear_tol:
       - (Number) max_linear_tol:
       - (Number) min_angular_tol:
       - (Number) max_angular_tol:
3. Specify default log option for checker. ( Optional )
      - (Integer) log_type:
        1 - LOG_ERROR
        2 - LOG_WARNING
        3 - LOG_INFO
      - (String) log_msg:
         Additional message to log
4. Modify checker standard parameters: ( Optional )
      -  (Boolean) disabled?  set it to TRUE to disable the checker
      -  save log in part     set to False to not allow the checking results to be saved to the part
============================================================================================
</PRE><PRE><FONT COLOR= blue>DefClass: %mqc_check_dimension_tolerance( %ug_base_checker ); 
</FONT></PRE><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( String )              %test_category: "Template.Drafting";
   ( String )              %displayed_name: "Check Dimension Tolerances";

</SPAN></FONT></PRE></DIV><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( Boolean Parameter )   disabled?: False;
   ( Boolean Parameter )   save_log_in_part: True;
</SPAN></FONT></PRE></DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"> parameter for the checker</PRE><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( String )               min_linear_tol_label:    %ug_MSGTXT("Minimum Linear Tolerance (Millimeter)");
   
</SPAN></FONT></PRE></DIV><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( String )               max_linear_tol_label:   %ug_MSGTXT("Maximum Linear Tolerance (Millimeter)");   

</SPAN></FONT></PRE></DIV><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( String )               min_angular_tol_label:    %ug_MSGTXT("Minimum Angular Tolerance (Degree)");
   
</SPAN></FONT></PRE></DIV><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( Number Parameter )     min_linear_tol:          0.0;
   ( Number Parameter )     max_linear_tol:     0.0;
   ( Number Parameter )     min_angular_tol:          0.0;
   ( Number Parameter )     max_angular_tol:     0.0;
</SPAN></FONT></PRE></DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\">  parameter for log_option                                       </PRE><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( String )               max_angular_tol_label:   %ug_MSGTXT("Maximum Angular Tolerance (Degree)");   
   
</SPAN></FONT></PRE></DIV><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( Integer Parameter )    log_type: 1;
</SPAN></FONT></PRE></DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\">  parameter for log_message     </PRE><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( list )                 log_type_option: { LOG_ERROR, LOG_WARNING, LOG_INFO };
   ( string )               log_type_label: %ug_MSGTXT("Log Option");
   
</SPAN></FONT></PRE></DIV><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( string Parameter )     log_msg: "";
</SPAN></FONT></PRE></DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\">  checking ...</PRE><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( string )               log_msg_label: %ug_MSGTXT("Log Message");


</SPAN></FONT></PRE></DIV><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( Any Uncached ) 
      do_check:
   @{ 
       
       # verify parameters
       $check_linear_min? << If ( min_linear_tol: < 0.0 ) | 
                                -( min_linear_tol: < max_linear_tol: )
                             Then False
                             Else True;
       $check_linear_max? << If ( max_linear_tol: < 0.0 ) |
                                -( min_linear_tol: < max_linear_tol: )
                             Then False
                             Else True;                          
       $check_angular_min? << If ( min_angular_tol: < 0.0 ) |
                                 -( min_angular_tol: < max_angular_tol: )
                             Then False
                             Else True;
       $check_angular_max? << If ( max_angular_tol: < 0.0 ) |
                                 -( min_angular_tol: < max_angular_tol: )
                             Then False
                             Else True;             

    if ( $check_linear_min?  | $check_linear_max? |
         $check_angular_min? | $check_angular_max?  )
    then
    @{
       # get all dimensions
       $dimensions << mqc_askEntities( DIMENSION );

       # UNIT conversion
       $part_unit << ug_askPartUnits("");

       $min_linear_tol << If $part_unit = Pounds_And_Inches
                          Then  min_linear_tol:/25.4
                          Else  min_linear_tol:;
       $max_linear_tol << If $part_unit = Pounds_And_Inches
                          Then  max_linear_tol:/25.4
                          Else  max_linear_tol:; 

       # log detail info for each object
       $status << ug_mqc_log_object_detail_flag( 1 );                              

       If Empty?( $dimensions )
       Then Donothing
       Else Loop
       {
           For $each_dim In $dimensions;
        
           For $is_ang Is ug_mqc_IsAngularDim( $each_dim );
           
           For $tol Is ug_mqc_askDimTolerance( $each_dim );
           For $high_tol Is First( $tol );
           For $low_tol  Is Abs( Second( $tol ) );
           
           Do If $is_ang
              Then
                 @{ 
                     If  ( $check_angular_max? & ( $high_tol > max_angular_tol:) | ($low_tol > max_angular_tol:))
                     Then
                       @{
                           $each_msg << %ug_MSGTXT("Found dimension whose tolerance ")+ Format( "(%f,", $low_tol )+ Format( "%f )", $high_tol )+ 
                                        %ug_MSGTXT(" is higher than maximum tolerance: ")  + Format( "%f", max_angular_tol: ) + %ug_MSGTXT(" degree.");
                                                                  
                           ug_mqc_log_object_detail( Nth( log_type:, log_type_option: ), { $each_dim }, $each_msg );                                  
                         }
                     Else Donothing;        

                     If  ( $check_angular_min? & ( $high_tol < min_angular_tol:) | ($low_tol < min_angular_tol:))
                     Then
                       @{
                           $each_msg << %ug_MSGTXT("Found dimension whose angle tolerance ")+ Format( "(%f,", $low_tol )+ Format( "%f )", $high_tol )+ 
                                        %ug_MSGTXT(" is lower than minimum tolerance: ") + Format( "%f", min_angular_tol: ) ;
                                      
                           ug_mqc_log_object_detail( Nth( log_type:, log_type_option: ), { $each_dim }, $each_msg );                                   
                         }                            
                     Else Donothing;                            

                  }
              Else
                @{  
                     If  ( $check_linear_max? & ( $high_tol > $max_linear_tol ) | ($low_tol > $max_linear_tol))
                     Then
                       @{
                           $each_msg << %ug_MSGTXT("Found dimension whose tolerance ") + Format( "(%f,", $low_tol )+ Format( "%f )", $high_tol )+ 
                                        %ug_MSGTXT(" is higher than maximum tolerance: " ) + Format( "%f", $max_linear_tol ) ;
                                       
                           ug_mqc_log_object_detail( Nth( log_type:, log_type_option: ), { $each_dim }, $each_msg );                                  
                         }
                     Else Donothing;        
                     
                     If  ( $check_linear_min? & ( $high_tol < $min_linear_tol) | ($low_tol < $min_linear_tol))
                     Then
                       @{
                           $each_msg << %ug_MSGTXT("Found dimension whose tolerance ") + Format( "(%f,", $low_tol )+ Format( "%f )", $high_tol )+ 
                                        %ug_MSGTXT(" is lower than minimum tolerance: ")  + Format( "%f", $min_linear_tol ) ;
                                       
                           ug_mqc_log_object_detail( Nth( log_type:, log_type_option: ), { $each_dim }, $each_msg );                                   
                         }                            
                     Else Donothing;                  
                     
                  };
         };

    }
    Else
        ug_mqc_empty_param_warning();
        
   };

</SPAN></FONT></PRE></DIV></TABLE><p class=EndLine>&nbsp;</p><p class=blank>&nbsp;</p></BODY></HTML>