11

In PlantUML adding activation lines in a sequence diagram can be very messy. Is there any way to make it auto activate and deactivate without all the extra text?

e.g.

Generate Sequence diagram without activation lines

@startuml

First -> Second
Second -> Third
Third -> Second
Second ->  First

@enduml

enter image description here

But to add the activation lines its gets quite messy

@startuml

First -> Second : message
activate First
activate Second
Second -> Third: message
activate Third
Third -> Second: response
deactivate Third
Second ->  First: response
deactivate First
deactivate Second

@enduml

enter image description here

I'm wondering if there is its possible to have it auto detect the likely create destroy points automatically

1
  • I doubt that's possible in any built-in way. There's no way for it to know when the active period should end. Commented Jul 8, 2016 at 12:31

1 Answer 1

20

Yes (2017) with autoactivate on; the syntax is still in incubation, however it has been part of the distribution for some time.

Note that in all cases you still need to manually activate the First one, because there's no incoming message.

Compact syntax

If you want to maintain control of the (de)activation, you can express activation/deactivation with ++ and -- symbols on the same line to activate the target.

activate First
First -> Second ++ : message12
Second -> Third ++ : message23
Third -> Second -- : response32
Second ->  First -- : response21
deactivate First

enter image description here

autoactivate on

With your original description you will quickly find out that you need to describe your lines properly as a return, otherwise you'll be activating ad nauseam.

autoactivate on
activate First
First -> Second
Second -> Third
Third --> Second
Second --> First
deactivate First

enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.