Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Improve performance of Visio automation from .net - creating diagram with lots of shapes and shape data

Tags:

.net

com

visio

I have some code which creates potentially lots of shapes and sets shape data to various values. Some shapes might have 5 shape data rows, and some 20 (or various other values).

This is written in VB.Net and I would like to improve performance. Following guidelines here:

http://blogs.msdn.com/b/mailant/archive/2004/09/22/233082.aspx

I have been looking at calls to .DropMany and .SetFormulas.

One issue is that I want to add lots of Shape Data rows - while there exists an .AddShapes call to do multiple rows in one hit, there is no equivalent for shape data section - leaving multiple calls to .AddNamedRow (I have tried calls to AddRows but it gives an error when used with Shape Data section).

Current algorithm:

Work out which masters to use for which shapes (not all the same)
pg.DropMany(with array of masters and appriate X/Y coords)
for each shape dropped:
    for each shape data row (e.g. 5 - 10 times per shape):
        shp.AddNamedRow()
pg.SetFormulas(for all shapes on page and all properties)

Any other suggestions for improving performance?

like image 968
Robert Cowham Avatar asked Jan 30 '26 02:01

Robert Cowham


1 Answers

One thing you might try is to use the ScreenUpdating property on the Visio application object. When set to False, Visio will not update its window until the property is set to True again. I've not used Visio automation before but I have used this with Word and it helps a lot. The trick is to find a good trade-off between speed and frequency of updates-- if you turn off updating for too long, the user might think Visio has crashed.

like image 175
Ken Keenan Avatar answered Feb 01 '26 01:02

Ken Keenan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!