Book a Demo

Author Topic: Different beahviour VBScript EA V12.1 and V13  (Read 6719 times)

Pegasus

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
    • View Profile
Different beahviour VBScript EA V12.1 and V13
« on: February 02, 2017, 11:29:10 pm »
Hello,

I just tried to use VB Scripts (diagram goup) changing line style of connectors in a diagramm adapted in EA V12.x inside EA V13 and it seems nothing to be changed. Using same Modell with EA 12.1 it works furthermore fine. Does something changed in API with release EA V13...? 

Thanks
Pegasus

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Different beahviour VBScript EA V12.1 and V13
« Reply #1 on: February 03, 2017, 02:31:53 am »
It would probably be helpful to see the code.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13471
  • Karma: +571/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Different beahviour VBScript EA V12.1 and V13
« Reply #2 on: February 03, 2017, 03:23:20 am »
I haven't noticed any differences, and I use a lot of vbscript.

Geert

Pegasus

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
    • View Profile
Re: Different beahviour VBScript EA V12.1 and V13
« Reply #3 on: February 03, 2017, 06:28:45 pm »
option explicit

!INC Local Scripts.EAConstants-VBScript

' Script Name: DefaultLineStyles
' Author: Geert Bellekens, Patrick Gottschalk
' Purpose: Allows to change the linestyles to their default
' Date: 27/04/2015; 03.02.2016 (LC->LV für Mode 3 korrigiert), 04.02.2016 trace (UML, Abstraction) -> Mode 3, LV
'
dim lsDirectMode, lsAutoRouteMode, lsCustomMode, lsTreeVerticalTree, lsTreeHorizontalTree, _
lsLateralHorizontalTree, lsLateralVerticalTree, lsOrthogonalSquareTree, lsOrthogonalRoundedTree

lsDirectMode = "1"
lsAutoRouteMode = "2"
lsCustomMode = "3"
lsTreeVerticalTree = "V"
lsTreeHorizontalTree = "H"
lsLateralHorizontalTree = "LH"
lsLateralVerticalTree = "LV"
lsOrthogonalSquareTree = "OS"
lsOrthogonalRoundedTree = "OR"

dim defaultStyle
dim menuDefaultLines


'*********EDIT BETWEEN HERE*************


' set here the default style to be used
defaultStyle = lsOrthogonalSquareTree

' set there the style to be used for each type of connector
function determineStyle(connector)
   dim connectorType
   connectorType = connector.Type
   select case connectorType
      case "StateFlow","ObjectFlow","InformationFlow"
         determineStyle = lsOrthogonalRoundedTree
      case "Generalization", "Realization", "Realisation"
         determineStyle = lsTreeVerticalTree
      case "UseCase","NoteLink"  ' Original:"UseCase", "Dependency","NoteLink"
         determineStyle = lsDirectMode
      case "Dependency"
         determineStyle = lsOrthogonalSquareTree'lsLateralVerticalTree
      case "Abstraction" ' UML trace
         determineStyle = lsTreeHorizontalTree
      case else
         determineStyle = defaultStyle
   end select
end function
'************AND HERE****************


sub main
      dim diagram
      dim diagramLink
      dim connector
      dim dirty
      dirty = false
      set diagram = Repository.GetCurrentDiagram
      'save the diagram first
      Repository.SaveDiagram diagram.DiagramID
      'then loop all diagramLinks
      if not diagram is nothing then
         for each diagramLink in diagram.DiagramLinks
            set connector = Repository.GetConnectorByID(diagramLink.ConnectorID)
            if not connector is nothing then
               'set the connectorstyle
               setConnectorStyle diagramLink, determineStyle(connector)
               'save the diagramlink
               diagramLink.Update
               dirty = true
            end if
         next
         'reload the diagram if we changed something
         if dirty then
            'reload the diagram to show the link style
            Repository.ReloadDiagram diagram.DiagramID
         end if
      end if
end sub

main


