Book a Demo

Author Topic: Diagram Options  (Read 6057 times)

Doug Blake

  • EA User
  • **
  • Posts: 102
  • Karma: +0/-0
    • View Profile
Diagram Options
« 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
DGB Using 12.0.1214 / eaDocX 3.6.2.1 / MSSQL / TFS / Windows 7 / IE11

philchudley

  • EA User
  • **
  • Posts: 750
  • Karma: +22/-0
  • EA Consultant / Trainer - Sparx Europe
    • View Profile
Re: Diagram Options
« Reply #1 on: March 31, 2014, 10:58:27 pm »
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
Models are great!
Correct models are even greater!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Diagram Options
« Reply #2 on: March 31, 2014, 11:13:30 pm »
Doug you probably can using the template package.

Geert

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Diagram Options
« Reply #3 on: March 31, 2014, 11:14:59 pm »
Quote
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

Doug Blake

  • EA User
  • **
  • Posts: 102
  • Karma: +0/-0
    • View Profile
Re: Diagram Options
« Reply #4 on: April 01, 2014, 12:13:13 am »
Quote
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 ...
DGB Using 12.0.1214 / eaDocX 3.6.2.1 / MSSQL / TFS / Windows 7 / IE11

Nizam Mohamed

  • EA User
  • **
  • Posts: 193
  • Karma: +1/-0
    • View Profile
Re: Diagram Options
« Reply #5 on: April 01, 2014, 12:39:58 am »
Simple VB Script to update diagram status across the model
Code: [Select]
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
« Last Edit: April 01, 2014, 12:58:03 am by nizammohamed »

Nizam Mohamed

  • EA User
  • **
  • Posts: 193
  • Karma: +1/-0
    • View Profile
Re: Diagram Options
« Reply #6 on: April 01, 2014, 12:41:11 am »
Script to update diagrams under a particular package
Code: [Select]
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
« Last Edit: April 01, 2014, 12:58:25 am by nizammohamed »

Nizam Mohamed

  • EA User
  • **
  • Posts: 193
  • Karma: +1/-0
    • View Profile
Re: Diagram Options
« Reply #7 on: April 01, 2014, 12:42:59 am »
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