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

Pages: [1] 2
1
Automation Interface, Add-Ins and Tools / Re: Custom Table Script context
« on: February 28, 2020, 05:28:10 am »
Thanks timoc.

Was hoping I could muscle my way to making use of it like how MagicDraw allows the structure of tables that pull information from the model, and then update back to the model when you change the info on the table.

This seems far from it and simply stated seems like it will be limited to non-model data.

2
Automation Interface, Add-Ins and Tools / Re: Custom Table Script context
« on: February 27, 2020, 07:32:50 am »
I'm interested in this as well. The Sparx Custom Table section found on
https://sparxsystems.com/enterprise_architect_user_guide/15.0/model_domains/custom_table_artifact.html
doesn't have anything meaningful written about scripts.

I don't know what scripts to write. Is it the same jscript ones I write in the Scripting window? Will it recognize commands like Repository.SQLQuery()? Am I supposed to shoot for the script to output data in .xml format? Array format?

The help page is entirely unclear about this and basically only mentions something to the effect of, "You can invoke a behavior script."

3
PCS General Board / Cloud Services Error retrieving results: WAIT_TIMEOUT
« on: February 08, 2020, 10:00:19 am »
Hi All,

I get the below errors when I try to do an Import via .xml to an existing model or if I try to Import Storage from RAS. It is the same error for both.
I am using pro cloud express to host the models on a server. We are using AWS RDS and EC2 instances.

For a transfer via RAS it is hung up on -

Importing package: [MyStorageName]
Adding Elements to Diagram: [ADiagramInMyStorage]

with the below error

Sparx Systems Cloud Services [2009]
Error retrieving results: WAIT_TIMEOUT


For the .xml transfer it is hung up on -

Adding connectors to diagram

with the same error

Sparx Systems Cloud Services [2009]
Error retrieving results: WAIT_TIMEOUT

4
Hi All,

I have a script running multiple functions to automate a lot of things among which creation of instances is one of them. I have a SQL Query that specifies the ClassifierIDs from which to create instances. This script works great and all, but I want to add one more level of complexity.

I want to make sure the script doesn't create instances if there is a case that there is an instance with a specified ClassifierID existing already. My function below has inputs of classifierID, stereotype, and name provided from a query in another function. I'm looking for help in figuring out the if statement to check for an existing instance with a classifierID that will be specified by my query.

Code: [Select]
function addInstance(classifierID, stereotype, name)
Dim package
Dim newinstance AS EA.Element
set package = Repository.GetTreeSelectedPackage()
if newinstance.ClassifierID exists for some instance in the model
                      do nothing
                else if
                      do the below things
                end if
' create the new instance element
set newinstance = package.Elements.AddNew("", stereotype)
' assign a classifier element to the new instance element
newinstance.ClassifierID = classifierID
' assign a name to the new instance element
newinstance.Name = name
' update and refresh for the push to happen to EA
newinstance.Update
package.Elements.Refresh
addInstance = newinstance.ElementID

End Function

Appreciate any help! Thanks!

5
Thanks qwerty,

I was getting confused since selecting an element from the drop down "Select Type..." accomplished assigning a ClassifierID and Type on the t_attribute table in the back end. So I had to use the

att.ClassifierID = someelement.ElementID
AND
att.Type = someelement.Name

6
Hello All,

I'm trying to add multiple attributes to a selected object. I am wondering if the Sparx Automation Interface / Object Model allows for the addition of an attribute whose Type is a selected element as one would normally do by selecting "Select Type..." in the Type dropdown menu in the Attributes section of an object. I've got the below script, but I'm trying do understand what I can put in the "Type" field that I've left blank in the code below to reference to a selected element.

Code: [Select]
dim element AS EA.Element
dim pack AS EA.Package
dim att AS EA.Attribute

set pack = Repository.GetTreeSelectedPackage()
set element = pack.Elements.AddNew("TestElm", "Class")
set att = element.Attributes.AddNew("TestAtt", "")
att.Update
element.Attributes.Refresh
pack.Elements.Refresh

Appreciate any guidance!

7
Diagram.Update might be the culprit here.
It might be undoing you new diagram objects.

Have you tried removing that line?

So I removed it and ran the script and curiously enough the diagram does not show up on the project browser. But what I did after is move the diagram.Update before I set the diagramobj and that worked!

That was quite a headscratcher, and I'm not entirely certain why that move was necessary, but I'm glad it works now!

Thanks all for your help!

8
That doesn't seem to be like the missing piece  :-\

9
Hey guys, finally was able to marry up querying and VBScript to flexibly create arrays and reference to them to automate creation of instances. This is nifty and could have many other automation capabilities!

I want to give a big shoutout to Geert for his code here https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Framework/Utils/Util.vbs
There are nice little examples of SQLQuery and VBScript harmonious usage.

I'm still only stuck on why I can't get the diagram object to appear on the new diagram I'm creating according to my script above. Any pointers there? I'd be good for this after!

10
element3.ClassifierID = 2651

it rather shall be.

This still doesn't drop the newly created instance on the newly created diagram though.

11
Hi All,

I managed to at least work on getting a script together to create new "instance" elements and a diagram within a selected package. This is about a 1/4 of the way there. For some reason, despite making a diagram object variable to add the instance element to the new diagram, it won't show up on the diagram. Can someone see what the problem could be here? I've searched this forum for past issues such as this, and Geert has mentioned a cast-discrepancy can cause this, but I'm not certain what this is or how to resolve this. I'm guessing it's something to do with me trying to equalize variable sets EA.DiagramObject and EA.Element

