Speeding up Visio batch job

I

ionpopescu

My C# 2.0 application runs a batch job that involves generating
several Visio document.
I go through a loop that opens a Visio instance, drops a bunch of
shapes and saves the document. The problem is that it is really too
slow, so I was wondering if you could share some tips on speeding it
up. Is there any way to have Visio run "in the background", without
doing all the layout work as my app is dropping shapes on it? what's
the faster way to do this if all you care about are the visio documents
generated by the process and you want to minimze any other process that
might slow visio down?
 
K

Kari Yli-Kuha

ionpopescu said:
My C# 2.0 application runs a batch job that involves generating
several Visio document.
I go through a loop that opens a Visio instance, drops a bunch of
shapes and saves the document. The problem is that it is really too
slow, so I was wondering if you could share some tips on speeding it
up. Is there any way to have Visio run "in the background", without
doing all the layout work as my app is dropping shapes on it? what's
the faster way to do this if all you care about are the visio documents
generated by the process and you want to minimze any other process that
might slow visio down?

We're doing similar operations in a couple of our apps, the difference
is that we're currently doing it using VBA. We are planning on implementing
it using C#/.NET 2.0

A couple of hints:

- you seem to be running a separate process and control the Visio app
from "outside". This is always slower than doing it in the same process
with Visio. You might consider using a "Office Shared Add-in", i.e.
using the IDTExtensibility2 interface.

- if that's not possible, try launching Visio.InvisibleApp instead of
Visio.Application. Also, use the same app for all documents you generate
instead of launching a new Visio app for each drawing.

- in both cases, use DropMany(U) instead of plain Drop - it's much faster

- if all you do is generate drawings, you might consider disabling Visio events
to minimize the event handling overhead. For that:
set Visio.Application.EventsEnabled = false).
Note: remember to re-enable the events after you're done

good luck,
/C
 
C

Chris Roth [MVP]

Other ideas:

Check out application.DeferRecalc property, and also app.UndoEnabled.

You can turn off Undo, so Visio doesn't have to cache any undo operations
and data.

Another idea: Draw with text!

Create Visio documents in Visio-xml format (vdx). This works well if you
know where the shapes need to be placed (ie: you're not depending on Visio's
auto layout)


--
Hope this helps,

Chris Roth
Visio MVP

More Visio shapes, articles, development info and pure diagramming fun at:
www.wanderkind.com/visio
 
P

Paul Herber

- if all you do is generate drawings, you might consider disabling Visio events
to minimize the event handling overhead. For that:
set Visio.Application.EventsEnabled = false).
Note: remember to re-enable the events after you're done

It will depend a great deal on what any event handler does, but I did
some tests recently in one of our applications that creates diagrams
from a text file, the shape added event is enabled for various
purposes but in this mode it was basically just to add a unique ID to
each shape.
Creating a diagram with events disabled was only 1% faster than with
events enabled.
Your application may produce different results though.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top