---
title: "PlantUML连线的注意事项"
author: "lyj86"
date: "2019-01-04T17:28:23Z"
tags: []
categories: ["开源软件"]
slug: "plantuml"
draft: false
lastmod: "2019-01-04T21:42:28Z"
id: 2436126
url: "https://lyj86.iteye.com/blog/2436126"
---

PlantUML教程中（http://s.plantuml.com/PlantUML\_Language\_Reference\_Guide\_ZH.pdf），4.5更多分支一节，代码如下：

 

@startuml

(\*) --&gt; if "Some Test" then

--&gt;\[true] "activity 1"

if "" then

-&gt; "activity 3" as a3

else

if "Other test" then

-left-&gt; "activity 5"

else

--&gt; "activity 6"

endif

endif

 

else

-&gt;\[false] "activity 2"

endif

 

a3 --&gt; if "last test"then

--&gt; "activity 7"

else

-&gt; "activity 8"

endif

 

@enduml

 

如果不用 a3 --&gt; if "last test"... 而是直接写 --&gt; if "last test"...，那么活动图里面activity 2节点就会有线连接到 "last test"节点，这里需要注意一下。

 

 

如果想从别的分区A的point 1节点连到分区B，然后分区B连回"point 2"节点，不想让point 1节点与point 2节点相连，就要给写成如下代码，并且p2的定义必须在引用它之前才行。

 

partition A {

   ...

   --&gt; "point 1" as p1

 

   "point 2" as p2 --&gt; ...

}

 

partition B {

   p1 --&gt; ...

   --&gt; p2

}

 

另外，poing 2 as p2必须和后面的--&gt; xxx 写在同一行。就类似(\*) --&gt; xxx一样。如果只写poing 2 as p2，会报错。

 

另外，如果partition B 里面写了"point 1" --&gt; ...，而没有使用别名p1，那么出来的图就是A区显示point 1节点，B区显示point 1节点，但是两个节点之间没有连线。