Code: [Select]
Dim element3 as EA.Element
Dim package as EA.Package
Dim diagram as EA.Diagram
Dim diagramobj as EA.DiagramObject

set package = Repository.GetTreeSelectedPackage()

set element3 = package.Elements.AddNew("ActualTestResource", "UAFP::ActualResource")
element3.ClassifierID(2651)
element3.Update

set diagram = package.Diagrams.AddNew("Test", "Class")
set diagramobj = diagram.DiagramObjects.AddNew("", "")

diagramobj.ElementID = element3.ElementID
diagramobj.Update
diagram.Update
diagram.DiagramObjects.Refresh
package.Elements.Refresh
package.Diagrams.Refresh

Once I can get this basic functionality done, I am looking to utilize a SQL Query to call multiple classifier IDs to make multiple "instance" elements to drop them on a diagram. Does anyone have any pointers for this end goal? I am guessing it will have something to do with Repository.SQLQuery which will return an XML string that I will need to parse for classifier IDs. And I will have to run this in a loop.

Am I on the right track here? TYIA

12
Hey everyone, I'm curious whether it's possible to script the creation of diagrams with elements that are Property type objects. I know diagrams can be created with scripting, but curious as to how they could be populated with Property type objects that don't yet exist. The case I am considering is something like this:

Diagram A has a number of <<ResourceArtifact>> elements that create a hierarchy.

Can Diagram B be made such that it is contained simply of the the Property type version of the elements in Diagram A? Diagram B needs no connectors between the Property type objects.

Would this be something of a partitioned approach to scripting? Something where one script creates the Property type elements, and another will then create a diagram to dump them in.

Is this possible? Any related examples anyone can point me to?


13
General Board / Re: Script for making connectors between elements
« on: November 05, 2019, 11:37:36 am »
Thanks everyone for your guidance and assistance. I will be doing some more exploring with how to tie SQL queries and CreateObject function in VBScript to perhaps create two arrays from which to reference Object_IDs to make connectors in large quantities based on array size.

14
General Board / Re: Script for making connectors between elements
« on: November 02, 2019, 10:09:53 am »
The parameter is a STRING containing the query.

q.

Thanks for the reminder. I updated my code as shown below, with quotes around the SQL Query. I still get an error however that says Object doesn't support this property or method: 'Connectors'
Additionally, is there a way to type in anything other than a number for the second parameter of the Repository.GetElementSet(string, number) method? I would like this script to work with differently sized arrays.

Code: [Select]
dim source as EA.Element
dim target as EA.Element
dim conn as EA.Connector

set source = Repository.GetElementSet("SELECT t_object.Object_ID FROM t_object INNER JOIN t_diagramobjects ON t_object.Object_ID = t_diagramobjects.Object_ID WHERE (((t_diagramobjects.Diagram_ID)=14) AND ((t_object.Stereotype)='Risk'))", 2)

set target = Repository.GetElementSet("SELECT t_object.Object_ID FROM t_object INNER JOIN t_diagramobjects ON t_object.Object_ID = t_diagramobjects.Object_ID WHERE (((t_diagramobjects.Diagram_ID)=14) AND ((t_object.Stereotype)='ResourceArtifact'))", 2)

set conn = source.Connectors.AddNew("", "Association")

conn.SupplierID = Repository.GetElementSet("SELECT t_object.Object_ID FROM t_object INNER JOIN t_diagramobjects ON t_object.Object_ID = t_diagramobjects.Object_ID WHERE (((t_diagramobjects.Diagram_ID)=14) AND ((t_object.Stereotype)='ResourceArtifact'))", 2)

conn.Update
source.Connectors.Refresh
target.Connectors.Refresh

15
General Board / Re: Script for making connectors between elements
« on: November 02, 2019, 04:46:18 am »
Thank you both for the help. Went ahead and tried KP's suggestion as it was a minor revision to what I had. And it worked!

What I'm trying to do is add a SQL query into the mix and see if I can add connectors in mass based on the query's specification. So I've tried the following modification utilizing EA's Repository.GetElementSet method. My queries return a list of source Object_IDs and a list of target Object_IDs, between which I want to establish a 1:1 relationship per array row.

For instance:
Query 1 would output
Object 1
Object 2
Object 3

Query 2 would output
Object 4
Object 5
Object 6

And I want to add connectors automatically between Object 1 and Object 4; Object 2 and Object 5; Object 3 and Object 6

I know the below won't execute, any suggestions?

Code: [Select]
dim source as EA.Element
dim target as EA.Element
dim conn as EA.Connector

set source = Repository.GetElementSet(SELECT t_object.Object_ID
FROM t_object INNER JOIN t_diagramobjects ON t_object.Object_ID = t_diagramobjects.Object_ID
WHERE (((t_diagramobjects.Diagram_ID)=14) AND ((t_object.Stereotype)="Risk"));,)

set target = Repository.GetElementSet(SELECT t_object.Object_ID
FROM t_object INNER JOIN t_diagramobjects ON t_object.Object_ID = t_diagramobjects.Object_ID
WHERE (((t_diagramobjects.Diagram_ID)=14) AND ((t_object.Stereotype)="ResourceArtifact"));,)

set conn = source.Connectors.AddNew("", "UAFP::Affects")
conn.SupplierID = Repository.GetElementSet(SELECT t_object.Object_ID
FROM t_object INNER JOIN t_diagramobjects ON t_object.Object_ID = t_diagramobjects.Object_ID
WHERE (((t_diagramobjects.Diagram_ID)=14) AND ((t_object.Stereotype)="ResourceArtifact"));,)

conn.Update
source.Connectors.Refresh
target.Connectors.Refresh

Pages: [1] 2