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

Pages: [1] 2 3
1
Hey,

I was wondering: is there a way to update the diagram after deleting things from the model? For examlpe it's really easy to delete some selected connectors:

Code: [Select]
dim i
dim element as EA.Element
dim diagramObject as EA.DiagramObject

for i = 0 to (selectedObjects.Count - 1)
set diagramObject = selectedObjects.GetAt(i)
set element = getElementByID(diagramObject.ElementID)
dim allConnectors : allConnectors = element.Connectors.Count-1
element.Connectors.Delete(allConnectors)
element.Update

'can't seem to update diagram appearance...
currentDiagram.Update
currentDiagram.DiagramLinks.Refresh
next

But even though -- in this case -- the relationship is removed, the connector still meaninglessly appears in the diagram.

2
General Board / Re: Auto-Report Generation Questions
« on: December 23, 2016, 09:40:58 am »
So a possible approach to what you want using virtual documents might involve writing a script to conditionally set the source of a model document such that it's the desired package within that package structure you depicted. Then when you insert the {Package.Name} field into the template for that model document, it will grab the name of the source package.

I recommend first manually creating the virtual document that does what you want so you have an intuition, then adapting the script provided in the link to make it automated. Of course this is all assuming you'll ahve some sort of consistent package structure.

3
General Board / Re: Ghost element connections
« on: December 23, 2016, 09:30:54 am »
Good to know. I think I'm set up the same as KP.

4
Automation Interface, Add-Ins and Tools / Re: Finding Parent Lane, Pool
« on: December 23, 2016, 08:51:39 am »
BTW anyone that read this interested in the solution. Probably not most efficient way but it works. Not sure if this is even a super useful functionality, but I was unsure how to filter well within the section of document editor so this makes it easy to filter by tagged values. (EDIT: just realized it'll tell you that the tags are reset even if you cancel, but it won't do anything if you do cancel)

Code: [Select]
option explicit

!INC Local Scripts.EAConstants-VBScript

'
' Script Name:
' Author:
' Purpose: At tags to elements located inside swimlanes with name "Actor" and value of the swimlane name (and remove "Actor" tags from elements not located in a swimlane)
' Date:
'
'
sub OnDiagramScript()

'GET DIAGRAM REFERENCE
dim currentDiagram as EA.Diagram
set currentDiagram = Repository.GetCurrentDiagram()

if not currentDiagram is nothing then
' Get a reference to any selected connector/objects
dim selectedConnector as EA.Connector
dim selectedObjects as EA.Collection
set selectedConnector = currentDiagram.SelectedConnector
set selectedObjects = currentDiagram.SelectedObjects

if not selectedConnector is nothing then
' A connector is selected
elseif selectedObjects.Count > 0 then
' One or more diagram objects are selected
else
' Nothing is selected
end if
else
Session.Prompt "This script requires a diagram to be visible", promptOK
end if


'ADD THE ACTOR TAGS BY SWIM LANE

'ask user
dim result : dim clearTags
result = MsgBox("This script will reset and add 'Actor' tags for all diagram objects. Do you wish to proceed?", vbYesNo + vbQuestion, "Reset Actor Tags")

Select Case result
Case vbYes
MsgBox "Script initiated..."
clearTags = true
Case vbNo
MsgBox "The script has been terminated by user.",vbinformation,"Script cancelled"
clearTags = false
End Select

'clear and reset actor tags
if clearTags then
'get a list of the lanes in diagram
dim arrListLanes
set arrListLanes = CreateObject("System.Collections.ArrayList")
set arrListLanes = getDiagramObjects(currentDiagram, "Lane")

'tag elements by lane
tagActors currentDiagram, arrListLanes
end if

msgbox "Actor tags have been reset.", vbinformation, "Script complete"

end sub




'removes actor tags then re-tags
function tagActors(currentDiagram, arrListLanes)

dim poolArrList, i, poolCount, laneCount, tagUpdated
dim tempElement as EA.Element
dim parentElement as EA.Element
dim laneElement as EA.Element
dim tag as EA.TaggedValue
dim diagramObject as EA.DiagramObject

poolCount = 0 : laneCount = 0 : tagUpdated = false

'clear any existing actor tags from diagram objects
for each diagramObject in currentDiagram.DiagramObjects
set tempElement = getElementByID(diagramObject.ElementID)
dim tags as EA.Collection
set tags = tempElement.TaggedValues

for i = tags.Count - 1 to 0 step -1
dim theTag as EA.TaggedValue
set theTag = tags.GetAt(i)
if theTag.Name = "Actor" then
call tempElement.TaggedValues.DeleteAt(i, FALSE)
end if
next
next
'tag the desired elements
for each diagramObject in currentDiagram.DiagramObjects
set tempElement = getElementByID(diagramObject.ElementID)
for i = 0 to arrListLanes.count-1
dim laneID : laneID = arrListLanes(i).ElementID
if tempElement.ParentID = laneID then
set parentElement = getElementByID(tempElement.ParentID)
if parentElement.Stereotype = "Lane" then
for each tag in tempElement.TaggedValues
if tag.Name = "Actor" and tag.Value <> parentElement.Name then
tag.Value = parentElement.Name
tag.Update
parentElement.TaggedValues.Refresh
tagUpdated = true
end if
next

if not tagUpdated then
set tag = tempElement.TaggedValues.AddNew("Actor","")
tag.Value = parentElement.Name
tag.Update
parentElement.TaggedValues.Refresh
end if
end if
end if
next
next

end function


'returns array list of diagram objects of specified stereotype
function getDiagramObjects(diagram, elementStereoType)

