# IDs of Model Elements

**URL:** <https://forums.visual-paradigm.com/t/ids-of-model-elements/16093>\
**Category:** Plug-in & Open API\
**Tags:** code-engineering\
**Created:** [May 21, 2020, 3:59am UTC](https://forums.visual-paradigm.com/t/ids-of-model-elements/16093 "2020-05-21T03:59:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lalitnagpal](https://avatars.discourse-cdn.com/v2/letter/l/c6cbf5/32.png) [@lalitnagpal](https://forums.visual-paradigm.com/u/lalitnagpal)\
**Post date:** [May 21, 2020, 3:59am UTC](https://forums.visual-paradigm.com/t/ids-of-model-elements/16093/1 "2020-05-21T03:59:28Z")

</div>

Query 1 - When I create the model elements ( Application Components ) in a ArchiMate diagram using the Open API, I want the components to have the ids that Open API code supplies rather than auto generated ids. Is there any setting where I can specify the id is to be picked up from one supplied via Open API code and only if the one supplied is null or blank then VP to auto generate it.

```
IArchiMateApplicationComponent appComponent = IModelElementFactory.instance().createArchiMateApplicationComponent();

appComponent.setUserID("123456789") 
appComponent.setName("Some Name")
appComponent.setDescription("Some Description")

IArchiMateApplicationComponentUIModel shapeArchiComponent = (IArchiMateApplicationComponentUIModel) diagramManager.createDiagramElement(archiMate, appComponent);
shapeArchiComponent.setSize(200, 80);
shapeArchiComponent.resetCaption();

archiMateDiagram.addDiagramElement( shapeArchiComponent );

```

My ids are getting picked up sometimes ( when I start with a complete new project for example ) and sometimes its giving them auto generated ids. I am adding the components in a local project, so there are no duplicates here right now.

Query 2 - Another query is how do I pick up the logged in VP user name via Open API

Query 3 - How do I programmatically give a Organic Layout to the diagram via Open API

Many thanks for the help.

---

<div class="post-metadata">

**Author:** ![peter.wong](https://forums.visual-paradigm.com/user_avatar/forums.visual-paradigm.com/peter.wong/32/3250_2.png) [@peter.wong](https://forums.visual-paradigm.com/u/peter.wong)\
**Post date:** [May 21, 2020, 9:38am UTC](https://forums.visual-paradigm.com/t/ids-of-model-elements/16093/2 "2020-05-21T09:38:43Z")

</div>

Query 1:  
ModelElement has 2 id properties: `id` and `userID`

- `id` is not editable
- `userID` is editable. You may enter your userID as your above `appComponent.setUserID("123456789")`.

But, by default, Application Component won’t support userID.  
You need to enable it via Project Options, as following:

 ![ID-001](https://forums.visual-paradigm.com/uploads/default/original/2X/6/62464e31a1619584d885f2e9d8a6f947aa916740.png)

Query 2:  
It is newly supported in these few weeks, please reference to following post:

> [@How to get teamwork user name?](https://forums.visual-paradigm.com/t/how-to-get-teamwork-user-name/16063):
>
> Hi guys Is it possible to get username (Email) of the logged user into teamwork in the instance of vp that my plugin is running ?

Query 3:  
You may call:  
`DiagramManager.layout(diagram, DiagramManager.LAYOUT_ORGANIC)`

---

<div class="post-metadata">

**Author:** ![lalitnagpal](https://avatars.discourse-cdn.com/v2/letter/l/c6cbf5/32.png) [@lalitnagpal](https://forums.visual-paradigm.com/u/lalitnagpal)\
**Post date:** [May 21, 2020, 10:26am UTC](https://forums.visual-paradigm.com/t/ids-of-model-elements/16093/3 "2020-05-21T10:26:01Z")

</div>

I don’t see these in the version Version 16.1 (Build 20200430bi) - although they seem to have been introduced in 2019 as per the thread

```auto
ApplicationManager.instance().isLoggedIn()
ApplicationManager.instance().getLoggedInUserName() // return the name
ApplicationManager.instance().getLoggedInEmail() // return the email

```

---

<div class="post-metadata">

**Author:** ![peter.wong](https://forums.visual-paradigm.com/user_avatar/forums.visual-paradigm.com/peter.wong/32/3250_2.png) [@peter.wong](https://forums.visual-paradigm.com/u/peter.wong)\
**Post date:** [May 22, 2020, 3:27am UTC](https://forums.visual-paradigm.com/t/ids-of-model-elements/16093/4 "2020-05-22T03:27:01Z")

</div>

about Query 2,  
Please update the software to latest patch build (20190530ap or later) to get the enhancement.
