Macro Automation

Overview of Macro Automation

Located in the Utilities panel, the eVolve Macro Automation tool speeds up and simplifies the macro creation process. Utilizing eVolve Element Filters will drastically reduce the size of the codebase and allow it to be more universal. In-house teams can write simple code blocks to handle the work for users to decide how and when to use it by leveraging custom element filter rules.

Tool Palette buttons
  • Refresh Current View - used to re-run the Macro Automation rules on the current active view.
  • Refresh Full Project - used to re-run the Macro Automation rules on the entire project view.
  • Export Rules - used to transfer Macro Automation rules to another project.
  • Import Rules - used to bring in Macro Automation rules from another project.
Grid Columns
  • Run Order - used to define the sequence in which the rules are executed, 1 is 1st, 2 is 2nd, 3 is 3rd, etc.
  • Run in Second Pass - indicates whether the rule runs after all other processing has been completed, see below for more information.
  • Rule Name - used to apply a label to a Macro Automation rule.
  • Description - used to provide additional information about the Macro Automation rule.
  • Element Filter - used to define the categories and optional conditions, which elements and their parameters are filtered against.
  • Document Macros - lists all available macros in the project.
  • Execute On - defined when/how the Macro Automation rule runs.
    • Manual Only - the rule will only run when either the Refresh Current View or Refresh Full Project button is manually clicked.
    • Any Update - the rule runs when any change to the drawing is made.
    • New Element Creation - the rule will only run when an element is placed on the drawing area.
    • Existing Element Change - the rule runs when an existing element is modified.
  • Enabled - if unchecked, the rule is disabled and will not run.

Creating an Automation Rule

  1. From the eVolve ribbon, in the Utilities panel, click Macro Automation.
  2. From the grid, click the top row with Click here to add a new row. displayed and add the following required information:
    Required:
    - Rule Name - the name does not have to be unique as you may utilize Description, Group, and Sub Group to further distinguish it from other profiles.
    - Document Macros - Only macros for this project are displayed.
    NOTE: If undefined, "Copy from Parameter must be provided." is displayed in the Error Message column.
    - Element Filter - defines the elements the Macro Automation rule will run against.
    Optional:
    - Run Order - automatically assigned if undefined.
    - Run in Second Pass - the default state is checked.
    - Description - blank if left undefined.
    - Group - blank if left undefined.
    - Sub Group - blank if left undefined.
    - Execute On - the default value is Manual Only if left undefined.
    - Enabled - if unchecked, the rule is disabled and will not run.
  3. After the Required and Optional fields are defined, click Apply. The new row is added to the grid.

Using a Macro

To use this tool, there must be an existing macro in the project. This macro will only need to handle the "work" needed as the firing mechanism and element collection will be handled by the Automation rule.

Below is a simple example that writes the Room Name of the room an element is in, to a custom shared parameter.  Note that this block along with many others can be found here.

Run in Second Pass

The Run in Second Pass option gives users the option to run rules after Revit and eVolve have completed processing instead of before. Basically, if the Run in Second Pass option is unchecked when a rule runs and the expected elements are not colored, check the Run in Second Pass option.

NOTE: If the same parameter is being changed in both the first pass and second pass the updating of the second pass parameter(s) change will fail, throwing an error. However, parameters may be changed multiple times in the same pass.

Technical Notes

  • When a rule is satisfied, the respective Document Macro is queued for execution after the current Revit modify operation is complete.
  • The Macro must be at the project level. No application-level macros are available for use.
  • This feature does not honor dynamo scripts, however, their code equivalent can be converted and used.
  • The target macro to execute is provided by the Revit ElementIds which are captured as part of the process. This information is transmitted via a file named eV-[RuleName].txt (where "RuleName" is the respective Macro Automation rule name) that is placed within the current user's Windows temp folder.
  • The sample code below is for a Revit Macro which demonstrates how a consumer can access this information. The snip between the "Template" lines can be considered a boilerplate.
  • public void Sample()
    {
    const string MacroAutomationRuleName = "Test";

    //Begin Template
    var addedIds = Array.Empty<ElementId>();
    var modifiedIds = Array.Empty<ElementId>();

    // Extract all the added and modified id's impacted by this rule.
    var elementIdFile = System.IO.Path.Combine(System.IO.Path.GetTempPath(), string.Format("eV-{0}.txt", MacroAutomationRuleName));
    if (System.IO.File.Exists(elementIdFile))
    {
    // File contains added ids on the first line and modified on the second.
    var elementIds = System.IO.File.ReadAllText(elementIdFile).Split(new string[] { Environment.NewLine }, StringSplitOptions.None)
    .Select(ids => ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries))
    .ToArray();

    addedIds = elementIds[0].Select(id => new ElementId(int.Parse(id))).ToArray();
    modifiedIds = elementIds[1].Select(id => new ElementId(int.Parse(id))).ToArray();
    }

    if (!addedIds.Any() && !modifiedIds.Any())
    {
    // Nothing of consequence.
    return;
    }
    //End Template

    TaskDialog.Show("eVolve Macro Automation Sample",
    "Element Ids:"
    + "\n Added = " + string.Join(", ", addedIds.Select(id => id.IntegerValue.ToString()))
    + "\n Modified = " + string.Join(", ", modifiedIds.Select(id => id.IntegerValue.ToString())),
    TaskDialogCommonButtons.Ok);
    }

Security Note

Running macros does carry a security risk in that "arbitrary code" may be executed from within Revit. Worst case scenario is something like User 1 creates a rule in the model which on a param update executes a Macro/PowerShell script. User 2 then opens this model on his machine and the rule is triggered which executes the code User 1 put in place (on User 2's machine).

Relevant Articles

Creating an Element Filter

Macro Examples


How did we do?


Powered by HelpDocs (opens in a new tab)

Powered by HelpDocs (opens in a new tab)