Author Topic: Create standalone object?  (Read 8912 times)

bilon

  • EA User
  • **
  • Posts: 85
  • Karma: +0/-0
    • View Profile
Create standalone object?
« 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.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Create standalone object?
« Reply #1 on: July 23, 2019, 02:34:08 pm »
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

bilon

  • EA User
  • **
  • Posts: 85
  • Karma: +0/-0
    • View Profile
Re: Create standalone object?
« Reply #2 on: July 23, 2019, 06:30:20 pm »
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!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Create standalone object?
« Reply #3 on: July 23, 2019, 09:06:24 pm »
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.

bilon

  • EA User
  • **
  • Posts: 85
  • Karma: +0/-0
    • View Profile
Re: Create standalone object?
« Reply #4 on: July 24, 2019, 12:03:28 am »
You are right, now I see. Interesting, but I'm definitely not Rich Anderson. As I know :-)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Create standalone object?
« Reply #5 on: July 24, 2019, 12:48:11 am »
There might be some esoteric link between the both of you ;-)

q.
« Last Edit: July 24, 2019, 11:06:51 pm by qwerty »

Mauricio Moya (Arquesoft)

  • EA User
  • **
  • Posts: 341
  • Karma: +8/-4
  • EA Consulting and development in Spanish
    • View Profile
    • Arquehub Azure Module
Re: Create standalone object?
« Reply #6 on: July 24, 2019, 02:00:31 am »
You can add it via SQL (inserting the suitable data in the t_object table) with a wrong parent_ID

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Create standalone object?
« Reply #7 on: July 24, 2019, 07:18:51 am »
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.

bilon

  • EA User
  • **
  • Posts: 85
  • Karma: +0/-0
    • View Profile
Re: Create standalone object?
« Reply #8 on: July 24, 2019, 09:50:28 pm »
Yes, that is exactly what I need!

smendonc

  • EA User
  • **
  • Posts: 148
  • Karma: +5/-0
  • I love YaBB 1 Gold!
    • View Profile
Re: Create standalone object?
« Reply #9 on: July 25, 2019, 04:14:41 am »
bilon - Is the below what you are trying to do?

Below is VBScript, I have not tried anything similar with the other scripting languages.
Code: [Select]
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

bilon

  • EA User
  • **
  • Posts: 85
  • Karma: +0/-0
    • View Profile
Re: Create standalone object?
« Reply #10 on: July 29, 2019, 07:30:10 pm »
Something like this, but I want the new objet to be of EA class (for example element) and completely independent on model.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Create standalone object?
« Reply #11 on: August 05, 2019, 06:36:01 pm »
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