How can I duplicate a group of elements using a macro?

0 votes
asked Feb 26 in Wanted features by Ran Magen

Hi,

What I'm basically trying to achieve is to reuse a group of elements multiple times. for example:

actor User
!definelong MyGroup(XX)

    rectangle "Foo XX" {
        component "API" as api_XX
        component "Service" as service_XX

        api_XX --> service_XX
        service_XX --> api_XX
    }

!enddefinelong

MyGroup(1)
MyGroup(2)
User --> api_1
User --> api_2

Where the end result would be a User component with arrows to 2 separate rectangles that have the same look and names of components, except their variable names would be different.

This is useful in cases where the architecture design has a scaled out set of components.

1 Answer

0 votes
answered Feb 26 by Ran Magen

Ok, found my own answer.

Turns out if I define the variables using ##, the replacing works:

actor User
!definelong MyGroup(XX)

    rectangle "Foo XX" {
        component "API" as XX##service
        component "Service" as XX##service

        XX##api --> XX##service
        XX##service --> XX##api
    }
    User --> XX##api
!enddefinelong

MyGroup(1)
MyGroup(2)
...