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: object

Class 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:

Element

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_folder()[source]

Method to remove this element from the given folder path

remove_prop(key)[source]

Method to remove an element property

Parameters:

key (str)

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

reset_profile() None[source]

Clear the profile assignment.

reset_visual_style() None[source]

Reset all custom visual styles to defaults.

Returns:

None

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]