check [Solved] [Archimate] creating elements from scripts

1 year 9 months ago - 1 year 9 months ago #4827 by Iorek
Hi everybody.

I was uncertain on the proper location for this question, here or in the developer/scripts section. I apologise if this is the wrong one.

Now, the question: I'd like to automate some simple tasks in my Archimate model by using a script. I succeed in browsing the model and getting/setting several values, however I don't understand if there is a way to create new instances of elements (e.g. a BusinessActor or a DataObject), which I would need for my purposes.
My problem is that I was assuming to find something equivalent to the "factory" methods in the IUMLModel interface (e.g createClass() ), but I find nothing. Is maybe the approach different? Any hint?

Thanks,
Francesco

Please Log in or Create an account to join the conversation.

1 year 9 months ago #4829 by Iorek
I reply to myself... I finally found the interface IArchimateModelFactory that groups the methods I would need.
But now the problem is:
1. Is the interface useable in Jython?
2. How do I get a reference to it in my script?
Thanks for any help, folks

Please Log in or Create an account to join the conversation.

1 year 9 months ago #4831 by chm
Hi lorek,

there is no ArchiMate factory to use from a module or a script, but it is still possible to use the generic "createElement" method, for example :
# assume elt is a business folder

# create the ArchiMate element
ba = Modelio.getInstance().getModelingSession().getModel().createElement("BusinessActor")
ba.setName("Actor")

# attach the new element to its folder
elt.getContent().add(ba)

Hope this helps,


chm

Please Log in or Create an account to join the conversation.

1 year 9 months ago #4832 by Iorek
Thank you so much, chm. It definitely works!
Now, i'll work on it.

Thanks again,
Francesco

Please Log in or Create an account to join the conversation.

Moderators: tmachmebr
Time to create page: 0.035 seconds
^ Back to Top