Skip to main content
7-Bedrock
May 12, 2025
Question

Can someone help in writing code to add action listener on Model Save

  • May 12, 2025
  • 1 reply
  • 755 views

Hello Everyone,

 

I am developing a J-Link tool the requirement is to execute the tool on every save of the model.

 

I have implemented this on session objection performing session.AddActionListener but this is resulting into clearing undo/redo stack into session.

 

Looking for better option to keep the track on undo\redo stack and tool should run on every model save.

 

Thanks in advance

Swapnil

1 reply

21-Topaz I
May 13, 2025

Hi this is a known and general limitation. This applies to Toolkit hence to Java OTK : https://www.ptc.com/en/support/article/CS143895

and not only to listeners but also to the whole API.

7-Bedrock
May 13, 2025

If I skip the session action listeners it maintains the undo/redo stack. As soon I add Action Listener to session it clears the stack. Much appreciated help if someone provide sample code to add model action listener to on after active model save

21-Topaz I
May 14, 2025

Hi,

please find a generic article with a code sample : https://www.ptc.com/en/support/article/CS316823

the code enables to catch the event when creating a parameter.

Have it run first successfully and then iterate it to your likings.

 

//edit the example above is Toolkit. Apologies.

here is an article about Java Object Toolkit (JOTK aka Jlink) code : https://www.ptc.com/en/support/article/CS408439 

look into it and derive from it.