Author Topic: Visio in-memory model and current diagram on page state  (Read 94 times)

0 Members and 1 Guest are viewing this topic.


  • Full Member
  • ***
  • Posts: 174
Visio in-memory model and current diagram on page state
« on: September 24, 2020, 04:27:07 AM »
While I must say that Visio VBA code can be optimized quite a lot for performance, a 500-1000 group shape diagram now performs quite well, I am worried about performance for the next step.

As I start thinking about the move to a Visio add-in (why a Visio add-in? not all customers want a VBA macro-based solution unfortunately) I read the horror stories about the potential for terrible performance with an Office VSTO add-in.

The key problem? Every time a user performs a significant action on the diagram, I use a combination of the ConnectedShapes()/GluedShapes() methods, and I ‘read through the diagram’ via its connections to rebuild an in-memory model. I do this rebuild-every-time to make sure the in-memory model I use is in sync with the current diagram on the page, and actually this now performs quite well even on an older Core i5 notebook.

With the add-in I am thinking maybe move to a solution where I do not rebuild every time but I will use event listening to make sure everything that happens on the page is caught and the add-in updates the in-memory model to keep it in sync.

Rebuilding requires a ton of calling ConnectedShapes and GluedShapes which I understand can lead to terrible performance doing this from an add-in, so better to update changes rather than rebuild every time.

Of course if a user’s laptop crashes the in-memory model has to be rebuilt, but this is easy to catch (the in-memory model is empty after a restart after all).

My question is: is it safe and can an add-in catch all relevant events or are there some ‘leak’ scenarios where a user changes something in the diagram yet the add-in is not notified even though it is listening to the relevant events?

Thank you for sharing your insights on this, important to make choices based on experience with how a specific solution architecture (a Visio VSTO add-in) actually works and the potential issues that have been identified by experienced developers!

« Last Edit: September 24, 2020, 04:29:34 AM by Visisthebest »