Book a Demo

Author Topic: Missing properties and Names of elements in instances  (Read 5950 times)

GEJ81SGP

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Missing properties and Names of elements in instances
« on: April 23, 2018, 11:36:58 pm »
Hello community,

I created an Add-In, that can sort and structure ports and labels.
It is all working perfectly fine if I use the scripts on a class. But as soon as I use it on an instance there are errors.

I just found out that when initializing an instances there is lots of information lost.
For example the Style property of the DiagramObject of the class looks like this in the class:

    Style: "HideIcon=0;DUID=B70E5936;LBL=CX=67:CY=13:OX=20:OY=1:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:ALT=0:ROT=0;"

In the instance it contains just this information:

    Style: " DUID=D944900E;"

Furthermore, non of the ports on an instance have a name anymore, what is really annoying! Therefore, they have a prefix of the <<Stereotype>> in the label.
And if I add a port to the instance via "Rightclick" -> "Structural Elements.." EA does not recognize its Stereotype automatically, but I have to change it manually every single time.

I know its a lot of questions, but somehow I think they are all related to each other.

Does someone of you know, why there is all the infomation lost when creating an instance of a class?
Or maybe someone can even suggest a workaround?

I would be really glad for help, thanks very much in previous! :)

Nizam

  • Prolab Moderator
  • EA User
  • *
  • Posts: 320
  • Karma: +15/-2
  • Model Sharing - Simplified
    • View Profile
    • Professional Model Collaboration
Re: Missing properties and Names of elements in instances
« Reply #1 on: April 24, 2018, 09:28:30 am »
I'm not sure if I can answer all your queries, but please bear in mind that the instances of a class do not have any 'Name' property set, only its classifiername is shown in the diagram, you have to name them manually

GEJ81SGP

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Missing properties and Names of elements in instances
« Reply #2 on: April 24, 2018, 06:51:04 pm »
Hi,

thank you for your fast answer! I attached an image to this post, that shows exactly the issue. Like you said there is no name for the ports in the instance. In my case thats a problem, as I want to sort those ports alphabetically with my script. Maybe you know a possibility or a workaround how I could automatically give them the name of text in the label?
I hope I was able to make it a bit clearer what I try to achieve.


https://www.imagebanana.com/s/1037/eJd30mfN.html

Thank you very much.
« Last Edit: April 24, 2018, 06:53:24 pm by GEJ81SGP »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Missing properties and Names of elements in instances
« Reply #3 on: April 24, 2018, 08:48:10 pm »
You can look at the port instance's classifier and extract the name for your sorting.

q.

P.S. The classifier is stored in t_object.PDATA3 as guid (should be MiscData[2])
« Last Edit: April 24, 2018, 08:52:49 pm by qwerty »

GEJ81SGP

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Missing properties and Names of elements in instances
« Reply #4 on: April 25, 2018, 12:04:40 am »
Thanks very much guys!

I was able to solve it now with your help. I used the ClassifierIDs to get the names from the original ports on the class.

So there is just the issue with the label parameters left.

Maybe you do also have a solution on how I can get the position of a label on a instance?
Within the class, the information is given in the style: LBL=CX=67:CY=13:OX=20:OY=1
If I look for the same information on an instance its just: " DUID=D944900E;"

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Missing properties and Names of elements in instances
« Reply #5 on: April 25, 2018, 01:19:10 am »
The diagram position is at the very same place for the instance. It's just that you need to save the diagram before you can retrieve the position.

q.

GEJ81SGP

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Missing properties and Names of elements in instances
« Reply #6 on: April 27, 2018, 10:11:05 pm »
Well, thank you very much! That sounds logical to me.

But if I save the diagram first by using Repository.SaveDiagram(long DiagramID), it is still not showing me the information for the label. Do I have to use some other code for saving?
I also tried .SaveAllDiagrams(), .ReloadDiagram(), and .Update(); but its still not showing me the information Im looking for.


qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Missing properties and Names of elements in instances
« Reply #7 on: April 27, 2018, 11:32:52 pm »
Can you post a code snippet of what you're doing, please?

q.

GEJ81SGP

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Missing properties and Names of elements in instances
« Reply #8 on: May 02, 2018, 06:14:46 pm »
Thanks qwerty! It was my fault that it did not save, because I changed something in the settings from my addin.

Now its working perfectly fine just by saving it first. Thanks a lot guys!