Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: bilon on July 23, 2019, 02:25:37 am
-
Is it possible to create standalone object? I mean object not connected to any model object, created just for the needs of a script.
-
You mean with the API in a script or something like that?
The only way to create a new thing in EA is to use AddNew on the collection of it's owner.
Create a new element: use package.elements.AddNew()
Geert
-
I really meant to create it with the API in the script. I was almost sure it is impossible, but I asked :-) What a pity it's not possible!
-
Out of curiosity: Are you the alter ego of Rich Anderson? Quite funny to see the same (impossible) question pop up almost the same time.
q.
-
You are right, now I see. Interesting, but I'm definitely not Rich Anderson. As I know :-)
-
There might be some esoteric link between the both of you ;-)
q.
-
You can add it via SQL (inserting the suitable data in the t_object table) with a wrong parent_ID
-
You can add it via SQL (inserting the suitable data in the t_object table) with a wrong parent_ID
No. He want's just an in-memory object and not a deserialized one from the database.
q.
-
Yes, that is exactly what I need!
-
bilon - Is the below what you are trying to do?
Below is VBScript, I have not tried anything similar with the other scripting languages.
option explicit
!INC Local Scripts.EAConstants-VBScript
'
' Script Name:
' Author:
' Purpose:
' Date:
'
sub main
dim myObject
set myObject = new MyClass
myObject.Value1 = Repository.ConnectionString
myObject.Value2 = "Hello World!"
Session.Output myObject.Value1
Session.Output myObject.Value2
end sub
'=================================================================
' Define the in memory object
'=================================================================
Class MyClass
private value_1
private value_2
public property get Value1()
Value1 = value_1
end property
public property let Value1(myVal1)
value_1 = myVal1
end property
public property get Value2()
Value2 = value_2
end property
public property let Value2(myVal2)
value_2 = myVal2
end property
End Class
main
-
Something like this, but I want the new objet to be of EA class (for example element) and completely independent on model.
-
Something like this, but I want the new objet to be of EA class (for example element) and completely independent on model.
Maybe you can explain what you are trying to achieve.
I've never needed anything like this, and I've been doing EA development for more than 10 years now.
Geert