Skip to main content
May 12, 2025 11:22 AM UTC
Question

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

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

4 replies

May 13, 2025 6:50 AM UTC

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.

May 13, 2025 2:42 PM UTC

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

May 14, 2025 11:56 AM UTC

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.