'gets the diagram link object
function getdiagramLinkForConnector(connector, diagram)
   dim diagramLink
   set getdiagramLinkForConnector = nothing
   for each diagramLink in diagram.DiagramLinks
      if diagramLink.ConnectorID = connector.ConnectorID then
         set getdiagramLinkForConnector = diagramLink
         exit for
      end if
   next
end function

'actually sets the connector style
function setConnectorStyle(diagramLink, connectorStyle)
   'split the style into its parts
   dim styleparts
   dim styleString
   styleString = diagramLink.Style
   styleparts = Split(styleString,";")
   dim stylePart
   dim mode
   dim modeIndex
   modeIndex = -1
   dim tree
   dim treeIndex
   treeIndex = -1
   mode = ""
   tree = ""
   dim i
   'find if Mode and Tree are already defined
   for i = 0 to Ubound(styleparts) -1
      stylePart = styleparts(i)
      if Instr(stylepart,"Mode=") > 0 then
         modeIndex = i
      elseif Instr(stylepart,"TREE=") > 0 then
         treeIndex = i
      end if
   next
   'these connectorstyles use mode=3 and the tree
   if  connectorStyle = lsTreeVerticalTree or _
      connectorStyle = lsTreeHorizontalTree or _
      connectorStyle = lsLateralHorizontalTree or _
      connectorStyle = lsLateralVerticalTree or _
      connectorStyle = lsOrthogonalSquareTree or _
      connectorStyle = lsOrthogonalRoundedTree then
      mode = "3"
      tree = connectorStyle
   else
      mode = connectorStyle
   end if
   'set the mode value
   if modeIndex >= 0 then
      styleparts(modeIndex) = "Mode=" & mode
      diagramLink.Style = join(styleparts,";")
   else
      diagramLink.Style = "Mode=" & mode& ";"& diagramLink.Style
   end if
   'set the tree value
   if treeIndex >= 0 then
      if len(tree) > 0 then
         styleparts(treeIndex) = "TREE=" & tree
         diagramLink.Style = join(styleparts,";")
      else
         'remove tree part
         diagramLink.Style = replace(diagramLink.Style,styleparts(treeIndex)&";" , "")
      end if
   else
      diagramLink.Style = diagramLink.Style & "TREE=" & tree & ";"
   end if
end function

function getConnectorStyle(diagramLink)
   'split the style
   dim styleparts
   styleparts = Split(diagramLink.Style,";")
   dim stylePart
   dim mode
   dim tree
   mode = ""
   tree = ""
   for each stylepart in styleparts
      if Instr(stylepart,"Mode=") > 0 then
         mode = right(stylepart, 1)
      elseif Instr(stylepart,"TREE=") > 0 then
         tree = replace(stylepart, "TREE=", "")
      end if
   next
   if tree <> "" then
      getConnectorStyle = tree
   else
      getConnectorStyle = mode
   end if
end function

Nabil

  • EA User
  • **
  • Posts: 147
  • Karma: +5/-2
    • View Profile
    • View My LinkedIn Profile Here
Re: Different beahviour VBScript EA V12.1 and V13
« Reply #4 on: February 03, 2017, 08:41:34 pm »
could you please confirm are you getting error on all line styles or for anything specific?

Also report your issue to Sparx Support.

BR,
Nabil Saleem
Nabil

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Different beahviour VBScript EA V12.1 and V13
« Reply #5 on: February 03, 2017, 09:35:45 pm »
I ran that script for "several" connectors and could not spot any difference. What differences do you see exactly?

q.

Pegasus

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
    • View Profile
Re: Different beahviour VBScript EA V12.1 and V13
« Reply #6 on: February 06, 2017, 08:48:37 pm »
If i run script on EA V12.1 calling the connectors graphic representation changed in diagram after script ends. If I call same script in same way in EA V13 I see script runs, but nothing changed in diagram...

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13471
  • Karma: +571/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Different beahviour VBScript EA V12.1 and V13
« Reply #7 on: February 06, 2017, 09:00:43 pm »
Are you sure the script actually runs?
In v13 they added new security rights to allow/restrict running scripts. By default they are turned off, so maybe your script isn't running at all.

To make sure add something like

msgbox "this script is running!"

To the script.

Geert