dim selectedObjectsList
set selectedObjectsList = CreateObject("System.Collections.ArrayList")
dim diagramObject as EA.DiagramObject
dim diagramConnector as EA.Connector
dim element as EA.Element

for each diagramObject in diagram.DiagramObjects
set element = Repository.GetElementByID(diagramObject.ElementID)
if element.StereoType = elementStereoType then
selectedObjectsList.Add diagramObject 'why don't I just add the element instead of the object..?
end if
next

'return selected Elements
set getDiagramObjects = selectedObjectsList

end function 'end getDiagramObjects

OnDiagramScript

5
Automation Interface, Add-Ins and Tools / Re: Finding Parent Lane, Pool
« on: December 23, 2016, 07:35:34 am »
It seems to work without using "Repository." first. What's the distinction?

Also I think I've figured it out; the error was because earlier code was setting tempElement to an element that had no parent element. I've done a test it am able to get an element and it's parent element using the ParentID.

6
Automation Interface, Add-Ins and Tools / Re: Finding Parent Lane, Pool
« on: December 23, 2016, 07:14:45 am »
Also I did place it graphically in the lane, but that automatically put it in the lane within Project Browser as well.

7
Automation Interface, Add-Ins and Tools / Re: Finding Parent Lane, Pool
« on: December 23, 2016, 07:12:55 am »
This is what I tried right away, but I get an internal application error here so I assumed ParentID didn't actually get the parent element:

Code: [Select]
set tempElement = getElementByID(tempElement.ParentID)
You're saying that it should? I suspected that ParentID returned a package ID and that's where I was going wrong. If it's indeed an element, any clues as to why my code fails?

8
Automation Interface, Add-Ins and Tools / Finding Parent Lane, Pool
« on: December 23, 2016, 05:07:43 am »
(VBScript)

Is there a way to find the lane an element is located in?  I've been trying to use this through the diagram object,s but perhaps looking through the packages is better?  I hesitated to do that because they're elements and not packages.

To be clear, for something like this in Project Browser:

Pool 1
   Lane 1
      Element 1
      Element 2
   Lane 2
      Element 3
      Element 4
Pool 2
    Lane 3
      Element 5
      Element 6
   Lane 4
      Element 7
      Element 8
     

Want to be able to determine that, for example, Element 5 is located in Lane 3 in Pool 2.

9
General Board / Re: Ghost element connections
« on: December 14, 2016, 10:00:21 am »
Basically I was just confused about how to properly both remove an element from a diagram and its relationships from the model, which I figured out  :)

10
General Board / Re: Ghost element connections
« on: December 14, 2016, 09:55:53 am »
"If you remove an object from a diagram you are not removing it (or any relationships that it has) from the model."
Perhaps if you define "object" as those contained in the diagramObjects table.  But connectors deleted from the diagram, as I commented, do in fact change the properties of the element's "Link" table, which I would interpret as changing relationships within the model (and more than just the diagram).  I don't think I've had any difficult understanding the the model and digram are not identical.

11
General Board / Re: Auto-Report Generation Questions
« on: December 14, 2016, 07:21:17 am »
By node do you mean a package within Project Browser?

I'm not sure I understand exactly what you're asking, but when it comes to document generation, I recommend learning to using virtual documents. I've tried a few ways to generate documents and this seems to be the best. I've been using virtual documents that use a combination of templates, filters, and template fragments. It's still very finnicky and a significant learning curve to get the hang of it, but it will allow a very high level of customization.

Perhaps this doesn't help, but if it happens to then Geert has a really a good tutorial about virtual documents: http://bellekens.com/2015/11/12/tutorial-generate-complex-documents-from-enterprise-architect-with-a-two-step-semi-automated-approach/


12
General Board / Re: Ghost element connections
« on: December 14, 2016, 06:54:42 am »
After some playing around I think I discovered the answer:

If you delete an element with connections to other elements directly (selecting that element and deleting it), it will retain those connections in its Links table despite being removed from the diagram.

However, if you first delete its associated connectors, THEN delete the element, it will have an empty Links table.

I suppose it's like this for the convenience of removing an element, then bringing it back and having it automatically restore its connectors. I still think it should remove the Links in both cases though...

13
General Board / Ghost element connections
« on: December 14, 2016, 06:43:22 am »
After deleting an element from my diagram -- but still having it in the Project Browser -- it still seems to retain Links to other elements in the diagram. This causes issues for the script I'm developing since it uses said links when going through the diagram.

Is it therefore necessary to delete these elements from the project browser? How can elements be deleted from the diagram in a way that ensures they are unlinked from those still in the diagram? It doesn't make sense to me that an element would retain its links when it's graphically removed from the model.

14
General Board / Re: Get a gateway's "Type"?
« on: December 13, 2016, 09:09:25 am »
Also: it looks like you have to further specify eventGatewayType for "Event-Parallel" and "Event-Exclusive" gatewayType, since the tagVar.Value will as shown in my last reply will give "Event" for both of those.

15
General Board / Re: Get a gateway's "Type"?
« on: December 13, 2016, 08:52:09 am »
OK figured it out by looking in the tagged values, thanks! This is how I tested it:

Code: [Select]
'stereotype already determiend as "gateway"
'find out what type of gateway it is
dim tagVar as EA.TaggedValue
for each tagVar in myElement.TaggedValues
   if tagVar.Name = "gatewayType" then
      msgbox "Gateway: "&myElement.Name &vbnewline &"Type: "&tagVar.Value
   end if
next

Pages: [1] 2 3