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

Pages: [1]
1
Automation Interface, Add-Ins and Tools / Re: Element - set GUID method
« on: December 12, 2017, 06:05:46 am »
Hi,

I would also like to set a GUID manually.
When I Import a CSV-File with (valid) GUID inside, the GUIDs where set to the new Elements.
So I consider there musst be a Method to give Input with GUIDs.

I tried to Import it by an script because i like to add a new Connector to existing Elements.
I also tried the "SQL Backdoor" Geert implied, but I got a warning about duplicate Elements.
I also tried the "normal" way to import with the buildin Sparx CSV importer, no Porblems with the GUIDs.
Here is the import function:

Code: [Select]
function OnRowImported()
{
      rowCount++;

      // get all values for this row
      var reqName = CSVIGetColumnValueByName("Name");
      var reqType = CSVIGetColumnValueByName("Type");
      var reqGUID = CSVIGetColumnValueByName("GUID");
      var reqNotes = CSVIGetColumnValueByName("Notes");
      var reqAlias = CSVIGetColumnValueByName("Alias");
  var reqStereotype = CSVIGetColumnValueByName("Stereotype");
  var reqTagValue = CSVIGetColumnValueByName("TagValue");
  var systemGUID = CSVIGetColumnValueByName("SystemGUID");  
 
      Session.Output("  Importing: " + reqName + "." + reqGUID);

targetPackage = Repository.GetTreeSelectedPackage();
requirement = targetPackage.Elements.AddNew (reqName, reqType);
// requirement.ElementGUID = "{"+reqGUID+"}";
requirement.Notes = reqNotes;
requirement.Stereotype = reqStereotype;
requirement.Alias = reqAlias;
tag = requirement.TaggedValues.AddNew ("Funktional/NichtFunktional",reqTagValue);
tag.Update;
requirement.Update();
SQL = "UPDATE `t_object`"+
"SET     `ea_guid`='{"+reqGUID+"}'"+
"WHERE `Object_ID`="+requirement.ElementID+";"
Repository.Execute(SQL);

     
}

May someone got a hint for me

regards Benny


[edit] HAHA never Mind I really got double GUID in the CSV-file (because of a N-N dependency for the System Elements...  :o
So it work fine with the SQL Update :D

2
Quote
According tot the help
Quote
IsSelectable
Boolean
Notes: Indicates whether this object on the diagram can be selected.
Setting IsSelectable to false, and then updating the diagramObject should work.
It doesn't say this is a read-only property (doesn't say read/write either)

So if setting this property doesn't have the expected result I would log it as a bug.

Geert

Hi,

According to Page 89 in qwertys book ab IsSelectable: "In my tests this neither returned the correct setting nor did it change the property."

Yes it doesn´t  work. Like serveral other Methods that don´t effect the "Value" of an Element.
Like making Text in a Boundary Bold or altering the font etc.
It is a real pain to get those thinks work in a script properly Imho.

regards
Benny


3
Automation Interface, Add-Ins and Tools / Re: Insert a Legend
« on: May 05, 2017, 01:05:40 am »
THANKS  ;D


Code: [Select]
xrefGUID = GUIDGenerateGUID()
SQL = "INSERT INTO [t_xref] " &_
  "([XrefID], [Name], [Type], [Visibility], [Namespace], [Requirement], [Constraint], [Behavior], [Partition], [Description], [Client], [Supplier], [Link])"&_
  " VALUES('" & xrefGUID & "', 'CustomProperties', 'element property', 'Public', NULL, NULL, NULL, NULL, '0', '@PROP=@NAME=Eins@ENDNAME;@TYPE=LEGEND_OBJECTSTYLE@ENDTYPE;@VALU=#Back_Ground_Color#=55295;#Pen_Color#=0;#Pen_Size#=1;#Legend_Type#=LEGEND_OBJECTSTYLE;@ENDVALU;@PRMT=0@ENDPRM.....);"
msgbox(SQL)
Repository.Execute SQL

square brackets ....  I hate them  :P

4
Automation Interface, Add-Ins and Tools / Re: Insert a Legend
« on: May 04, 2017, 08:08:50 pm »
Hi,

i managed to generate a full legend and everything is working fine... in my local test *.EAP  ;D



Code: [Select]
dim legend as EA.Element
dim SQL
dim xrefGUID

set legend = currentPackage.Elements.AddNew( "", "Text")
legend.Subtype = 76
'legend.Notes = ""
legend.Update

