Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: JiangangWang 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.
-
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
-
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.