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.

Topics - Benny

Pages: [1]
Automation Interface, Add-Ins and Tools / Insert a Legend
« on: April 13, 2017, 11:35:13 pm »

I managed to insert a Legend in a Diagram with a Script

Code: [Select]
set legend = currentPackage.Elements.AddNew( "", "Text")
hyperLink.Subtype = 76

How can I fill these legend with values using a script.

I inserted a legend using the "normal" way in sparx and searched for any reference in the database.
But I just found the SubType 76 Statement and some values in the StyleEx Row.
But where are the values and colors of the Legend defined ?

Maby someone has hint for me?



Im trying to compare two strings with each other, but it does not work : /

First of all the Code:

option explicit
!INC Local Scripts.EAConstants-VBScript

sub HidePrivateAttributes()
   ' Get the type of element selected in the Project Browser
   dim treeSelectedType
   treeSelectedType = Repository.GetTreeSelectedItemType()
   select case treeSelectedType

      case otDiagram
         ' Code for when a diagram is selected
         dim theDiagram as EA.Diagram
         set theDiagram = Repository.GetTreeSelectedObject()
         dim Ops               
         dim Atts


         Atts = theDiagram.Name Like "XXX Attributes*"
         Ops = theDiagram.Name Like "XXX Operations*"
         If Atts = true then
         call hideAtt(theDiagram)
         Elseif Ops = true then
         call hideOps(theDiagram)
         End if


      case else
         ' Error message
         Session.Prompt "This script does not support items of this type.", promptOK
   end select
end sub

Function hideAtt(diagram)
End Function

Function hideOps(diagram)
End Function

But it seems that Sparx dont like the "LIKE" Operator or I use it wrong.
Based on msdn homepage it is the correct syntax "result = string Like pattern  "

I tryed to use "Option Compare Binary/Text" but it send me an error "Statement expected"

I Know I'm lacking knowledge in VBS and it might be a simple VBS failure.

I search the web for tutorials but it all scripts it is no problem to use this operator.

Please maybe someone can explain this to me.




im facing a problem (again  ???).

Im trying to hide or show the Attributes / Operations of a class in a diagram.
The values are in the Elements Setup Window=> Show Compartments => Attributes / Operations.
Also shown on page 130 Scripting EA ; )

I understand that the *.WriteStyle("") is only for the "Show Element Property String" and some other stuff, but how can I access the Attributes and Operations.

As a work around in an other Project I just hide the Private-statement at the Visible Class Members.

Function hideAtt (diagram)
End Function

But at this time I need it more detailed. I need to write a script which hide the Attributtes and/or Operations based on the diagram name.

Maybe someone can give me a hint.




I would like to add the Diagram Properties Note to the diagram using a script which already adds some Boundaries.

The Diagram Properties Note is just a text so I tried it like this:

   dim Overview as EA.Element
   set Overview = currentPackage.Elements.AddNew( "", "Text" )
   call Overview.Notes("Name: " & currentDiagram.Name & vbCrLf & _
   "Author: " & currentDiagram.Author & vbCrLf & _
   "Version: " & currentDiagram.Version & vbCrLf & _
   "Created: " & currentDiagram.CreatedDate & vbCrLf & _
   "Updated: " & currentDiagram.ModifiedDate )

I looks quiet the same, but what I did not consider, that the Name ModifiedDate is fix in the notefield once the text was created.
In die original diagram properties note the values are self updating.

Is there a possibility to insert the original one within a script.
I cloud insert it in the diagram like this:
So there must be a way, or ?


Pages: [1]