pyArchimate β Public API shimο
pyArchimate.pyArchimate is a compatibility shim that re-exports the full
public API from the individual sub-modules (Model, Element,
Relationship, View, Node & Connection, Enumerations, Exceptions,
Helpers). Importing from this shim gives access to every public
symbol in one place.
Module contentsο
Compatibility shim that re-exports legacy and modular APIs.
- class pyArchimate.pyArchimate.AccessType(*values)[source]ο
Bases:
str,EnumEnumeration of Access Relationship types
- Access = 'Access'ο
- Read = 'Read'ο
- ReadWrite = 'ReadWrite'ο
- Write = 'Write'ο
- class pyArchimate.pyArchimate.ArchiType(*values)[source]ο
Bases:
str,EnumEnumeration of ArchiMate element and relationship types.
Members cover all ArchiMate 3.x layers: Strategy, Motivation, Business, Application, Technology, Physical, and Implementation & Migration.
Business layer elements include: BusinessActor, BusinessRole, BusinessCollaboration, BusinessInterface, BusinessProcess, BusinessFunction, BusinessInteraction, BusinessEvent, BusinessService, BusinessObject, Contract, Representation, and Product.
- Access = 'Access'ο
- Aggregation = 'Aggregation'ο
- AndJunction = 'AndJunction'ο
- ApplicationCollaboration = 'ApplicationCollaboration'ο
- ApplicationComponent = 'ApplicationComponent'ο
- ApplicationEvent = 'ApplicationEvent'ο
- ApplicationFunction = 'ApplicationFunction'ο
- ApplicationInteraction = 'ApplicationInteraction'ο
- ApplicationInterface = 'ApplicationInterface'ο
- ApplicationProcess = 'ApplicationProcess'ο
- ApplicationService = 'ApplicationService'ο
- Artifact = 'Artifact'ο
- Assessment = 'Assessment'ο
- Assignment = 'Assignment'ο
- Association = 'Association'ο
- BusinessActor = 'BusinessActor'ο
- BusinessCollaboration = 'BusinessCollaboration'ο
- BusinessEvent = 'BusinessEvent'ο
- BusinessFunction = 'BusinessFunction'ο
- BusinessInteraction = 'BusinessInteraction'ο
- BusinessInterface = 'BusinessInterface'ο
- BusinessObject = 'BusinessObject'ο
- BusinessProcess = 'BusinessProcess'ο
- BusinessRole = 'BusinessRole'ο
- BusinessService = 'BusinessService'ο
- Capability = 'Capability'ο
- CommunicationNetwork = 'CommunicationNetwork'ο
- Composition = 'Composition'ο
- Constraint = 'Constraint'ο
- Contract = 'Contract'ο
- CourseOfAction = 'CourseOfAction'ο
- DataObject = 'DataObject'ο
- Deliverable = 'Deliverable'ο
- Device = 'Device'ο
- DistributionNetwork = 'DistributionNetwork'ο
- Driver = 'Driver'ο
- Equipment = 'Equipment'ο
- Facility = 'Facility'ο
- Flow = 'Flow'ο
- Gap = 'Gap'ο
- Goal = 'Goal'ο
- Grouping = 'Grouping'ο
- ImplementationEvent = 'ImplementationEvent'ο
- Influence = 'Influence'ο
- Junction = 'Junction'ο
- Location = 'Location'ο
- Material = 'Material'ο
- Meaning = 'Meaning'ο
- Node = 'Node'ο
- OrJunction = 'OrJunction'ο
- Outcome = 'Outcome'ο
- Path = 'Path'ο
- Plateau = 'Plateau'ο
- Principle = 'Principle'ο
- Product = 'Product'ο
- Realization = 'Realization'ο
- Representation = 'Representation'ο
- Requirement = 'Requirement'ο
- Resource = 'Resource'ο
- Serving = 'Serving'ο
- Specialization = 'Specialization'ο
- Stakeholder = 'Stakeholder'ο
- SystemSoftware = 'SystemSoftware'ο
- TechnologyCollaboration = 'TechnologyCollaboration'ο
- TechnologyEvent = 'TechnologyEvent'ο
- TechnologyFunction = 'TechnologyFunction'ο
- TechnologyInteraction = 'TechnologyInteraction'ο
- TechnologyInterface = 'TechnologyInterface'ο
- TechnologyProcess = 'TechnologyProcess'ο
- TechnologyService = 'TechnologyService'ο
- Triggering = 'Triggering'ο
- Value = 'Value'ο
- ValueStream = 'ValueStream'ο
- View = 'View'ο
- WorkPackage = 'WorkPackage'ο
- exception pyArchimate.pyArchimate.ArchimateConceptTypeError[source]ο
Bases:
ArchimateErrorRaised when an invalid or unsupported Archimate concept type is encountered.
- exception pyArchimate.pyArchimate.ArchimateRelationshipError[source]ο
Bases:
ArchimateErrorRaised when a relationship constraint is violated or an invalid relationship operation is attempted.
- class pyArchimate.pyArchimate.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.pyArchimate.Element(elem_type=None, name=None, uuid=None, desc=None, folder=None, parent=None, profile=None)[source]ο
Bases:
objectClass to manage Element artifacts with visual styling and hierarchy support.
Supports ArchiMate v3.x elements with optional parent-child relationships, custom visual styles (colors, transparency), and junction type semantics.
- Parameters:
name (str) β Name of the element
elem_type (str) β Archimate concept type of element
uuid (str) β element identifier
desc (str) β description of the element
folder (str) β folder path in which element should be referred to (e.g. /Application/BE)
parent (Model) β reference to the parent Model object
profile (str) β element profile identifier
Visual Styling (P3): - Use set_fill_color(color), set_line_color(color) to customize appearance - Supports hex colors (#RRGGBB) and named colors (e.g., βredβ, βblueβ) - Use set_line_width(width) and set_transparency(alpha) for additional styling - All visual properties are preserved during XML export/import round-trips
Hierarchy (P3): - Elements can be organized into parent-child relationships via Model.add_child() - Use get_parent() to retrieve parent, get_siblings() for neighbors - Junction elements (AND/OR/XOR) use set_junction_type() for semantics
Junction Types (P3): - Junction elements support type validation: βandβ, βorβ, βxorβ - Use set_junction_type(type_str) to set junction semantics - Junction types are validated on set and preserved in round-trip exports
- Raises:
ArchimateConceptTypeError β Exception raised on elem_type or parent type error
- Returns:
Element object
- Return type:
Example:
from pyArchimate import ArchiType from pyArchimate.model import Model m = Model('example') # Create elements process = m.add(ArchiType.BusinessProcess, 'Order Processing') func = m.add(ArchiType.BusinessFunction, 'Order Fulfillment') junction = m.add(ArchiType.Junction, 'Decision Point') # Build hierarchy m.add_child(process.uuid, func.uuid) # Style elements process.set_fill_color('#ffeb3b') process.set_transparency(0.9) # Set junction semantics junction.set_junction_type('and')
- assign_viewpoint(viewpoint_id: str) None[source]ο
Assign a standard ArchiMate 3.x viewpoint slug to this element.
- Parameters:
viewpoint_id (str) β canonical viewpoint slug (e.g. βstakeholderβ)
- Raises:
ValueError β if viewpoint_id is not a recognised slug
- delete() None[source]ο
Delete the current element from the parent model Note: it does not delete the instance itself but it remove the data from the model
It also deletes all relationships that have this element as source or target and it deletes all visual nodes referring to this element (and conns) from views
Children are orphaned rather than cascaded (Phase 2 behavior).
- get_fill_color() str | None[source]ο
Get the fill color of this element.
- Returns:
Hex color (#rrggbb) or None if not set (use default)
- Return type:
Optional[str]
- get_junction_type() str | None[source]ο
Get the junction type for a Junction element.
- Returns:
Junction type (βandβ, βorβ, βxorβ) or None if not set
- Return type:
Optional[str]
- get_line_color() str | None[source]ο
Get the line/border color of this element.
- Returns:
Hex color (#rrggbb) or None if not set (use default)
- Return type:
Optional[str]
- get_line_width() float | None[source]ο
Get the line/border width of this element.
- Returns:
Width in pixels or None if not set (use default)
- Return type:
Optional[float]
- get_transparency() float | None[source]ο
Get the transparency/opacity of this element.
- Returns:
Opacity 0.0-1.0 or None if not set (use default)
- Return type:
Optional[float]
- get_visual_style() dict[str, Any][source]ο
Get all visual style properties as a dictionary.
- Returns:
Dictionary with fillColor, lineColor, lineWidth, transparency (only set values)
- Return type:
dict[str, Any]
- in_rels(rel_type=None)[source]ο
Method to get a list of the inbound relationships
- Parameters:
rel_type (str) β relationship type to filter
- Returns:
[Relationship]
- Return type:
list
- merge(elem: Element, merge_props: bool = False) None[source]ο
Method to merge another element of the same type with this element
- Parameters:
elem (Element) β the element to merge
merge_props (bool) β flag to merge or not the properties
- out_rels(rel_type=None)[source]ο
Method to get a list of the outbound relationships
- Parameters:
rel_type (str) β relationship type to filter
- Returns:
[Relationship]
- Return type:
list
- property parent_uuid: str | Noneο
Get the parent element UUID (for hierarchical grouping).
- Returns:
Parent element UUID or None if this is a root element
- Return type:
Optional[str]
- property profile_idο
Gets the profile ID if the current profile is valid and exists in the associated modelβs profiles. Returns None if either there is no current profile or it does not exist in the modelβs profiles.
- Returns:
The ID of the current profile if it exists, otherwise None.
- Return type:
int or None
- property profile_nameο
Retrieve the name of the profile associated with the current object. This is done by checking if the profile attribute exists and matches a profile in the modelβs profiles. If no matching profile is found or the profile attribute is None, the method returns None.
- Returns:
The name of the associated profile if it exists, otherwise None.
- Return type:
str or None
- prop(key, value=None)[source]ο
Method to get or set an elementβs property
- Parameters:
key (str) β Property key
value (str) β Property value
- Returns:
an existing element property value str if βvalueβ argument is None
- Return type:
str
- property propsο
Get all element properties as a dictionary
- Returns:
properties
- Return type:
dict
- rels(rel_type=None)[source]ο
Method to get a list of the inbound and outbound relationships
- Parameters:
rel_type (str) β relationship type to filter
- Returns:
[Relationship]
- Return type:
list
- remove_viewpoint(viewpoint_id: str) None[source]ο
Remove a viewpoint slug assignment; silently ignores unknown slugs.
- Parameters:
viewpoint_id (str) β canonical viewpoint slug to remove
- set_fill_color(color: str | None) None[source]ο
Set the fill color of this element.
- Parameters:
color (Optional[str]) β Hex color (#RRGGBB), named color, or None to use default
- Raises:
ValueError β If color format is invalid
- set_junction_type(junction_type: str | None) None[source]ο
Set the junction type for a Junction element.
- Parameters:
junction_type (Optional[str]) β Junction type (βandβ, βorβ, βxorβ) or None
- Raises:
ValueError β If junction_type is not valid
- set_line_color(color: str | None) None[source]ο
Set the line/border color of this element.
- Parameters:
color (Optional[str]) β Hex color (#RRGGBB), named color, or None to use default
- Raises:
ValueError β If color format is invalid
- set_line_width(width: float | None) None[source]ο
Set the line/border width of this element.
- Parameters:
width (Optional[float]) β Width in pixels (β₯ 0), or None to use default
- Raises:
ValueError β If width is negative
TypeError β If width is not numeric
- set_profile(profile_name)[source]ο
Sets the current profile for an instance. If the specified profile name already exists in the model, it sets the profile to the matching profile. Otherwise, a new profile is created, added to the model, and set as the current profile.
- Parameters:
profile_name (str) β The name of the profile to set. If it exists in the
model
not (it will be used directly. If)
name (a new profile with this)
used. (will be created and)
- Raises:
No exceptions are explicitly raised in this method. β
- set_transparency(alpha: float | None) None[source]ο
Set the transparency/opacity of this element.
- Parameters:
alpha (Optional[float]) β Opacity 0.0 (transparent) to 1.0 (opaque), or None to use default
- Raises:
ValueError β If alpha is out of range
TypeError β If alpha is not numeric
- set_visual_style(fill_color: str | None = None, line_color: str | None = None, line_width: float | None = None, transparency: float | None = None) None[source]ο
Set multiple visual style properties at once.
- Parameters:
fill_color β Fill color (hex or named)
line_color β Line color (hex or named)
line_width β Line width in pixels (β₯ 0)
transparency β Opacity 0.0-1.0
- Raises:
ValueError β If any property is invalid
- property type: str | Noneο
Get the Archimate concept type of this element
- Returns:
type str
- Return type:
str
- property uuid: strο
Get the identifier of this element
- Returns:
Identifier str
- Return type:
str
- property viewpoints: list[str]ο
Return the list of assigned viewpoint slugs.
- Returns:
list of canonical viewpoint slug strings
- Return type:
list[str]
- class pyArchimate.pyArchimate.Model(name=None, uuid=None, desc=None)[source]ο
Bases:
objectClass to create ArchiMate v3.x compliant models with full hierarchy and styling support.
Supports element grouping (parent-child relationships), visual styling (colors, transparency), junction types (AND/OR/XOR), and advanced hierarchy queries with round-trip fidelity.
Element Hierarchy (P3): - Use add_child(parent_uuid, child_uuid) to create parent-child relationships - Supports unlimited nesting (default max depth 5, configurable) - Automatic cycle detection prevents invalid hierarchies - When parent is deleted, children are orphaned (not deleted) - Query methods: get_parent(), get_children(), get_ancestors(), get_descendants()
Visual Styling (P3): - Elements support custom fill colors, line colors, line width, and transparency - Colors can be hex (#RRGGBB) or named colors; all normalized to hex for export - All visual properties preserved during XML round-trip export/import cycles - Use element.set_fill_color(), set_line_color(), etc. for styling
Advanced Queries (P3): - get_siblings(elem_uuid): Find all elements with same parent - find_by_hierarchy_path(path): Query by path like β/Parent/Childβ with wildcard support - Path examples: β/Rootβ, β/Parent/Child/β, β/A//B/Leafβ - Performance: cycle detection <1ms, queries <10ms on 1000+ element models
Junction Semantics (P3): - Junction elements support type semantics: βandβ, βorβ, βxorβ - Types are validated and preserved across XML export/import cycles - Use element.set_junction_type(type_str) to set semantics
Note: Perspectives are not handled in the current version of this library
This class defines methods and properties to create Elements, Relationships, Diagrams (Views) with Nodes and Connections with visual layout.
It also reads, writes or merges XML files using the ArchiMate Open Exchange File format.
- Parameters:
name (str) β Model name
uuid (str) β Model Identifier
desc (str) β Model documentation
- Returns:
Model object
- Return type:
Example:
from pyArchimate import ArchiType from pyArchimate.model import Model m = Model('Enterprise Architecture') # Create elements process = m.add(ArchiType.BusinessProcess, 'Order Management') func1 = m.add(ArchiType.BusinessFunction, 'Order Entry') func2 = m.add(ArchiType.BusinessFunction, 'Order Fulfillment') # Build hierarchy m.add_child(process.uuid, func1.uuid) m.add_child(process.uuid, func2.uuid) # Apply visual styling process.set_fill_color('#e8f4f8') func1.set_fill_color('#b3e5fc') # Query hierarchy children = m.get_children(process.uuid) siblings = m.get_siblings(func1.uuid) ancestors = m.get_ancestors(func1.uuid) # Find by path results = m.find_by_hierarchy_path('/Order Management/Order Entry') # Export (preserves all hierarchy and visual properties) m.write('model.archimate')
- add(concept_type=None, name=None, uuid=None, desc=None, folder=None, profile=None)[source]ο
Method to add a new Element in this model
- Parameters:
concept_type (str) β Archimate Element type
name (str) β Elementβs name
uuid (str) β Elementβs Identifier
desc (str) β Elementβs documentation
folder (str) β Elementβs organization path
profile β str Archimate Element profile name
- Returns:
Element or View class object
- Return type:
- add_child(parent_uuid: str, child_uuid: str) None[source]ο
Add a parent-child relationship between two elements.
- Parameters:
parent_uuid β UUID of parent element
child_uuid β UUID of child element
- Raises:
KeyError β If parent or child UUID not in model
ValueError β If child already has parent, cycle would be created, or max depth exceeded
- add_profile(name=None, uuid=None, concept=None)[source]ο
Adds a new profile to the profiles dictionary and associates it with this model.
This method creates an instance of the Profile class using the provided arguments and stores it in the internal dictionary, keyed by its unique identifier (UUID). If no UUID or name is provided, the default values will be used. This method also returns the newly created Profile instance.
- Parameters:
name (str, optional) β The name of the profile being added.
uuid (str, optional) β The unique identifier for the profile.
concept (Any, optional) β A concept object associated with the profile.
- Returns:
The newly created Profile object.
- Return type:
- add_relationship(rel_type: str = '', source: Any = None, target: Any = None, uuid: str | None = None, name: str | None = None, access_type: str | None = None, influence_strength: str | None = None, desc: str | None = None, is_directed: bool | None = None, profile: str | None = None) Relationship[source]ο
Method to add a new Relationship between two Element objects
- Parameters:
rel_type (str) β Archimate relationship type
source ([str|Element]) β Source Element by Identifier or by object
target ([str|Element]) β Target Element by Identifier or by object
uuid (str) β Relationship Identifier
name (str) β Relationship name
access_type (str) β if type is Access, type of Access (Read, Writeβ¦)
influence_strength (str) β if type is Influence, strength of the influence (1, 10, +,++β¦)
desc (str) β Relationship documentation
is_directed (bool) β if type is Association, flag to indicated if the relationhsip is directed
- Returns:
Relationship class object
- Return type:
- check_connection(c: Any) bool[source]ο
Method to check the validity of a single connection
- Parameters:
c (Connection) β Connection object
- Returns:
True if the connection is valid
- Return type:
boolean
- check_invalid_nodes()[source]ο
Check and get the list of nodes that are orphans (without known related Element) :return: list of orphan nodes :rtype: list(Node)
- property connsο
Get the list of all connections from the model :return: Connections :rtype: list(Connection)
- default_theme(theme='archi')[source]ο
Set the default color theme for the model :param theme: default theme reference :return: nothing
- property elementsο
Get the list of Elements in this model
- Returns:
[Element]
- Return type:
list
- embed_props(remove_props=False)[source]ο
Method to embed properties of each view, element, relationship into their description attribute as a stringified json tag
Some tools like Aris are not configured to managed conceptβs properties, so we embed the properties before exporting the model there
- expand_props(clean_doc=True)[source]ο
Method to expand modelβs concepts desc attribute properties tag into conceptβs properties
- filter_elements(fct)[source]ο
Method to filter Elements
- Parameters:
fct (function) β callback (lambda) function with filtering criteria
- Returns:
list of Elements
- Return type:
list
- filter_relationships(fct)[source]ο
Method to find relationhips by providing a callback function with criteria
- Parameters:
fct (function) β callback function
- Returns:
list(Relationships)
- Return type:
list
- filter_views(fct)[source]ο
Method to find views by providing a callback function with criteria
- Parameters:
fct (function) β callback function
- Returns:
list(Views)
- Return type:
list
- find_by_hierarchy_path(path: str) list[Element][source]ο
Find elements by hierarchy path (e.g., β/parent/child/elementβ).
Supports wildcard matching at end:
'/parent/child/*'matches all children of child.- Parameters:
path β Hierarchy path string starting with β/β, levels separated by β/β
- Returns:
List of matching Elements
- find_elements(name=None, elem_type=None)[source]ο
Method to find elements by name or type or both
- Parameters:
name (str) β name criteria
elem_type (str) β elem_type criteria
- Returns:
list(Element)
- Return type:
list
- find_relationships(rel_type, elem, direction='both')[source]ο
Find all relationships of a list of elements
- Parameters:
rel_type (str) β type of relationship tp search for
elem (Element) β an element with relationships
direction (str) β data direction [βin_relsβ, βout_relsβ, βbothβ | None]
- Returns:
[Relationship]
- Return type:
list
- find_views(name)[source]ο
Method to find views by name
- Parameters:
name (str)
- Returns:
list(View)
- Return type:
list
- get_ancestors(elem_uuid: str) list[Element][source]ο
Get all ancestors of an element (parent, grandparent, β¦, root).
- Parameters:
elem_uuid β Element UUID
- Returns:
List of ancestor Elements [parent, grandparent, β¦, root] (excludes the element itself)
- get_children(elem_uuid: str) list[Element][source]ο
Get all direct children of a given element.
- Parameters:
elem_uuid β Element UUID
- Returns:
List of child Elements (empty if no children)
- get_depth(elem_uuid: str) int[source]ο
Get the nesting depth of an element (0 = root).
- Parameters:
elem_uuid β Element UUID
- Returns:
Depth level
- get_descendants(elem_uuid: str) list[Element][source]ο
Get all descendants of an element in breadth-first order.
- Parameters:
elem_uuid β Element UUID
- Returns:
List of descendant Elements (excludes the element itself)
- get_elements_by_viewpoint(viewpoint_id: str) list[Any][source]ο
Return elements assigned to the given viewpoint slug.
- Parameters:
viewpoint_id (str) β canonical viewpoint slug
- Returns:
list of Element objects
- Return type:
list[Element]
- Raises:
ValueError β if viewpoint_id is not a recognised slug
- get_leaf_elements() list[Element][source]ο
Get all leaf elements (elements with no children).
- Returns:
List of leaf Elements
- get_or_create_element(elem_type: str, elem: str, create_elem: bool = False) Any | None[source]ο
Method to get an Element by name or create one if not existing
- Parameters:
elem_type (str) β Archimate type of the element
elem (str) β name of the Element
create_elem (bool) β if True, create a new Element if not found
- Returns:
Element object
- Return type:
- get_or_create_relationship(rel_type: str, name: str | None, source: Any, target: Any, create_rel: bool = False, access_type: str | None = None, influence_strength: str | None = None, desc: str | None = None, is_directed: bool | None = None) Any | None[source]ο
Method to get a Relationship by source/target/type and/or by name or create one if not found
- Parameters:
rel_type (str) β Archimate type of the relationship
name (str) β name of the relationships
source ([str|Element]) β Source Element or Identifier of the Element
target ([str|Element]) β Target Element or Identifier of the Element
create_rel (bool) β if True, create a new relationship if not found
access_type (str) β if type is Access, and creat_rel is true, set the access type
influence_strength (str) β if type is Influence, and creat_rel is true, set the strenght
desc (str) β relationship description
is_directed (bool) β if type is Association, and creat_rel is true, set the direction flag
- Returns:
Relationship object
- Return type:
- get_or_create_view(view, create_view=False)[source]ο
Method to get or create a view by name
- Parameters:
view (str) β View name
create_view (bool) β if True, create a view if not found
- Returns:
View object
- Return type:
- get_parent(elem_uuid: str) Element | None[source]ο
Get the parent element of a given element.
- Parameters:
elem_uuid β Element UUID
- Returns:
Parent Element or None if root
- get_root_elements() list[Element][source]ο
Get all root elements (elements with no parent).
- Returns:
List of root Elements
- get_siblings(elem_uuid: str) list[Element][source]ο
Get all sibling elements (elements with same parent).
- Parameters:
elem_uuid β UUID of element to find siblings for
- Returns:
List of sibling Elements (excludes elem_uuid itself)
- Raises:
KeyError β If element UUID not in model
- get_viewpoints()[source]ο
Return all 13 standard ArchiMate 3.x viewpoints.
- Returns:
list of Viewpoint objects
- Return type:
list[Viewpoint]
- get_views_by_viewpoint(viewpoint_id: str) list[Any][source]ο
Return views whose primary viewpoint matches the given slug.
- Parameters:
viewpoint_id (str) β canonical viewpoint slug
- Returns:
list of View objects
- Return type:
list[View]
- Raises:
ValueError β if viewpoint_id is not a recognised slug
- merge(file_path)[source]ο
Method to merge an Archimate file into this model
- Parameters:
file_path (str)
- property nodesο
Get the list of all nodes from the model :return: Nodes :rtype: list(Node)
- property profiles: list[Profile]ο
Property to access the profiles.
This property provides access to the _profiles attribute of the class instance. It allows getting the internal profiles data which is encapsulated within the class.
- Returns:
The value of the _profiles attribute.
- prop(key, value=None)[source]ο
Method to get or set an elementβs property
- Parameters:
key (str) β Property key
value (str) β Property value
- Returns:
an existing element property value if βvalueβ argument is None
- Return type:
str
- property propsο
Dictionary of model properties (read only)
- Returns:
properties dictionary
- Return type:
dict
- read(file_path, *args, **kwargs)[source]ο
Method to read an Archimate file
The method detects automatically and reads the following formats: - Open Group Open Exchange File (.xml) - plain XML text - Archi Tool (.archimate) - ZIP archive containing model.xml
ZIP archives (.archimate) are transparently extracted before parsing. File format is detected using magic bytes (PK signature) for ZIP, falling back to plain text reading for .xml files.
- Parameters:
file_path (str) β Path to the file to read
- Raises:
SystemExit β If file cannot be read or is invalid
- property relationshipsο
Get the list of Relationships in this Model
- Returns:
[Relationship]
- Return type:
list
- remove_child(parent_uuid: str, child_uuid: str) None[source]ο
Remove a parent-child relationship (orphan the child).
- Parameters:
parent_uuid β UUID of parent element
child_uuid β UUID of child element
- Raises:
KeyError β If parent or child UUID not in model
ValueError β If child is not actually a child of parent
- property typeο
Get the type of Model :return: type :rtype: str
- property uuidο
Get the Model Identifier
- Returns:
Identifer
- Return type:
str
- property viewsο
Get the list of views in this model
- Returns:
[View]
- Return type:
list
- write(file_path=None, writer=None)[source]ο
Method to write the file_path to an Archimate file
Auto-selects writer based on file extension if not explicitly specified: - .archimate files use Archi native format (archiWriter) - .xml files use OpenGroup Exchange format (archimateWriter) - Default to OpenGroup Exchange format
- Parameters:
file_path (str) β Output file path
writer (Writers|str|callable|None) β writer selection (enum value, registry key, or callable) used to format the output. If None, auto-detects based on file_path extension.
- Returns:
XML data structure as string
- Return type:
str
- class pyArchimate.pyArchimate.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.pyArchimate.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.pyArchimate.Position[source]ο
Bases:
objectPositional relationship between two nodes (distance, angle, orientation).
- property dist: float | Noneο
Euclidean distance between nodes.
- class pyArchimate.pyArchimate.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.pyArchimate.RGBA(r=0, g=0, b=0, a=100)[source]ο
Bases:
objectManage RGB/hex color and alpha (opacity) channels.
- Parameters:
r β red channel 0-255
g β green channel 0-255
b β blue channel 0-255
a β alpha channel 0-100
- property colorο
Return #RRGGBB hex string.
- class pyArchimate.pyArchimate.Readers(*values)[source]ο
Bases:
EnumEnumeration for Readers drivers
Note: ARIS format (aris = 1) is deprecated and will be removed in a future version. Use archi (Archi native) or archimate (OpenGroup Exchange format) instead.
- archi = 0ο
- archimate = 2ο
- aris = 1ο
- class pyArchimate.pyArchimate.Relationship(rel_type='', source=None, target=None, uuid=None, name=None, access_type=None, influence_strength=None, desc=None, is_directed=None, profile=None, parent=None)[source]ο
Bases:
objectClass to manage the relationship between two elements of the model
- Parameters:
rel_type (str) β Archimate relationship type
source ([str|Element]) β element source either an element identifier, or an element object
target ([str|Element]) β element target either an element identifier, or an element object
uuid (str) β identifier of the relationship
name (str) β optional name of the relationship
access_type (str) β optional parameter for access relationship (βReadβ, βReadWriteβ, βWriteβ, βAccessβ)
influence_strength (str) β optional influence strength for Influence relationships. Canonical field preserved across export/import cycles. Values: numeric (0-10), β+β, β++β, β-β, βββ. Supports round-trip fidelity with both .archimate and OpenGroup formats. On import, automatically maps legacy βmodifierβ field to influenceStrength.
desc (str) β description/documentation text of the relationship. Stored as <documentation> element in .archimate format. Preserved during round-trip export/import cycles with support for Unicode characters, special XML characters, and arbitrary length text.
is_directed (bool) β boolean flag for association relationship
profile (str) β relationship profile identifier
parent (Model) β parent Model object
- property access_typeο
Get the access type of an Access relationship
- Returns:
type
- Return type:
str
- delete()[source]ο
Method to delete this relationship from the model structure Also take care to remove visual conns from the views
- property influence_strengthο
Get the influence strength of an Influence relationship
- Returns:
influence strength
- Return type:
str
- property is_directedο
Get the direction of an Association relationship
- Returns:
direction flag
- Return type:
boolean
- property profile_idο
Gets the profile ID if the current profile is valid and exists in the associated modelβs profiles. Returns None if either there is no current profile or it does not exist in the modelβs profiles.
- Returns:
The ID of the current profile if it exists, otherwise None.
- Return type:
int or None
- property profile_nameο
Retrieve the name of the profile associated with the current object. This is done by checking if the profile attribute exists and matches a profile in the modelβs profiles. If no matching profile is found or the profile attribute is None, the method returns None.
- Returns:
The name of the associated profile if it exists, otherwise None.
- Return type:
str or None
- prop(key, value=None)[source]ο
Method to set a property given by its key if a value is provided or to return of value of a property if the value is None
- Parameters:
key (str)
value (str)
- Returns:
value of the property defined by the key or None
- Return type:
str
- property propsο
Return the properties of this relationship
- Returns:
properties
- Return type:
dict
- set_profile(profile_name)[source]ο
Sets or updates the profile for the current instance based on the provided profile name. If the profile name exists in the modelβs profile collection, it is set as the current profile. Otherwise, a new profile is created and added to the model, and its unique identifier is set for the current profile.
- Parameters:
profile_name (str) β The name of the profile to set. If it does not exist, a new profile is created with this name.
- Raises:
ValueError β If the profile name is invalid or cannot be processed.
- property typeο
Get the Archimate type of the relationship
- Returns:
Archimate type
- Return type:
str
- property uuidο
Get this relationship identifier
- Returns:
Identifier
- Return type:
str
- class pyArchimate.pyArchimate.TextAlignment(*values)[source]ο
Bases:
str,EnumEnumeration for text horizontal position
- Center = '1'ο
- Left = '0'ο
- Right = '2'ο
- class pyArchimate.pyArchimate.TextPosition(*values)[source]ο
Bases:
str,EnumEnumaration for Text vertical position
- Bottom = '2'ο
- Middle = '1'ο
- Top = '0'ο
- class pyArchimate.pyArchimate.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.
- class pyArchimate.pyArchimate.Writers(*values)[source]ο
Bases:
EnumEnumeration for Writers drivers
- archi = 0ο
- archimate = 2ο
- csv = 1ο
- pyArchimate.pyArchimate.check_invalid_conn(model)[source]ο
Delegate invalid relationship checks to the model implementation.
- pyArchimate.pyArchimate.check_invalid_nodes(model)[source]ο
Delegate orphan node checks to the model implementation.
- pyArchimate.pyArchimate.check_valid_relationship(rel_type, source_type, target_type, raise_flg=False)[source]ο
Check if a relationship is used according to Archimate language or raise an exception
- Parameters:
rel_type (str) β relationship type
source_type (str) β source concept type
target_type (str) β target concept type
raise_flg β Throw an exception instead of logging an error
- pyArchimate.pyArchimate.default_color(elem_type: str, theme: Any = 'archi') str[source]ο
Get the default color of a Node, according to its type
- Parameters:
elem_type (str) β archimate element type
theme (str) β βarchiβ or βarisβ color theme - default = βarchiβ
- Returns:
#Hex color str
- pyArchimate.pyArchimate.embed_props(model, remove_props=False)[source]ο
Delegate property embedding to the model implementation.
- pyArchimate.pyArchimate.expand_props(model, clean_doc=True)[source]ο
Delegate property expansion to the model implementation.
- pyArchimate.pyArchimate.get_default_rel_type(source_type, target_type)[source]ο
Return the default valid relationship type between two element types.
- pyArchimate.pyArchimate.get_or_create_connection(owner, *args, **kwargs)[source]ο
Delegate connection creation to View helper methods.
- pyArchimate.pyArchimate.get_or_create_node(owner, *args, **kwargs)[source]ο
Delegate node creation to Model/View helper methods.
- pyArchimate.pyArchimate.log_set_level(lvl)[source]ο
Change the logging level for all handlers at once :param lvl: logging level :type lvl: logging.LEVEL enumeration
- pyArchimate.pyArchimate.log_to_file(log_file)[source]ο
Add a log handler to save log to file :param log_file: path to the log file :type log_file: str
- pyArchimate.pyArchimate.log_to_stderr()[source]ο
Add a logging handler to the standard error output