View, Node & Connectionο
This module contains the visual-representation layer of pyArchimate:
Viewβ a named diagram that belongs to a Model.Nodeβ the visual representation of an Element inside aView.Connectionβ the visual representation of a Relationship inside aView.Profile,Point,Positionβ supporting geometry types.
Module contentsο
Modern implementations of View, Node, Connection, Profile, Point, and Position.
All classes are self-contained and carry no dependency on the legacy module.
- class pyArchimate.view.Connection(ref=None, source=None, target=None, uuid=None, parent=None)[source]ο
Bases:
objectA visual connection between two Nodes, backed by a Relationship.
- Parameters:
ref β Relationship identifier or Relationship-like object (duck-typed)
source β source Node identifier or Node object
target β target Node identifier or Node object
uuid β connection identifier
parent β parent View
- property access_type: str | Noneο
Access type (for Access relationships).
- property conceptο
Referenced Relationship object.
- property influence_strength: str | Noneο
Influence strength (for Influence relationships).
- property is_directed: boolο
Whether relationship is directed.
- l_shape(direction=0, weight_x=0.5, weight_y=0.5)[source]ο
Shape the connection as an L (one bendpoint).
- property name: str | Noneο
Relationship name.
- property ref: strο
Relationship reference identifier.
- s_shape(direction=0, weight_x=0.5, weight_y=0.5, weight2=0.5)[source]ο
Shape the connection as an S (two bendpoints).
- property type: strο
ArchiMate relationship type.
- property uuid: strο
Unique identifier for this connection.
- class pyArchimate.view.Node(ref=None, x=0, y=0, w=120, h=55, uuid=None, node_type='Element', label=None, parent=None)[source]ο
Bases:
objectA visual node in a View, representing an Element concept.
- Parameters:
ref β Element identifier or Element object
x β top-left x coordinate
y β top-left y coordinate
w β width
h β height
uuid β node identifier
node_type β one of βElementβ, βLabelβ, βContainerβ
label β label text (for Label/Container nodes)
parent β parent View or parent Node
- add(ref=None, x=0, y=0, w=120, h=55, uuid=None, node_type='Element', label=None, nested_rel_type=None)[source]ο
Create and return a child node embedded in this node.
- property cx: floatο
Center x coordinate.
- property cy: floatο
Center y coordinate.
- delete(recurse=True, delete_from_model=False)[source]ο
Delete this node and its related connections.
- property desc: str | Noneο
Description of referenced element.
- distribute_connections()[source]ο
Redistribute all connections evenly along each edge of this node.
- property fill_color: str | Noneο
Fill color in hex format.
- get_obj_pos(other_node: Node) Position[source]ο
Return a Position describing this nodeβs relationship to another.
- get_or_create_node(elem=None, elem_type=None, x=0, y=0, w=120, h=55, create_elem=False, create_node=False, nested_rel_type=None)[source]ο
Return an existing child node or create one if requested.
- get_point_pos(point: Point) Position[source]ο
Return positional relationship between this node and a point.
- getnodes(elem_type: str | None = None) list[Node][source]ο
Get child nodes filtered by element type.
- property h: intο
Height.
- in_conns(rel_type: str | None = None) list[Connection][source]ο
Incoming connections (this node as target), optionally filtered by type.
- is_inside(x: float = 0, y: float = 0, point: Point | None = None) bool[source]ο
Return True if the (x,y) point lies within this nodeβs bounding box.
- property name: str | Noneο
Name of referenced element (if Element node).
- out_conns(rel_type: str | None = None) list[Connection][source]ο
Outgoing connections (this node as source), optionally filtered by type.
- property ref: str | Noneο
Element reference identifier.
- resize(max_in_row=3, keep_kids_size=True, w=120, h=55, gap_x=20, gap_y=20, justify='left', recurse=False, sort='asc')[source]ο
Resize this node to fit all embedded children.
- property rx: floatο
Relative x coordinate (relative to parent).
- property ry: floatο
Relative y coordinate (relative to parent).
- property type: str | Noneο
ArchiMate type of referenced element.
- property uuid: strο
Unique identifier for this node.
- property w: intο
Width.
- property x: intο
Top-left x coordinate.
- property y: intο
Top-left y coordinate.
- class pyArchimate.view.Point(x: float = 0, y: float = 0, start_x: int | None = None, start_y: int | None = None, end_x: int | None = None, end_y: int | None = None)[source]ο
Bases:
objectA simple (x, y) coordinate pair stored as floats for lossless round-trips.
Archiβs native format encodes bendpoints as integer offsets from element centres; those centres can be half-integers (e.g. element height 55 β cy = y + 27.5). Storing the resolved absolute coordinate as a float preserves the value so that
round(bp.x - cx)reproduces the original integer offset exactly during export.- property x: floatο
X coordinate.
- property y: floatο
Y coordinate.
- class pyArchimate.view.Position[source]ο
Bases:
objectPositional relationship between two nodes (distance, angle, orientation).
- property dist: float | Noneο
Euclidean distance between nodes.
- class pyArchimate.view.Profile(name=None, uuid=None, concept=None, model=None)[source]ο
Bases:
objectAn Archimate stereotype / specialisation profile for elements or relationships.
- delete()[source]ο
Remove this profile and clear all references to it from elements and relationships.
- property uuid: strο
Unique identifier for this profile.
- class pyArchimate.view.View(name=None, uuid=None, desc=None, folder=None, parent=None)[source]ο
Bases:
objectA diagram (view) in an Archimate model containing Nodes and Connections.
- Parameters:
name β view name
uuid β view identifier
desc β description
folder β folder path for organisation hierarchy
parent β parent Model object (duck-typed: must have views_dict)
- add(ref: object = None, x: int = 0, y: int = 0, w: int = 120, h: int = 55, uuid: str | None = None, node_type: str = 'Element', label: str | None = None) Node[source]ο
Add and return a Node in this view.
- add_connection(ref: object = None, source: object = None, target: object = None, uuid: str | None = None) Connection[source]ο
Add and return a Connection between two Nodes.
- property conns: list[Connection]ο
All connections in this view.
- duplicate(name: str | None = None) View[source]ο
Create independent deep copy of this view registered in same model.
- Parameters:
name β Name for duplicated view. If None, appends β (copy)β to original name.
- Returns:
New View object with deep-copied nodes and connections.
- Raises:
ValueError β If view has no parent model (cannot register duplicate).
- get_or_create_connection(rel: object = None, source: Node | None = None, target: Node | None = None, rel_type: str | None = None, name: str | None = None, create_conn: bool = False) Connection | None[source]ο
Return an existing connection or create one if requested.
- get_or_create_node(elem: object = None, elem_type: str | None = None, x: int = 0, y: int = 0, w: int = 120, h: int = 55, create_elem: bool = False, create_node: bool = False) Node | None[source]ο
Return an existing node for the element, or create one if requested.
- property primary_viewpoint: str | Noneο
Return the primary viewpoint slug for this view.
- Returns:
canonical viewpoint slug or None
- Return type:
str | None
- property props: dict[str, object]ο
Custom properties dictionary.
- set_primary_viewpoint(viewpoint_id: str) None[source]ο
Set the primary viewpoint slug for this view.
- Parameters:
viewpoint_id (str) β canonical viewpoint slug (e.g. βtechnologyβ)
- Raises:
ValueError β if viewpoint_id is not a recognised slug
- to_svg(filepath: str | None = None) str[source]ο
Export view to SVG string and optionally write to file.
- Parameters:
filepath β Optional path to write SVG file to. If provided, SVG is written to this file path. If None, only the SVG string is returned.
- Returns:
SVG string (valid XML with <svg> root element)
- property type: strο
Type identifier (always βDiagramβ).
- property uuid: strο
Unique identifier for this view.