Book a Demo

Author Topic: OnPostNewElement event & SysML IBD sync elements  (Read 6649 times)

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
OnPostNewElement event & SysML IBD sync elements
« on: February 01, 2018, 01:34:59 am »
Hi,

I'm trying to apply auto updates on a SysML IBD diagram when running the Synchronize Structural Elements, where EA creates new parts according to the BDD definition.
The only broadcast event I catch is EA_OnPreNewElement. However I need the Element ID to update via the OnPostNewElement or OnPostNewDiagramObject event.

Any reason why I'm not getting these events?


Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Nabil

  • EA User
  • **
  • Posts: 149
  • Karma: +5/-2
    • View Profile
    • View My LinkedIn Profile Here
Re: OnPostNewElement event & SysML IBD sync elements
« Reply #1 on: February 01, 2018, 02:26:49 am »
you can get elementID from Info.Get("ElementID")

Nabil
Nabil

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: OnPostNewElement event & SysML IBD sync elements
« Reply #2 on: February 01, 2018, 02:48:09 am »
That's not available with the EA_OnPreNewElement event (since the element is not created at this stage), hence my issue of not being able to catch OnPostNewElement or OnPostNewDiagramObject.
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Arshad

  • EA User
  • **
  • Posts: 291
  • Karma: +21/-1
    • View Profile
Re: OnPostNewElement event & SysML IBD sync elements
« Reply #3 on: February 01, 2018, 04:57:33 am »
Hi Guillaume

Please check whether you returned True in the EA_OnPreNewElement.
Element will be created only if you return True.

After the creation of element EA_OnPostNewElement will be triggered.
In EA_OnPostNewElement you can get the ElementId.

NOTE: Both the event will be triggered only if you create an element on a diagram (Drag drop from tool box to diagram)

Please refer http://www.sparxsystems.com/enterprise_architect_user_guide/9.2/automation/broadcastprenewelement.html
and http://www.sparxsystems.com/enterprise_architect_user_guide/9.2/automation/broadcastpostnewelement.html


HTH
Arshad
« Last Edit: February 01, 2018, 03:24:22 pm by Arshad »

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: OnPostNewElement event & SysML IBD sync elements
« Reply #4 on: February 01, 2018, 05:29:45 pm »
Hi Arshad,

Thank you for your reply. I missed the return value from Sparx API doc.
Please note that I'm using ea-matic.

To see the caught events, I started adding the following to the ea-matic function. I tried to return true in the PreNewElement but that didn't work (I also tried with Set EA_OnPreNewElement = true).


function EA_OnPostNewElement(Info)
   Repository.WriteOutput "Script", now() & " EA_OnPostNewElement " ,0   
end function

function EA_OnPostNewDiagramObject(Info)
   Repository.WriteOutput "Script", now() & " EA_OnPostNewDiagramObject  " ,0   
end function

function EA_OnPreNewDiagramObject(Info)
   Repository.WriteOutput "Script", now() & " EA_OnPreNewDiagramObject  "  ,0   
end function

function EA_OnPreNewElement(Info)
   Repository.WriteOutput "Script", now() & " EA_OnPreNewElement  " ,0   
   EA_OnPreNewElement = true
end function
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Arshad

  • EA User
  • **
  • Posts: 291
  • Karma: +21/-1
    • View Profile
Re: OnPostNewElement event & SysML IBD sync elements
« Reply #5 on: February 01, 2018, 06:26:26 pm »
Hi Guillaume

Are you sure your'e creating new elements on a diagram from toolbox by drag and drop ?  ???

I just tried below code and its working fine for me.
Code: [Select]
function EA_OnPostNewElement(Info)
    MsgBox("POS")
end function
function EA_OnPreNewElement(Info)
MsgBox("PRE")
end function


« Last Edit: February 01, 2018, 06:32:51 pm by Arshad »

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: OnPostNewElement event & SysML IBD sync elements
« Reply #6 on: February 01, 2018, 08:33:49 pm »
No, my intent is to trigger the script when running the "Synchronize Structural Elements" from a SysML Internal Block Diagram.
This feature creates new SysML parts elements according to the BDD definition i.e. Blocks associated via a composite or aggregation link to the main Block (e.g. our system).

So I have a feeling that despite the Sync Struct. Element creates elements in the model, it does not broadcast the OnPostNewElement event (only the OnPreNew).
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Arshad

  • EA User
  • **
  • Posts: 291
  • Karma: +21/-1
    • View Profile
Re: OnPostNewElement event & SysML IBD sync elements
« Reply #7 on: February 01, 2018, 08:50:33 pm »
Yes it won't trigger PostNew events .Will trigger only if a new element has been created on a diagram. :(

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: OnPostNewElement event & SysML IBD sync elements
« Reply #8 on: February 05, 2018, 06:47:43 pm »
I'll submit a feature request to Sparx.
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com