Elementο
An Element represents an Archimate concept (business actor, application
component, technology node, etc.). Every element belongs to exactly one
Model.
Module contentsο
Element module - extracted from the legacy monolith.
- class pyArchimate.element.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]