Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Pegasus

Pages: 1 [2] 3
currently I don't know what doing wrong (maybe lack on knowledge of java). I run Update() on a locked element (HybridScript in JAVA) and get an exception

Exception in thread "main" java.lang.Exception: Element locked
at org.sparx.Element.comUpdate(Native Method)
at org.sparx.Element.Update(

I surround the elem.SetName and following Update-call with try ... catch (Exception e) and get the message displayed, I put inside catch-block. But nevertheless the script ends with the (stacktrace) messages above. What I expect is, that I can catch the exception and coninue in script sequence. Maybe I catch the wrong Exception-Type. But if so, what will be the right one? I don't know a source describing the JAVA API

Thanks for support


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...

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
               dirty = true
            end if
         '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


'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
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
   '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
      mode = connectorStyle
   end if
   'set the mode value
   if modeIndex >= 0 then
      styleparts(modeIndex) = "Mode=" & mode
      diagramLink.Style = join(styleparts,";")
      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,";")
         'remove tree part
         diagramLink.Style = replace(diagramLink.Style,styleparts(treeIndex)&";" , "")
      end if
      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
   if tree <> "" then
      getConnectorStyle = tree
      getConnectorStyle = mode
   end if
end function


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...? 


General Board / SQL - Macro #Branch#: Result entire model
« on: January 14, 2017, 12:44:21 am »

I am just testing #Branch# Macro with some case
and is see that result seems to be entire modell wheater if selected package contains further packages  or not? I expecte #Branch contains
select o.ea_guid AS CLASSGUID, o.Object_Type AS CLASSTYPE,, o.ea_guid, o.Object_type AS Type, o.Stereotype, o.Author, o.modifiedDate AS Modified, o.note AS [Notes] FROM t_object o, t_package pkg WHERE pkg.Package_ID IN (#Branch#)

from user guide
Gets the IDs of the child Packages of the currently-selected Package, working recursively down to the lowest level of sub-Package. For example:
t_object.Package_ID IN (#Branch#)


I found "problem". It was part of setValue-parameter. In real code "new Date" ist result of an other api call  (Java API of PTCIntegrity) and this seems not to be well done by me. If I assing result to String variable first and call SetValute (strVal) afterwards, all is fine.


I don't understand API for modifiy (update) tagged values.  (EA 13)
What I want is to update existiing Tagged Values if content changed  see part of my code (part of function call)...

Collection<org.sparx.TaggedValue> elemTaVs = eaElem.GetTaggedValues();  // what means read only`?
tv_ptcModifDate = elemTaVs.GetByName( eaPtcFNameModifDate ); // returns null if not found
tv_ptcModifDate.SetValue( "new Date" );
if (tv_ptcModifDate.Update()) {

but new value isn't set in Modell (seen by Wizard in Model)

Thanks for support


there are some contratictory topics to question how to get in projectbrowser selected Obejcts (e.g. packages, requirements/elements); e.g.,30519.msg222208.html#msg222208 [Geerd] and,5050.msg123251.html#msg123251 [Aaron]. I do have same problem. In EA 13 using Java API GetTreeSelectedElements returns collection with e.g requirements only not also selected packages, so I assume there isn't an interface returning collection of selected "objects" [in project-browser]. But how is it possible to recognise multiple selections of "objects" e.g. packages and elements at once

Thanks for support and elucidation

First, Thanks for hint to specials of root.
Exception bases on an writeto script output and I didn' investigate.

I'm now able to access TV (displayed as Tags Tab), but I don't understand how to access on TV defined in an MDG e.g. SysML1.4 and I don't understand FQName in TV class (filled if e.g. SysML1.4 ?)
What I'm always confused is where to find definiton of e.g GetName() to access Name of e.g. Element, not write Element.Name ...?

I hope for further hints to lift the fog in my thougths


Preferences: I'm not realy familar with java, but need to use it to access via an API to an external applikation (PTCIntegrity)

I try to run from easy to more complex example (based on hyperscript example from Sparx using java)
I try to run first on packages and read TV (if exist) but I get Exception if I try to print of name of Element (package) of a root (Model) package....   I am not sure if I understand API at all.,
Where come e.g. GetPackages() from and how do I get access on e.g. isModel. I don't see this methods in online help (automation interface/Package package, ..)
If I understand right, I do have first getPackages(collection) than iterate with GetAt(idx) collection and call pgk.GetElement() to get access to e.g. TV. To get the TV for one element I do need a new collection TaggedValue filled by element.GetTaggedValues() ?

Where do I went wrong.
Sorry,  if my description isn't well english and confuse, but it reflects my current problem in understandig API
Tanks in advance for support and hints

Bugs and Issues / Create diagram with use alias
« on: November 24, 2016, 11:54:15 pm »
I trie to find the place(dialog) in EA V13.0.1305 where to configure that when creating new diagramm (browser/"add diagram") checkbox Properties/Diagram: "Use Alais if Available" and "Show Diagram Details" are selected (preset). Currently I do have to change manually for each diagram.
Thanks for support in advance


Bugs and Issues / CSV-Import: DAO.Fields [3265]
« on: November 24, 2016, 07:54:32 pm »

I do import (EA 13.0.1305) from excel/csv-file with hierarchical informations (CSV_KEY/CSV_PARENT_KEY) and get following message DAO.Fields [3265] Element in dieser Auflistung nicht gefunden. If export results (including GUI-ID) from EA into csv-file and compare this file wiht the i did the import with, I don't see differences. But what cause this messages. I fear inconsistency in data?

Thanks for feedback in advance

Bugs and Issues / Re: CSV import with preserve hierarchy
« on: November 08, 2016, 08:32:25 pm »
Hello Uffe, thanks for reply. Maybe I expressed misunderstanding. I need to use the CSV_(PARENT_)KEY columns to build the hierarchy in EA like the other tool respectively excel export. If CSV_(PARENT_)Key are emtpy all elements (Packages, Requirements, ..) will generate plane. thats not what I need.  The IDs itself I import into Tagged values as you describe

Bugs and Issues / CSV import with preserve hierarchy
« on: November 08, 2016, 07:45:38 pm »
I do have a problem with CSV import and the colums CSV_KEY and CSV_PARENT_KEY.
Scenario: I import data from a separate "Requirement management" system exported to Excel. this system exports ID and hierarical relations as reference to the actual numerical ID. To import in EA(13) it is necessary to write into CSV_KEY the name of the element and in CSV_PARENT_KEY the name of the parent element. Unfortunaltely it is not possible to use own identifier. So I get warning if e.g. the parent is a package wit name XXX and the underlying element (Requirement) has identical name XXX. Do I something wrong. If not than it is desirable that SPARX adds possibility to use selfdefined token also numerical values for CSV_(PARENT_)KEY.

General Board / Re: New Beta
« on: June 10, 2016, 05:00:31 pm »
The discussion about the new version refers only to the UI. I find it more interesting to know if i can edit a modell build with Version 12.1 in parallel with this new Major beta 13 without running into problem e.g. incompatibiliites ....


Pages: 1 [2] 3