Add Modifiers to Arcade Script

The previous topic discussed adding Key modifiers in order to add flexibility and nuance to the symbols. Now, you need to inform the arcade script of the same changes. In short, you need to inform the script that the Key might be followed by modifiers and how to look for those modifiers.

  1. Open the Design Style you created earlier in an application that can edit SQLite database files, such as DB Browser.

  2. Browse the data inside the Design Style, and locate the “meta” table.

  3. In the meta table, there are two rows where you configure the behavior of the Design Style: dictionary_configuration and dictionary_script.

  4. Click dictionary_configuration first.

  5. In the previous example, the script only referenced the “Type” for symbol. Now, your symbols incorporate many other attributes such as ConductorType, Phases, WorkflowState, Diameter, Material, etc. Thus, all the attributes being used as modifiers must be included in the “symbol” row of the dictionary_configuration. Your symbol row varies depending upon what you included in your modifiers, but here is one example:

    {
      "configuration": [],
      "symbol": ["Type", "SpecType", "Energized", "ConductorType", "ConduitSystemType",
      "Phases", "ClosedPhases", "BreakerSubtype", "VoltageClass", "WorkflowState",
      "WorkFunction", "TransformerType", "DisconnectorSubtype", "PhaseCount",
      "Overloaded", "OpenPhases"],
      "text": []
    }

  6. Save the changes.

  7. Now, click on the dictionary_script row in the meta table.

  8. Before, the script only needed to match the featureType to the Key. Now, the script needs to understand to also match the modifiers. As an example, the script below is showing how the application should treat conductors and transformers with greater detail. It should include VoltageClass, Energized state, and PhaseCount when displaying conductors and transformers. For all features (including conductors and transformers), the application should understand the WorkFunction modifier.

    // this code matches the Keys and modifiers from Pro to the Recognized Keys in Designer XI
    var showFeature = false;
    var keys;
    
    if (showFeature) {
        var featureType = Lower($feature.Type);
    
        if (!isempty(featureType)) {
    
            keys = featureType;
    
            var showDetails = false;
            if (featureType == 'xfrb' || featureType == 'condb') {
                showDetails = true;
            }
    
            if (showDetails) {
                if (!isempty($feature.VoltageClass)) {
                    if ($feature.VoltageClass == '0') {
                        keys += '-p';
                    } else if ($feature.VoltageClass == '1') {
                        keys += '-s';
                    } else {
                        if (!isempty($feature.Energized) && $feature.Energized == 'None') {
                            keys += '-de';
                        }
                    }
                }
    
                if (!isempty($feature.PhaseCount)) {
                    keys += '-' + $feature.PhaseCount;
                }
            }
    
            if (!isempty($feature.WorkFunction)) {
                keys += '-' + Lower($feature.WorkFunction);
            }
    
            
    
            keys += ";";
    
        }
    
    }
    
    return keys;

  9. Save the changes.

QR Code is a registered trademark of DENSO WAVE INCORPORATED in Japan and other countries.

Was this helpful?