pyArchimate Library
pyArchimate is a Python library to manage Archimate based models

Module contents
A library to create and manage Archimate models.
Author: Xavier Mayeur Date: Aug 2022 Version 0.1
- class pyArchimate.AccessType[source]
Bases:
object
Enumeration of Access Relationship types
- Access = 'Access'
- Read = 'Read'
- ReadWrite = 'ReadWrite'
- Write = 'Write'
- class pyArchimate.ArchiType[source]
Bases:
object
Enumeration of Archimate Element & Relationships types
- Access = 'Access'
- Aggregation = 'Aggregation'
- AndJunction = 'AndJunction'
- ApplicationCollaboration = 'ApplicationCollaboration'
- ApplicationComponent = 'ApplicationComponent'
- ApplicationEvent = 'ApplicationEvent'
- ApplicationFunction = 'ApplicationFunction'
- 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'
- class pyArchimate.Connection(ref=None, source=None, target=None, uuid=None, parent=None)[source]
Bases:
object
Class to manage visual connections between Nodes
- Parameters:
ref ([str | Relationship]) – Reference to the parent Relationship concept
source ([str | Node]) – Source Node or node uuid of the connection
target ([ | Node) – Target Node or node uuid of the connection
uuid (str) – uuid of the connection (read-only excepted when reading an XML file to set the identifier)
parent (View) – Parent’s view
- Raises:
ArchimateConceptTypeError – Exception raised if invalid Archimate object type given
ValueError – Exception raise if a reference is not found in the model object dictionaries
- Returns:
Connection object
- Return type:
Conenction
- property access_type
- add_bendpoint(*bendpoints: Point)[source]
Method to add one or multiple bendpoints x-y Point to shape the connection
- property concept
Get the Relationship object referred by ref
- Returns:
Relationship object
- Return type:
- del_bendpoint(index)[source]
Method to delete an endpoint by index position
- Parameters:
index (int)
- get_bendpoint(index)[source]
Get the benpoint at the given index position (O is the first bendpoint at the source object)
- Parameters:
index (int)
- Returns:
Point object
- Return type:
Point|None
- property influence_strength
- property is_directed
- l_shape(direction=0, weight_x=0.5, weight_y=0.5)[source]
Format the connection using a L-shape (one bendpoint, orthogonal shape)
- Parameters:
direction (int) – 0 start with a horizontal segment, or 1 for a vertical one
weight_x (float) – 0…1 position of the bendpoint on the x-axis
weight_y (float) – 0…1 position of the bendpoint on the y-axis
- property name
Get the name of the parent Relationship
- Returns:
name
- Return type:
str
- property ref
Get the parent Relationship reference
- Returns:
Identifier
- Return type:
str
- s_shape(direction=0, weight_x=0.5, weight_y=0.5, weight2=0.5)[source]
Format the connection using a S-shape (two bendpoints, orthogonal shape)
- Parameters:
direction (int) – 0 starts with a horizontal segment, or 1 for a vertical one
weight_x (float) – 0…1 position of the first bendpoint on the x-axis
weight_y (float) – 0…1 position of the first bendpoint on the y-axis
weight2 (float) – 0…1 position of the second bendpoint
- set_bendpoint(bp: Point, index)[source]
Method to set an existing bendpoint to another xy-Point
- Parameters:
bp (Point)
index (int)
- property source
Get the Node object at the source of the relationship
- Returns:
Node object
- Return type:
- property type
Get the type of the parent relationship
- Returns:
type
- Return type:
str
- property uuid
Get Connection identifier
- Returns:
Identifier
- Return type:
str
- class pyArchimate.Element(elem_type=None, name=None, uuid=None, desc=None, folder=None, parent=None, profile=None)[source]
Bases:
object
Class to manage Element artifacts
- 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
- Raises:
ArchimateConceptTypeError – Exception raised on elem_type or parent tyme error
- Returns:
Element object
- Return type:
- 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
- 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=None, merge_props=False)[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 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
- 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. –
- property type
Get the Archimate concept type of this element
- Returns:
type str
- Return type:
str
- property uuid
Get the identifier of this element
- Returns:
Identifier str
- Return type:
str
- class pyArchimate.Font(name: str = 'Segoe UI', size: int = 9, color=<pyArchimate.RGBA object>)[source]
Bases:
object
Class to manage font attributes
- Parameters:
name – Font name
size – Font size
color – RGBA-class font color
- property color
Get #Hex font color
- Returns:
#Hex color string
- class pyArchimate.Model(name=None, uuid=None, desc=None)[source]
Bases:
object
Class to create a Archimate compliant models
Note: Perspectives are not handled in the current version of this library
This class define the 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:
- 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_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='', source=None, target=None, uuid=None, name=None, access_type=None, influence_strength=None, desc=None, is_directed=None, profile=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)[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_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_or_create_element(elem_type: str, elem: str, create_elem=False)[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, source, target, create_rel=False, access_type=None, influence_strength=None, desc=None, is_directed=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:
- 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
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 automagically and read the following formats: - ARIS AML - Open Group Open Exchange File - Archi Tool
- Parameters:
file_path (str)
- property relationships
Get the list of Relationships in this Model
- Returns:
[Relationship]
- Return type:
list
- 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
- class pyArchimate.Node(ref=None, x=0, y=0, w=120, h=55, uuid=None, node_type='Element', label=None, parent=None)[source]
Bases:
object
Class to manage Nodes A Node is a visual object representing an Element concept in a View
- Parameters:
ref ([str | Element]) – Identifier of the related Element or an Element object
x (int) – top-left absolute x coordinate of the node in the view
y (int) – top-left absolute y coordinate of the node in the view
w (int) – width of the node
h (int) – height of the node
uuid (str) – Node identifier
node_type (str) – Node type [‘Element’ | ‘Label’ | ‘Container’]
label (str) – Label text if node type is not ‘Element’
parent ([View | Node]) – Parent object, a View or an embedding Node object
- add(ref=None, x=0, y=0, w=120, h=55, uuid=None, node_type='Element', label=None, nested_rel_type=None)[source]
Method to create a node embedded in this node
- Parameters:
ref ([str | Element]) – Identifier of the related Element or an Element object
x (int) – top-left absolute x coordinate of the node in the view
y (int) – top-left absolute y coordinate of the node in the view
w (int) – width of the node
h (int) – height of the node
uuid (str) – Node identifier
node_type (str) – Node type [‘Element’ | ‘Label’ | ‘Container’]
label (str) – Label text if node type is not ‘Element’
nested_rel_type (str) – type of nested relationship between the new node and its parent embedding one
- Returns:
Node object
- Return type:
- conns(rel_type=None)[source]
List all connections of the given type connected to the node
- Parameters:
rel_type (str) – an Archimate relationship type
- Returns:
[Connection]
- Return type:
list
- property cx
Get the node centroid x coordinate
- Returns:
float cx
- property cy
Get the node centroid y coordinate
- Returns:
cy
- Return type:
float
- delete(recurse=True, delete_from_model=False)[source]
Delete node and related connections
- Parameters:
recurse (bool) – Recurse into embedded nodes & delete them as well
delete_from_model (bool) – Also delete the related Element (always non-recursive)
- property desc: str
Get the Node description from the parent Element :return: description :rtype: str
- distribute_connections()[source]
Method to arrange and distribute equally all visual conns along each edge of this node
- property fill_color
Get the fill color
- Returns:
#Hex color
- Return type:
str
- get_obj_pos(other_node) Position [source]
Get positional parameter of this node with respect to another one using centroid coordinates
- 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]
Method to get an existing node or to create a new one in this node
- Parameters:
elem ([str | Element]) – Element object or name of the related Element concept
elem_type (str) – Archimate Element concept type if create_elem flag is set
x (int) – top-left x position of the node
y (int) – top-left y position of the node
w (int) – node’s width
h (int) – node’s height
create_elem (bool) – flag to create a new element with name & type if not found
create_node (bool) – flag to create a new node if not found
nested_rel_type (Relationship) – relationship to use for nested node, else use a default value
- Returns:
Node object or None
- Return type:
[Node | None]
- get_point_pos(point: Point) Position [source]
Get positional parameter of this node center (x,y) points with respect to a point
- property h
Get node height
- Returns:
h
- Return type:
int
- in_conns(rel_type=None)[source]
List all connections of the given type where the node is target to (inbound conns)
- Parameters:
rel_type (str) – an Archimate relationships type
- Returns:
[Connection]
- Return type:
list
- is_inside(x: int = 0, y: int = 0, point: Point = None) bool [source]
Check whether the point given by the x,y coordinate is inside this node boundary
- Parameters:
x (int)
y (int)
point (Point) – a point object, overwriting x, y parameters if given
- Returns:
True of the point is inside the node boundary
- Return type:
bool
- property model
Get root Model :return: Model object :rtype: Model
- move(new_parent)[source]
Move a Node to another Node on the same view or to its root view :param new_parent: new parent object :rtype new_parent: Node | View
- property name: str
Get the name of the node’s Element concept
- Returns:
str : parent Element name
- Return type:
str
- property nodes
- out_conns(rel_type=None)[source]
List all connections of the given type where the node is source to (outbound conns)
- Parameters:
rel_type (str) – an Archimate relationships type
- Returns:
[Connection]
- Return type:
list
- property ref: str
Get the identifier of the parent Element concept
- Returns:
Identifier str
- 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 the node, to fit all embedded nodes, recursively
- Parameters:
max_in_row (int) – Maximum number of embedded nodes per row
keep_kids_size (bool) – Keep embedded node original size or set to default passed w,h parameters
w (int) – Default node width
h (int) – Default node height
gap_x (int) – Horizontal gap between two nodes
gap_y (int) – Vertical gap size between two nodes
justify (str) – justify node to ‘left’, ‘right’, or ‘center’
recurse (bool) – recurse & resize embedded nodes
sort (str) – one of ‘asc’ | ‘desc’ | ‘none’
- property rx
Get the relative x coordinate wrt to embedding node
- Returns:
rx
- Return type:
int
- property ry
Get the node relative y coordinate wrt to embedding Node
- Returns:
y
- Return type:
int
- property type
Get the type of the node’s parent Element concept
- Returns:
type
- Return type:
str
- property uuid: str
Get the identifier of the node.
- Returns:
Identifier string
- Return type:
str
- property w
Get the node width
- Returns:
w
- Return type:
int
- property x
get the x-coordinate (top-left corner) of the node
- Returns:
int x
- Return type:
int
- property y
Get the top-left node y coordinate
- Returns:
y
- Return type:
int
- class pyArchimate.Point(x=0, y=0)[source]
Bases:
object
A simple class to manage x, y coordinates of a point x: x-coordinate y: y-coordinate
- property x
x-coordinate getter :return: x-coordinate
- property y
y-coordinate getter :return: y-coordinate
- class pyArchimate.Position[source]
Bases:
object
- A class to manage positional parameters of a node with respect to to another one
dx: horizontal distance between the two nodes centres dy: vertical distance between the two node centres gap_x: horizontal distance between the adjacent vertical edges of the two nodes gap_y: vertical distance between the adjacent horizontal edges of the two nodes angle the angle of the imaginary line connecting the two node’s centers orientation: one of the letter L(eft), R(ight), T(op), B(ottom) giving the position of the other node with respect to this node. An exclamation character ‘!’ means that the adjacent edges are overlapping
- property dist
Calculate the distance between the two nodes :return: absolute value of the distance :rtype: float
- class pyArchimate.Profile(name=None, uuid=None, concept=None, model=None)[source]
Bases:
object
- delete()[source]
Deletes the profile by removing all references to it from elements and relationships within the model and deleting it from the profile registry.
- Raises:
KeyError – If the profile is not found in the profiles registry.
- property uuid: str
Get the identifier of the node.
- Returns:
Identifier string
- Return type:
str
- class pyArchimate.RGBA(r=0, g=0, b=0, a=100)[source]
Bases:
object
Class to manage RGB/hex color and alpha (opacity) channels
- Parameters:
r – red channel color intensity 0-255
g – green channel color intensity 0-255
b – blue channel color intensity 0-255
a – alpha channel color intensity 0-100
- property color
Get #RGB hex string
- Returns:
str
- class pyArchimate.Readers(*values)[source]
Bases:
Enum
Enumaration for Readers drivers
- archi = 0
- archimate = 2
- aris = 1
- class 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:
object
Class 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 (1-10, ‘+’, ‘-‘)parameter for influence relationship
desc (str) – description of the relationship
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.TextAlignment[source]
Bases:
object
Enumeration for text horizontal position
- Center = '1'
- Left = '0'
- Right = '2'
- class pyArchimate.TextPosition[source]
Bases:
object
Enumaration for Text vertical position
- Bottom = '2'
- Middle = '1'
- Top = '0'
- class pyArchimate.View(name=None, uuid=None, desc=None, folder=None, parent=None)[source]
Bases:
object
Class to manage the views (diagrams) in an Archimate model
- Parameters:
name (str) – Name of the view
uuid (str) – Identifier of the view
desc (str) – Description of the view content
folder (str) – folder path (organization) to structure view hierarchy
parent (Model) – parent Model object reference
- Raises:
ArchimateConceptTypeError – Exception raised if an invalid parent object type is given
- Returns:
View object
- Return type:
- add(ref=None, x=0, y=0, w=120, h=55, uuid=None, node_type='Element', label=None) Node [source]
Method to add a node in this view
- Parameters:
ref ([str|Element]) – Identifier of the node’s Element concept
x (int) – top-left x position of the node in the view
y (int) – top-left y position
w (int) – node’s width
h (int) – node’s height
uuid (str) – node’s Identifier
node_type (str) – node’s category (Element, Label or Container)
label (str) – Label of a Label or Container type node
- Returns:
Node object
- Return type:
- add_connection(ref=None, source=None, target=None, uuid=None)[source]
Method to add a connection between two nodes in this view
- Parameters:
ref ([str|Relationship]) – Identifier of the connnection’s Relationship
source ([str|Node]) – Source node of the connection (its Identifier or the node object itself)
target ([str|Node]) – Target node of the connection
uuid (str) – Identifier of the connection
- Returns:
Connection object
- Return type:
- property conns
Get the list of connections objects defined in this view :return: list of connections :rtype: list(Connection)
- get_or_create_connection(rel=None, source=None, target=None, rel_type=None, name=None, create_conn=False) Connection [source]
Method to get or create a connection between two nodes in this view
If no Parent Relationship is given, a search is performed on existing relationships with same attributes (type, source, target and name if given)
- Parameters:
rel ([str|Relationship]) – Parent Relationship object referred by the connection or None if a new relationship is to be created
source ([str|Node]) – Source node of the connection
target ([str|Node]) – Target node of the connection
rel_type (str used when a new relationship is to be created) – Archimate relationship type to search the parent Relationship or
name (str) – Name of the new relationship
create_conn (bool) – flag to create a new connection if not found
- Returns:
Connection object
- Return type:
- get_or_create_node(elem=None, elem_type=None, x=0, y=0, w=120, h=55, create_elem=False, create_node=False)[source]
Method to get an existing node or to create a new one in this view
- Parameters:
elem ([str|Element]) – Element object or name of the related Element concept
elem_type (str) – Archimate Element concept type if create_elem flag is set
x (int) – top-left x position of the node
y (int) – top-left y position of the node
w (int) – node’s width
h (int) – node’s height
create_elem (bool) – flag to create a new element with name & type if not found
create_node (bool) – flag to create a new node if not found
- Returns:
Node object or None
- Return type:
Node|None
- property nodes
Get the list of nodes objects, defined in this view :return:list of nodes :rtype: list(Node)
- prop(key, value=None)[source]
Method to get or set a view’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
Get the dictionary of view properties (Read-only)
- Returns:
Properties dictionary
- Return type:
dict
- property type
Get the type of the view
- Returns:
type
- Return type:
str
- property uuid
Get the identifier of the connection
- Returns:
Identifier
- Return type:
str
- class pyArchimate.Writers(*values)[source]
Bases:
Enum
Enumeration for Writers drivers
- archi = 0
- archimate = 2
- csv = 1
- 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
# :raises ArchimateConceptTypeError: Exception raised on invalid object Archimate type # :raises ArchimateRelationshipError: Exception raised on invalid relationship between the source and target parent elements
- pyArchimate.default_color(elem_type, theme='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