<HTML><HEAD><link type="text/css" href="../css/main_styles.css" rel="stylesheet"></HEAD>
<BODY><TITLE>%measure_dist_between_2pts</TITLE><H1>%measure_dist_between_2pts  </H1><P CLASS="Paragraph">Classname: <B>%measure_dist_between_2pts  </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>
    This checker validates the minimum distance between two points along a measurement
    direction. The user will select two points to be measured and a vector to indicate
    the measurement direction.
Parameters:
    ( Point )   point_1 - first point selected.
                          Might be selected interactively via the Point Construction dialog.
    ( Point )   point_2 - second point selected.
                          Might be selected interactively via the Point Construction dialog.
    ( Vector )  measurement_direction - vector along the dimensional line
                                        for the measurement of distance between two points.
    ( Name )    unit - mm or inches, default is mm.
    ( List )    pass_range (in millimeter)
                         - A list of one or two range limits for the pass range criterion.
                           Each range bound has two members.  The first member
                           defines the condition which can be LT, LE, GT or GE keyword.
                           LT is "less than". LE is "less than or equal to".
                           GT is "greater than". GE is "greater than or equal to".
                           The second member is integer or real value for the
                           range limit. For example, {{GT, 0.0}, {LE, 1.0}} or {{LE, -1}}.
                           If a range list has two limits, then the first limit defines the lower
                           limit; the second limit defines the upper limit. Otherwise, the checker
                           will return an invalid range error.
    ( List )    warning_range (in millimeter)
                         - A list of one or two range limits for the warning range criterion.
    ( List )    fail_range (in millimeter)
                         - A list of one or two range limits for the failure range criterion.
    ( String )  error_message - error message to be logged.
    ( String )  warning_message - warning message to be logged.
    (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.
Results:
    PASS         -- The measured distance passes the checking criteria.
    WARNING      -- The measured distance is marginal against the minimum and maximum ranges.
    FAIL         -- The measured distance fails the checking criteria.
</PRE><PRE><FONT COLOR= blue>DefClass: %measure_dist_between_2pts ( %ug_base_checker );
</FONT></PRE><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( String )    %test_category:  "Template.Measurement";
   ( String )    %displayed_name: "Check Two Point Distance Range";

</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\">   Attributes for this class</PRE><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( String )           unit_label: "Range Unit";
   ( List )             unit_option: {mm, inches};

</SPAN></FONT></PRE></DIV><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( Point Parameter )   Point_1: point(0,0,0);
   ( Point Parameter )   Point_2: point(0,0,0);
   ( Vector Parameter )   Measurement_direction: vector(1,0,0);
   ( Name Parameter )   unit: mm;
   ( List Parameter )   pass_range: {};
   ( List Parameter )   warning_range: {};
   ( List Parameter )   fail_range: {};
   ( String Parameter )   error_msg: "Distance measurement falls in fail range.";
   ( String Parameter )   warning_msg: "Distance measurement falls in marginal range.";
</SPAN></FONT></PRE></DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\">   Checker function</PRE><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   (Any Uncached)   do_check: 
if (Empty?(pass_range:) & Empty?(fail_range:) & Empty?(warning_range:) )
then
    ug_mqc_empty_param_warning()
else
@{ 
       $status << mqc_validate_3ranges(pass_range:, warning_range:, fail_range:); 
        
       if ($status) then 
       @{ 
           $msg << "Error in checking due to invalid range specification.";
           ug_mqc_log(LOG_ERROR, {}, $msg);  
       } 
       else 
       @{ 
           $vec << Point_1: - Point_2:; 
           $unit_vec << unitize(Measurement_direction:); 
           $xdist << abs($vec.$unit_vec); 
           $part_units << ug_askPartUnits( "" ); 

           $dist << if (unit: = mm) then 
                    @{ 
                        if ($part_units = pounds_and_inches) then 
                          $xdist*25.4
                        else $xdist; 
                    } 
                    else 
                    @{ 
                        if ($part_units = grams_and_millimeters) then 
                           $xdist/25.4
                        else $xdist; 
                    };  
          
           $unit_string << makestring(unit:);

           $result << mqc_check_range($dist, warning_range:); 
           if $result = True then                          
                @{  
                  $msg << warning_msg: + "The measured distance is " + 
                          format("%f"; $dist)+ " " + $unit_string +".";   
                  ug_mqc_log(LOG_WARNING, {}, $msg);  
                 }      
           else do_nothing;  
  
           $result << mqc_check_range($dist, fail_range:);                           
           if $result = True then  
                @{  
                  $msg << error_msg: + " The distance is " +
                          format("%f"; $dist) + " " + $unit_string +".";   
                  ug_mqc_log(LOG_ERROR, {}, $msg);  
                 }  
           else do_nothing;                                   
       }; 
        
   };

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