Book a Demo

Author Topic: Addings an element to multiple Diagram Layers?  (Read 10465 times)

Barrie Treloar

  • EA User
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Addings an element to multiple Diagram Layers?
« on: March 20, 2023, 04:03:19 pm »
If I have an element that should belong to multiple Diagram Layers, how do I do that?
It looks like the Filter & Layers tool only allows a 1:1 relationship.

Sunshine

  • EA Practitioner
  • ***
  • Posts: 1353
  • Karma: +121/-10
  • Its the results that count
    • View Profile
Re: Addings an element to multiple Diagram Layers?
« Reply #1 on: March 20, 2023, 04:22:57 pm »
Then use filters instead of diagram layers
Happy to help
:)

Barrie Treloar

  • EA User
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: Addings an element to multiple Diagram Layers?
« Reply #2 on: March 21, 2023, 07:53:34 pm »
Aren't filters global?
I didn't really want to pollute my model with them just for one diagram.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Addings an element to multiple Diagram Layers?
« Reply #3 on: March 21, 2023, 08:25:56 pm »
Aren't filters global?
I didn't really want to pollute my model with them just for one diagram.
Search the forum, I recently posted a topic on this theme.

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Barrie Treloar

  • EA User
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: Addings an element to multiple Diagram Layers?
« Reply #4 on: March 23, 2023, 03:21:43 pm »
Thanks Paolo.

I *did* search before posting, and so I have no idea how I missed those threads.

It was easier to look through your posts to find it!

https://sparxsystems.com/forums/smf/index.php/topic,47573.msg277302.html#msg277302

As usual, another feature of Sparx not yet implemented.

I'll fiddle with Filters and One Of..

Barrie Treloar

  • EA User
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: Addings an element to multiple Diagram Layers?
« Reply #5 on: March 23, 2023, 04:36:04 pm »
Of course there's no way to set a property on multiple selected elements...

Use the filter condition "Contains" (not One of)

This script requires editing before running, as I've not yet learnt how to prompt for user input...

Writing this script was still faster than manually selecting each element and setting keywords...

Code: [Select]
option explicit

'[path=\Element]
'[group=Element]

dim KEYWORD_TO_APPEND
' CHANGE THIS VALUE BEFORE RUNNING
KEYWORD_TO_APPEND = "business_architecture_view"

sub main
dim diagram as EA.Diagram
dim diagramObject as EA.DiagramObject
dim element as EA.Element

Session.Output "Start..."

'get the current diagram
set diagram = Repository.GetCurrentDiagram()
if not diagram is nothing then
'first save the diagram
Repository.SaveDiagram diagram.DiagramID
for each diagramObject in diagram.SelectedObjects
set element = Repository.GetElementByID(diagramObject.ElementID)
Session.Output "Working on '" & element.name & "'"
if InStr(element.Tag, KEYWORD_TO_APPEND) = 0 then
If element.Tag = "" then
element.Tag = KEYWORD_TO_APPEND
else
element.Tag = element.Tag & "," & KEYWORD_TO_APPEND
end if

if not element.Update() then
Session.Output "Update failed: " & element.GetLastError()
end if
end if
next
end if
logger.INFO "Done"
end sub

main
« Last Edit: March 23, 2023, 04:55:44 pm by Barrie Treloar »