xrefGUID = GUIDGenerateGUID()
SQL = "INSERT INTO `t_xref`" &_
  "(`XrefID`, `Name`, `Type`, `Visibility`, `Namespace`, `Requirement`, `Constraint`, `Behavior`, `Partition`, `Description`, `Client`, `Supplier`, `Link`)"&_
  "VALUES('" & xrefGUID & "', 'CustomProperties', 'element property', 'Public', NULL, NULL, NULL, NULL, '0', '@PROP=@NAME=Test Eins@ENDNAME;@TYPE=LEGEND_OBJECTSTYLE@ENDTYPE;@VALU=#Back_Ground_Color#=55295; [cut]', '"& legend.ElementGUID &"', '<none>', NULL);"

Repository.Execute SQL

But in my productive Project *.EAP it does not work  >:(
It seems there is an SQL Syntax failure or something ?
The productive Project runs on an MS OLEDB SQL Server

I tryed to get rid of the " ` " but it does not help.

Does anyone know what the Problem is?
It runs perfecly fine on the local EAP file.

/Benny

5
Automation Interface, Add-Ins and Tools / Re: Insert a Legend
« on: April 19, 2017, 01:05:21 am »
Thank you very much.  :D

6
Automation Interface, Add-Ins and Tools / Insert a Legend
« on: April 13, 2017, 11:35:13 pm »
Hi,

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?


/Benny

7
Hi,

ok one minute after I posted this i found, that "LIKE" is not available in VBS  :'(


I did it with instr()

=============================================

         Atts=instr(1,theDiagram.Name,"XXX Attributes",0)
         
         Ops=instr(1,theDiagram.Name,"XXX Operations",0)
         
         If Atts = 1 then
         'call hideAtt(theDiagram)
         msgBox(Atts)
         Elseif Ops = 1 then
         msgBox(Ops)
         'call hideOps(theDiagram)
         Else
         End if
=====================================================

Yeah  ;D now I can move on.

8
Hi,

I´m 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)
         Else
         End if


         ReloadDiagram(theDiagram.DiagramID)

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

Function hideAtt(diagram)
         diagram.ShowPrivate(false)
         diagram.Update()
End Function

Function hideOps(diagram)
         diagram.ShowPublic(false)
         diagram.Update()
End Function



But it seems that Sparx don´t 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.

regards

Benny



9
Thank you for your quick response!

regards

Benny

10
Hi,

i´m facing a problem (again  ???).

I´m 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)
         diagram.ShowPrivate(false)
         diagram.Update()
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.

regards

Benny

11
Hi,

i did it with the Subtype=18, it worked fine thank you very much.

many thanks

Benny

12
Hi,
thank you for your answers.

@qwerty:

afaik are the Show Diagram Note not equal to the Diagram porperty note? O_o

I´ll try the Subtype=18 solution.

bdw: I bougth your Book Scripting EA last week ; )

Many Thanks


13
HI,

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 )
   Overview.Update

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: http://sparxsystems.com/enterprise_architect_user_guide/13.0/modeling_tools/addpropertiesnote.html
So there must be a way, or ?

Benny

14
Hi,

thank you so much for your quick response!
I´ll try it asap.

Benny

15
Hi, may I aks a question concerning Boundaries in a script.

I added new Boundaries but i´d like to change the Boderstyle in "Solid".

I tryed like this but without success:

   ' Create the Overview Element
   dim testElement as EA.Element
   set testElement = currentPackage.Elements.AddNew( "Overview", "Boundary" )   
   'testElement.StyleEx = "Solid"
   testElement.Refresh()
   testElement.Update()
   
   Session.Output( "Created element '" & testElement.Name & "' in package '" & _
      currentPackage.Name & "'" )
      
   ' Add Overview to Diagram
   dim diagramObjects as EA.Collection
   set diagramObjects = currentDiagram.DiagramObjects
   
   dim testDiagramObject as EA.DiagramObject
   set testDiagramObject = diagramObjects.AddNew( "l=552;r=754;t=23;b=82;", "" )
   call testDiagramObject.SetStyleEx("styleex","Solid")

I tryed the SetStyleEx Method and with testElement.StyleEx = "Solid"

I would like to paste 2 Solid Boundaries with different colors in every new diagram I create.
But I don´t know how  :(
Please Help

Pages: [1]