Breadcrumbs

Step 2 Play a Macro

Now we have been recorded a macro, let's use it to batch modify similar devices.

Play a Macro from a manual selection


  1. Select components in the nav tree.Then click right and select Play Macro

    play macropng.png

  2. The list of components you wish to play the macro will appear.. Select the macro you just recorded in the list. Hit Play.

    image2019-8-25_11-26-0.png


There were two choices available in the popup:

  • Action { Apply directly ; Apply on a query }Apply Directly: the macro will be applied on the selected components which appear in the list.Apply on a query: it allows you to play the macro not on the selected components but on a Selection you can define in the BtibService. Let's see this in details.


[Advanced] Play a macro from a Selection


Selecting components to play a macro can be time consuming if they don't belong to the same parent or if you need to filter them by a criteria. Example: select only components from type A or select only the first device in every device folder.

This is precisely the purpose of "Selections". They are based on bql or neql syntax.

Let's create a new Selection. Open tools and select Active Pro Macro Manager.


active pro macro manager.png

 

Notice the macro you just recorded before. This is where every macro is saved. We'll be back there in the next step.

image2019-8-25_11-36-20.png


Open the tab called "Selections". Click on New at the bottom to create a new Selection. Then hit ok.

image2019-8-25_11-38-22.png


Give a name like "All submeters"

image2019-8-25_11-39-8.png



Since the Selections and the macros are in in a bog file, managers are not updating automatically. You need to refresh the view when you add or delete a component.


The Selection will then appear

image2019-8-25_11-41-14.png


Click right on the Selection, select views then Ax Property Sheet. Fill-in the query like for example:

station:|slot:|bql:select * from driver:Device where displayName like '%SubMeter%'

image2019-8-25_11-45-18.png

You can try your query by copy-pasting it to the station (remember this is an offline bog, so you can't play it directly).


When you're done, don't forget to save the bog file at the top.

image2019-8-25_11-49-31.png


Now, go back to the station, click-right anywhere and select "PlayMacro". But this time select "Apply on a query", and choose the Selection you've just created. Hit play.

image2019-8-25_11-51-5.png


The popup will show you the list of components selected by the query. Confirm.

image2019-8-25_11-52-45.png


See the result.


Use of the console


You probably noticed, the log console was opened. You can see in the console every operation being done by the macro and track for errors.

image2019-8-25_11-54-22.png


Next Step


Step 3 Modify a macro