Skip to content

Applying Capella filters🔗

With release v0.4.11 of py-capellambse you can apply filters headlessly. Since an instance of a ContextDiagram is not stored in the .aird file of your Capella model there is no way to apply filters via Capella/GUI. The filters implementation bridge the filter functionality of py-capellambse such that the labels are adjusted without needing diagram elements from within the .aird file.

Capella filters🔗

Currently the supported filters are:

Show ExchangeItems

from capellambse import MelodyModel
from capellambse_context_diagrams import filters

lost = model.by_uuid("a5642060-c9cc-4d49-af09-defaa3024bae")
diag = obj.context_diagram
assert filters.EX_ITEMS == "show.exchange.items.filter"
diag.filters.add(filters.EX_ITEMS)
diag.render("svgdiagram").save(pretty=True)
Context diagram of Lost SystemFunction with applied filter EX_ITEMS_FILTER

Show FunctionalExchanges and ExchangeItems

from capellambse import MelodyModel
from capellambse_context_diagrams import filters

lost = model.by_uuid("a5642060-c9cc-4d49-af09-defaa3024bae")
diag = obj.context_diagram
assert filters.FEX_EX_ITEMS == "show.functional.exchanges.exchange.items.filter"
filters.filters = {filters.FEX_EX_ITEMS}
diag.render("svgdiagram").save(pretty=True)
Context diagram of Lost SystemFunction with applied filter FEX_EX_ITEMS_FILTER

Custom filters🔗

Custom Filter - Show FunctionalExchanges or ExchangeItems

from capellambse import MelodyModel
from capellambse_context_diagrams import filters

lost = model.by_uuid("a5642060-c9cc-4d49-af09-defaa3024bae")
diag = obj.context_diagram
assert filters.FEX_OR_EX_ITEMS == "capellambse_context_diagrams-show.functional.exchanges.or.exchange.items.filter"
filters.filters.add(filters.FEX_OR_EX_ITEMS)
diag.render("svgdiagram").save(pretty=True)
Context diagram of Lost SystemFunction with applied filter FEX_OR_EX_ITEMS_FILTER

Make sure to check out our Stylings feature as well.