Book a Demo

Author Topic: show newly created ports of a propertytype on a property  (Read 4174 times)

matlan

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
show newly created ports of a propertytype on a property
« on: January 31, 2020, 07:16:39 pm »
Hi

I'm trying to use EA not only for sysml, but also for electronic schemas.
I want to use connectorproperties as cables with an assigned propertytype. the propertytype is a block, with an internal blockdiagram for cable assignment.

I'm want to assign a undefined cable (property) to a new propertytype and move existing ports on the property to the propertytype. This all works properly.

But after migrating the ports to the propertytype, i want the diagram to show the inherited ports of the propertytype instead the old ones from the property for consistency. deleting the old ports from the diagram works, but showing the inherited ones seems tricky.

I tried this and nothing happened, no error, no port:

dia_obj = diagram.DiagramObjects.AddNew ("", "");
dia_obj.ElementID = propertyTypePort.ElementID;
dia_obj.Update ();
Repository.ReloadDiagram (diagram.DiagramID);

Any ideas on how to show the inherited port on the diagram representation?
« Last Edit: January 31, 2020, 08:23:14 pm by matlan »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: show newly created ports of a propertytype on a property
« Reply #1 on: January 31, 2020, 08:24:33 pm »
You need to supply to position like
Code: [Select]
dia_obj = diagram.DiagramObjects.AddNew ("l=10;r=110;t=-20;b=-80", "");
dia_obj.ElementID = element.ElementID;
dia_obj.Update ();
Repository.ReloadDiagram (diagram.DiagramID);

q.

matlan

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: show newly created ports of a propertytype on a property
« Reply #2 on: January 31, 2020, 11:38:53 pm »
Thanks for your support!

Already tried and didnt work either...

I'm trying to isolate the problem. At the moment i just want to show all inherited ports on a property using this function.
Code: [Select]
internal static void ShowAllPorts()
        {
            EA.Element selectedElement = EAHelper.ActiveModel.GetElementByID(((EA.DiagramObject)currentDiagram.SelectedObjects.GetAt(0)).ElementID);
            EA.Element propertyType = EAHelper.ActiveModel.GetElementByID(selectedElement.PropertyType);
            foreach(EA.Element myPort in propertyType.EmbeddedElements)
            {
                ObjectBoundarys objectBoundarys = new ObjectBoundarys(currentDiagram.SelectedObjects.GetAt(0));
                EA.DiagramObject newPortRepresentation = currentDiagram.DiagramObjects.AddNew(objectBoundarys.getPortPosition(), "");
                newPortRepresentation.ElementID = myPort.ElementID;
                newPortRepresentation.Update();
            }
            EAHelper.ActiveModel.ReloadDiagram(currentDiagram.DiagramID);
        }

objectBoundarys.getPortPosition() returns "l=220;r=236;t=-497;b=-513"
property position is: l=228 r=353 t=-497 b=-537

Updating fails with error code -2147221504, 0xFFFFFFFF80040000

//edit: after cleanup of the db there is no failure when updating, but it still doesnt work...
Cleanup reports: Embedded Element With No Parent On Diagram

I didnt see any Parent field on the DiagramObject...

Any thoughts?
« Last Edit: February 01, 2020, 12:11:33 am by matlan »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: show newly created ports of a propertytype on a property
« Reply #3 on: February 01, 2020, 12:33:29 am »
There has been an issue with embedded elements being created via automation. Which version have you got?

q.

matlan

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: show newly created ports of a propertytype on a property
« Reply #4 on: February 01, 2020, 12:36:12 am »
15.0.1513 Ultimate

Just updated to the most recent version, didnt help...
« Last Edit: February 01, 2020, 01:33:28 am by matlan »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: show newly created ports of a propertytype on a property
« Reply #5 on: February 01, 2020, 02:53:12 am »
No Element Parent means: you have to first place the parent on the diagram and make sure it's there. Only then you can create the embedded element. So do it step by step. Try first to just create the parent. Once that works, try adding the embedded element.

q.

matlan

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: show newly created ports of a propertytype on a property
« Reply #6 on: February 03, 2020, 08:06:45 pm »
What i'm doing is assigning a propertytype (Block that owns ports) to a connectorproperty.

After that i want the connectorproperty (on a internal block diagram) to show the ports inherited of its propertytype. From the UI this is doable selecting the inherited port of the propertytype in the interactionpoints overview (features etc.)

So, parent is there, somehow... its propertytype owns these ports.

I'm still looking for a way to do this programmatically.

I've already tried to add a port to the connectorproperty and assign the ElementID of the port on the propertytype but that failed.
Assigning the target port to classifierId works, but isnt what i need.

BTW thanks for your effort helping me with this issue.

BR Mathias
« Last Edit: February 03, 2020, 08:21:04 pm by matlan »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: show newly created ports of a propertytype on a property
« Reply #7 on: February 04, 2020, 03:28:42 am »
Hmm. I just tried my own example under V13.5 and it did no longer work. Maybe it's me (got a cold and my brain is numb). But I would not wonder if Sparx messed this up again :-/ Will investigate further...

q.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: show newly created ports of a propertytype on a property
« Reply #8 on: February 04, 2020, 03:43:22 am »
Found it. The culprit sits Down Under.

I just ran my script to create a port. It did not show up (only the embedding element), although I made a diagram reload. But then closing and re-opening made the port show too.

Feel free to report a bug. Pretty sure you get a reply like "this is by design".

q.