<!DOCTYPE html
  PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<!--
Copyright (c) 2006 UGS Corp.

All Rights Reserved.

This software and related documentation are proprietary to UGS Corp.
-->
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>mqc_collectEntitiesWithFilterOptions Code Example</title>
      <script language="javaScript">
        abridged="false";
        displayConditions=new Array();
      </script>
      <link type="text/css" href="../css/main_styles.css" rel="stylesheet">
   </head>
   <body class="bodydocs" onload="top.pageLoader()" bgcolor="#FFFFFF">
      <div class="title_topic4" id="xps10_pagetitle">mqc_collectEntitiesWithFilterOptions Code Example</div>
      <hr noshade="true">
      <table cellspacing="4" align="center">
         <tr valign="top">
            <td bgcolor="#f7f7f7" colspan="1" rowspan="1">
               <p class="para_td"><a class="links" href="javascript:void(0)" onclick="top.openFile('checkmate/filter_ov.html');return(false);">Overview</a></p>
            </td>
            <td bgcolor="#f7f7f7" colspan="1" rowspan="1">
               <p class="para_td"><a class="links" href="javascript:void(0)" onclick="top.openFile('checkmate/filter_code_list_ht.html');return(false);">How To </a></p>
            </td>
            <td bgcolor="#f7f7f7" colspan="1" rowspan="1">
               <p class="para_td"><a class="links" href="javascript:void(0)" onclick="top.openFile('checkmate/filter_code_custom_op.html');return(false);">Options</a> 
               </p>
            </td>
            <td bgcolor="#f7f7f7" colspan="1" rowspan="1">
               <p class="para_td"><a class="links" href="javascript:void(0)" onclick="top.openFile('checkmate/filter_entities_op.html');return(false);">Related Topics</a></p>
            </td>
         </tr>
      </table><br><p class="para_topic">The following is an example DFA checker that uses the mqc_collectEntitiesWithFilterOptions function. The DFA file contains new translation extensions to the Knowledge Fusion User Interface Styler to include a <b class="uiTerm">Specify Filters</b> option on the <b class="uiTerm">Customization</b> dialog (See Related Topics for details).
      </p>
      <div class="title_division">mqc_report_entities_with_filters DFA File</div><pre class="indent">#! NX/KF 4.0
#

DefClass: %ali_mqc_report_entities_with_filters( %ug_base_checker );

#++
Description:
    
    Report entities with the specified types, layers/categories and colors.

Parameters:

    ( List Parameter )  Entity Filter  - Specify entity type, layer and color, 
                                         can include or exclude.
                                         Default is: 
                                             Types  - Include - ALL
                                             Layers - Include - ALL
                                             Colors - Include - ALL
                               
    (String Parameter)  Log Message    - User specified log message.
                                         Default is an empty string.

Results:
 
    Info -  Report entities with the specified types and reside on 
            the specified layers and in the specified color.
#-


   ( String )    %test_category:  &quot;My_Filter.Modeling&quot;;
   ( String )    %displayed_name: &quot;Report Entities with Specified Filters&quot;;
   ( Boolean Parameter )    Disabled?: False;
   ( Boolean Parameter )    save_log_in_part: True;
   
#  Attributes for this class

   ( List Parameter )    entities: {};
   ( String )            entities_label: &quot;Entity Filter&quot;;
   ( Name Parameter )    entities_type_mode: Include;
   ( List Parameter )    entities_type_filter: {all};
   ( Name Parameter )    entities_layer_mode: Include;
   ( List Parameter )    entities_layer_filter: {all};
   ( Name Parameter )    entities_color_mode: Include;
   ( List Parameter )    entities_color_filter: {all};

   ( String Parameter )  log_msg: &quot;&quot;;
   ( String )            log_msg_label: &quot;Log Message&quot;;

   (Any Uncached)   do_check:

   @{
       $usr_msg &lt;&lt; If ( &quot;&quot; = log_msg: ) Then &quot;&quot; Else &quot;~n&quot;+log_msg:;

       #Build filter condition string       
       $type_str  &lt;&lt; If ( (entities_type_mode: = Include) &amp; Member(All,entities_type_filter:))
                     Then &quot;&quot;
                     Else If ( entities_type_mode: = Include )
                     Then &quot;    Types: Include &quot;+mqc_list_to_string(entities_type_filter:,&quot;,&quot;)+&quot;~n&quot;
                     Else &quot;    Types: Exclude &quot;+mqc_list_to_string(entities_type_filter:,&quot;,&quot;)+&quot;~n&quot;;
                            
       $layer_str &lt;&lt; If ( (entities_layer_mode: = Include) &amp; Member(All,entities_layer_filter:) )
                     Then &quot;&quot;
                     Else If ( entities_layer_mode: = Include )
                     Then &quot;    Layer/Category: Include &quot;+mqc_list_to_string(entities_layer_filter:,&quot;,&quot;)+&quot;~n&quot;
                     Else &quot;    Layer/Category: Exclude &quot;+mqc_list_to_string(entities_layer_filter:,&quot;,&quot;)+&quot;~n&quot;;

       $color_str &lt;&lt; If ( (entities_color_mode: = Include) &amp; Member(All,entities_color_filter:) )
                     Then &quot;&quot;
                     Else If ( entities_color_mode: = Include )
                     Then &quot;    Colors: Include &quot;+mqc_list_to_string(entities_color_filter:,&quot;,&quot;)+&quot;~n&quot;
                     Else &quot;    Colors: Exclude &quot;+mqc_list_to_string(entities_color_filter:,&quot;,&quot;)+&quot;~n&quot;;

       #Get all entities with specified type and layer and color.
       $specified_entities  &lt;&lt; mqc_collectEntitiesWithFilterOptions( 
                                 entities_type_mode:,  entities_type_filter:,
                                 entities_layer_mode:, entities_layer_filter:,
                                 entities_color_mode:, entities_color_filter: );

       #Build detail log message.
       $entities_num  &lt;&lt; Length( $specified_entities );
       
       $entities_num_str &lt;&lt; If( $entities_num = 0 )
                            Then &quot;No specified entity found&quot;
                            Else If ( $entities_num = 1 )
                            Then &quot;Found one specified entity&quot;
                            Else &quot;Found &quot;+stringvalue($entities_num)+&quot; entities&quot;;
                            
                                
       $detail_msg  &lt;&lt; If ( ($type_str = &quot;&quot;) &amp; ($layer_str = &quot;&quot;) &amp; ($color_str = &quot;&quot;) )
                       Then $entities_num_str
                            +&quot; in part.~n&quot;
       
                       Else $entities_num_str
                            +&quot; with following filters:~n&quot;
                            +$type_str 
                            +$layer_str 
                            +$color_str;

       #Log these entities.
       ug_mqc_log( LOG_INFO, $specified_entities, $detail_msg + $usr_msg );
   };</pre></body>
</html>