Macro Automation

The eVolve Macro Automation tool speeds up and simplifies the macro creating 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 block to handle the work for users to decide how and when to use it by leveraging custom element filter rules.

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.

Location on the Ribbon

Once there is a Macro in the project, click the Macro Automation button from the Utilities panel.

Creating an Automation Rule

  1. Create a rule for the macro
    1. Click "Click here to add a new row."
  2. Assign a rule Rank
    1. This is used to sort rules in the grid as well as assign run orders.
  3. Assign a rule Name
    1. This field allows for the simple naming of a rule to quickly identify its use.
  4. Pick a Filter Type
    1. Choose a simple Category based Filter or a more universal Element Filter. We will continue with an Element Filter for this example.
  5. Create/Choose an Element Filter
    1. The element filter will be used to decide when to run the macro and what to run it on. To see more information on creating element filters see this article.
  6. Select the macro from the available Document Macros
    1. All macros that are a part of the project will be shown as options.
  7. Choose to set the rule to Auto (Optional)
    1. For macros that will be automated, click the Auto checkbox. This will ensure that anytime a part that matches the element filter is added or modified in the model, the macro will run.
  8. Enable the macro
    1. To toggle the macro on and off, use the Enabled checkbox.

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 will be available to use.
  • This feature does not honor dynamo scripts however these can be converted to their code equivalent and be used.
  • The target macro to execute is provided the Revit ElementIds which were 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) which is placed within the current user's Windows temp folder. This can be used to access the elements from the condition. An example code block is below however it provided in a utility method can be also be found here.
  • //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))

    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.
    //End Template

How did we do?

Powered by HelpDocs (opens in a new tab)

Powered by HelpDocs (opens in a new tab)