Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: Doug Blake on March 31, 2014, 10:48:05 pm
-
I have a project with over 700 diagrams. Is there a way to set default values for the items in the diagram properties dialogue instead of having to set the options for each diagram?
I am particularly interested in
- Use Alias if Available
- Show Namespace
-
Hi Doug
I believe this is possible with a script, I am off site at the moment, but will have a go tomorrow and post the script here
Best regards
Phil
-
Doug you probably can using the template package.
Geert
-
Hi Doug
I believe this is possible with a script, I am off site at the moment, but will have a go tomorrow and post the script here
Best regards
Phil
A script can take care of the existing diagrams, the template package can be used to set the default value for new diagrams.
Geert
-
Hi Doug
I believe this is possible with a script, I am off site at the moment, but will have a go tomorrow and post the script here
Best regards
Phil
Well that's damn decent of you Phil. I find the problem with all this scripting is that it takes focus off the job in hand, so we are reluctant to get into it. It may be something we have no choice but to embrace, but we have resisted so far ...
-
Simple VB Script to update diagram status across the model
option explicit
!INC Local Scripts.EAConstants-VBScript
'
' Iterates through an EAP file using recursion.
'
sub BatchEditDiagrams()
' Show the script output window
Repository.EnsureOutputVisible "Script"
' Iterate through all models in the project
dim currentModel as EA.Package
for each currentModel in Repository.Models
' Recursively process this package
ParsePackage currentModel
next
Session.Output ("DiagramIDs" & sDiagramIDs)
Session.Output( "Done!" )
end sub
sub ParsePackage (thePackage )
' Cast thePackage to EA.Package so we get intellisense
dim currentPackage as EA.Package
set currentPackage = thePackage
' Add the current package's name to the list
Session.Output( indent & currentPackage.Name & " (PackageID=" & currentPackage.PackageID & ")" )
' Dump the elements this package contains
EditDiagramProperties currentPackage
' Recursively process any child packages
dim childPackage as EA.Package
for each childPackage in currentPackage.Packages
ParsePackage childPackage
next
end sub
sub EditDiagramProperties ( thePackage )
dim currentPackage as EA.Package
set currentPackage = thePackage
' Iterate through all elements and add them to the list
dim currDiagram as EA.Diagram
for each currDiagram in currentPackage.Diagrams
Session.Output ( "Current Namespace Status" & currDiagram.HighlightImports & "Current Style" & currDiagram.ExtendedStyle)
'Set Namespace visibility
currDiagram.HighlightImports = 1
'Set UseAlias
if currDiagram.ExtendedStyle = "" Then
currDiagram.ExtendedStyle = "HideRel=0;ShowTags=0;ShowReqs=0;ShowCons=0;OpParams=1;ShowSN=0;ScalePI=0;PPgs.cx=1;PPgs.cy=1;PSize=9;ShowIcons=1;SuppCN=0;HideProps=0;HideParents=0;UseAlias=1;HideAtts=0;HideOps=0;HideStereo=0;HideEStereo=0;FormName=;"
else
currDiagram.ExtendedStyle = Replace(currDiagram.ExtendedStyle,"UseAlias=0","UseAlias=1")
End If
currDiagram.Update
Session.Output ( "New Namespace Status" & currDiagram.HighlightImports & "New Style" & currDiagram.ExtendedStyle)
next
end sub
BatchEditDiagrams
-
Script to update diagrams under a particular package
option explicit
!INC Local Scripts.EAConstants-VBScript
' NOTE: Requires a package to be selected in the Project Browser
sub EditPackageDiagrams()
' Show the script output window
Repository.EnsureOutputVisible "Script"
' Get the currently selected package in the tree to work on
dim thePackage as EA.Package
set thePackage = Repository.GetTreeSelectedPackage()
if not thePackage is nothing and thePackage.ParentID <> 0 then
set currentPackage = thePackage
' Iterate through all elements and add them to the list
dim currDiagram as EA.Diagram
for each currDiagram in currentPackage.Diagrams
Session.Output ( "Current Namespace Status - " & currDiagram.HighlightImports & "Current Style" & currDiagram.ExtendedStyle)
'Set Namespace visibility
currDiagram.HighlightImports = 1
'Set UseAlias
if currDiagram.ExtendedStyle = "" Then
currDiagram.ExtendedStyle = "HideRel=0;ShowTags=0;ShowReqs=0;ShowCons=0;OpParams=1;ShowSN=0;ScalePI=0;PPgs.cx=1;PPgs.cy=1;PSize=9;ShowIcons=1;SuppCN=0;HideProps=0;HideParents=0;UseAlias=1;HideAtts=0;HideOps=0;HideStereo=0;HideEStereo=0;FormName=;"
else
currDiagram.ExtendedStyle = Replace(currDiagram.ExtendedStyle,"UseAlias=0","UseAlias=1")
End If
currDiagram.Update
Session.Output ( "New Namespace Status - " & currDiagram.HighlightImports & "New Style" & currDiagram.ExtendedStyle)
next
Session.Output ("DiagramIDs" & sDiagramIDs)
Session.Output( "Done!" )
else
' No package selected in the tree
MsgBox( "This script requires a package to be selected in the Project Browser." & vbCrLf & _
"Please select a package in the Project Browser and try again." )
end if
end sub
EditPackageDiagrams
-
Request you to please try the script in a test model prior to trying in the actual model.
Also, whilst it may be time consuming, i'd request you to go with updating individual packages, rather than bulk model edit.
(Also start in a test model)
NB - I haven't tested this in all DBs, works ok in EAP