topo_layout
Automatically arranges device coordinates in a .topo file using layout modes such as layered, tree, grid, ring, or custom zones. Removes the need to manually set x/y positions for each device.
Instructions
自动排布设备坐标,不用手工填 x/y。
Args: path: .topo 文件路径。 mode: 布局方式。
- layered(默认):按连线关系自动分层,出口在上、终端在下,
最贴近常见的园区网拓扑图。
- tree:从 root 出发按层级展开。
- grid:网格铺开,适合还没连线的时候。
- ring:环形,适合环网。
groups: 只在 layered 下有效。手工指定每一层放哪些设备,
例如 [["Internet"], ["AR1"], ["Core1","Core2"]]。
没列进去的设备会自动补到最后一层。
root: 只在 tree 下有效,指定树根设备名。省略则挑连线最多的那台。
columns: 只在 grid 下有效,每行几台。省略则自动取平方根。
zones: 可选的分区列表。每项包含 title(或 name)、devices,可选
color(#RRGGBB)和 columns。给了 zones 后会使用分区布局,
mode/groups/root/columns 不再参与排布。
replace_annotations: 拓扑已有背景图形或文字时,是否明确清空并按 zones
重建。默认拒绝覆盖,因为 eNSP 标注没有稳定 ID,无法可靠区分手工项。
include_unassigned: zones 未包含的设备是否自动放入“未分区”背景框,默认是。
zone_columns: 整体画布每行放几个分区;0 表示自动。
allow_annotation_desync: 普通布局遇到已有标注时是否仍移动设备。默认否,
避免背景框和文字留在旧位置;仅在确认标注无需同步时才设为 true。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | layered | |
| path | Yes | ||
| root | No | ||
| zones | No | ||
| groups | No | ||
| columns | No | ||
| zone_columns | No | ||
| include_unassigned | No | ||
| replace_annotations | No | ||
| allow_annotation_desync | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |