CATIA Magic (CATIA Cybersystes, System of Systems)

Query Dialog & Legends - Not the same as others!

The Query Dialog for the Legend is a bit different than the other dialogs ( create custom column). The goal of the legend dialog (launched from Elements by Condition property of the Legend Item Specification) is to filter items on the diagram against the query. If the query returns true, then the legend is applied. 

Model with legend automatcally applied based on general type

In the diagram below, we have annotated important parts.

Element Type - This is a filter of what types will be processed. This Element by default. However, you should change this to the types you are annotating. This also can affect how the sub-queries are automatically typed. This also improves performance as only elements that are of the same type(s) specified here. Note that it is better to change this item first as many queries are driven by this setting. Also, for complex queries, keep track of the type in each as the default type will be from this setting and may need to be set to that stage of the query (see video). 

Body - this is where we create a query that returns true or false. This is important as we will not get desired results if we don't. By default the Property Test is created for you. However, you are fully capable of handling queries. Note that we can have many queries in Condition. If one of the queries evaluates to true, the legend is applied. This also means that you can have one legend that gets applied to different elements. 

Evaluation Mode - In evaluation mode, we are testing elements The THIS argument needs to be an element of the type Element Type and the result we get back is an Ordered Set that has at least one in the set that is true. If we get the true for the THIS, the legend will be applied when we run it for real. Note that the evaluation does not apply the legend, it is only for checking that the query works as designed,

Importand parts of the legend 

In the video below, this is a complex query for a legend than sets the color and icon for the flow realized on an association. The customer wanted to be able to see the type or category of item flowing. Thus the query needs to navigate from the association (Operational Association in this case because this is UAF), then to the flow, then to the conveyed, then its generalization. This returns a list of general types of all the flows realized by the association. We then use the operation from model called contains, to test is one of the categories we are targeting is in the list. The contains returns a true if one of the items matches. Note that this is a common concept in queries where many stages of the query can return collections rather than single elements, so we need to do collection test operations rather than simple boolean logic.
Here are the steps for this example:

  1. New legend Item Created.
  2. Legend adornment is set to change line color (pen color), line width, and the icon.
  3. Click into the Element By Condition. 
  4. set the Element Type (in this case it is OperationalAssociation)
  5. Create a Simple Navigation
  6. Note: Unclick the Show relations criteria available only for context may be necessary depending on the stage.
  7. Select the relation criteria, Realization (Information Flow), also note that this is target to source
  8. Select the Condition root, then Create operation and add a Metachain Navigation.
  9. Expand the metachain and drag the Simple Navigation onto THIS. The concept is that the Metachain starts from the result of the Simple Navigation. 
  10. Click onto the root of the Metachain and set it as follows:

    Metachain to fined conveyed element's general classifiers
    1. OperationalExchange - Conveyed (note that we need to change the type to OperationalExchange as this is the result of the SimpleNavigation)
    2. Classifier | General
  11. Click on Condition root and click Create Operation and select Operation From Model, then search for contains.

    Operation from model: contains
  12. Drag the Metachain onto the input parameter (this will be the collection we are searching for a match)
  13. Click on the obj parameter then click Create Operation and select from the Values section, Element. We get a dialog popup to select the item we want to search for. 
  14. The query is complete and we can close the dialog.

To summarize we have created the following query contains(metachain(SimpleNavigation-Realization,OperationalExchange.Conveyed.Classifier.General),Element(Cat4))
Here is a video of that process:

Video to create a dynamic legend based on realization of a flow item of a specific subtype
UAF Model 24xR2