Author Topic: Change diagram MDGTechnology  (Read 1734 times)

JiangangWang

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Change diagram MDGTechnology
« on: September 06, 2022, 10:36:50 am »
I have to change the SysML diagram (mainly sequence and bdd diagram) to UML diagram due to some issues, and it can be done through UI from menu change type by deleting the MDGTechnology tag value.

However there are lots of diagrams which need to be changed, so I turned into scripts to change it.
here is the core part of VB script, but when I run it, it doesn't take affect.

dim j
dim diagrams as EA.Collection
set diagrams = currentElement.Diagrams
               
for j = 0 to diagrams.Count - 1
   dim currentDiagram as EA.Diagram
   set currentDiagram = diagrams.GetAt ( j )
                  
   if currentDiagram.MetaType = "SysML1.4::Sequence" then
   Session.Output( "Diagram: " & currentDiagram.Name & " - Type: " & currentDiagram.Type & " - SysML Type: " & currentDiagram.MetaType)
            
   currentDiagram.MetaType = " "
        currentDiagram.StyleEx = replace(currentDiagram.StyleEx, "MDGDgm=SysML1.4::Sequence;", " ")
        currentDiagram.Update()
   diagrams.Refresh()
       end if
next

Could any master take a look at it?
Thx.            

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Change diagram MDGTechnology
« Reply #1 on: September 06, 2022, 02:55:27 pm »
So does it find any diagrams?
Also make sure the replace does what it needs to do. It won't work if you have a spelling error, and it's case sensitive.

Lastly, you don't need diagrams.Refresh(). Removing that won't fix anything, but it's simply not necesarry.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Change diagram MDGTechnology
« Reply #2 on: September 06, 2022, 06:26:01 pm »
Looks fine to me. But you are only looking for diagrams in elements, not in any packages. I would query the diagrams with a SQL and retrieve them for th API by the diagramID.

q.