Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Best way to generate a diagram programatically

621 views
Skip to first unread message

sh856531

unread,
Dec 19, 2008, 4:23:01 AM12/19/08
to
Hi Guys,

We have a need to programmatically create Visio diagrams using either Visio
2003 or 2007 (not sure which yet).

The idea will be to process a directory with a number of XML files and
create a diagram based on the contents of each file.

Can anyone tell me the best way to achieve this at a high level. If at all
possible I'd like to use C#.

I've looked at the XML format for visio with a view to just generating an
appropriate XML document on the fly. Problem was the XML format scared the
cack out of me. In fact, I think it scared the cack of Visual Studio as well
as it refused to even autoformat it so now the entire documents appears on 3
really long lines. And thats just with one rectangle!

I'm wondering if it is possible to use an API to create and connect shapes
but I don't know if thats possible on a server. Would that approach actually
open up lots of Visio instances as I process the files?

Huge thanks to anyone who could offer some suggestions on how to approach
this!

Best Regards

Simon

AlEdlund

unread,
Dec 19, 2008, 8:45:29 AM12/19/08
to
Let's take this in order.
a.) I'd start with v2007, no sense at all in going back and v2007
professional has a lot of data features
b.) the visio sdk has numerous examples using C# of creating drawings
c.) Chris Roth did some presentations/videos on Visio XML at the
DevConference and they are on his site (www.visguy.com)
d.) unlike Visio's Office cousins, Visio only opens one instance of the
application at a time.

al

"sh856531" <sh85...@discussions.microsoft.com> wrote in message
news:4DCC8A7C-95DD-483B...@microsoft.com...

Nikolay Belyh

unread,
Dec 19, 2008, 9:56:30 AM12/19/08
to
> d.) unlike Visio's Office cousins, Visio only opens one instance of the
> application at a time.

Al, are you sure about that...? Probably I miss something here...
Means, I can easily start two (or more) Visio processses (instances),
e.g. with CreateObject()... Thus I think I can have more than one
Visio instance at a time. I thought that the "single-instance" is the
"feature" of the Outlook only...

Probably, you mean that several Visio drawing controls share the same
Visio application?

Kind regards, Nikolay.

AlEdlund

unread,
Dec 19, 2008, 10:24:44 AM12/19/08
to
Nikolay,
You are correct. I use the drawing control so much, some times I forget.
Happy holidays and thanks,
al

"Nikolay Belyh" <nbe...@gmail.com> wrote in message
news:cba0fb9e-bc9a-44b8...@g3g2000pre.googlegroups.com...

Nikolay Belyh

unread,
Dec 19, 2008, 10:57:41 AM12/19/08
to
Al, I've got it... Happy holidays to you too :-)

BTW, about the original question on Visio "server" usage... - there is
a following "enlightening" article that might be also useful for you,
Simon...
http://support.microsoft.com/kb/257757

Kind regards, Nikolay.

AlEdlund

unread,
Dec 19, 2008, 11:18:28 AM12/19/08
to
Nikolay,
I am aware of that one. The good news is that with the release of office
sharepoint the excel restriction has been removed (excel services). Another
example of how office is moving towards server based solutions is the
project server implementation. It's because of this trend that my own
development has been moving away from addins to activex solutions (hopefully
the code will work both on a workstation and any future solutions that may
come down the line).
al

"Nikolay Belyh" <nbe...@gmail.com> wrote in message

news:93851386-e145-47aa...@r15g2000prh.googlegroups.com...

sh856531

unread,
Dec 19, 2008, 12:17:04 PM12/19/08
to
Hi Guys,

I really appreciate you taking the time to answer - thank you both.

I was wondering, what is the general perception of using Visio on the server
these days. My gut reaction is that I shouldn't do it, but if its the only
way and is reasonably well documented, if not encouraged, then I'm tempted to
give it a go.

Have you guys used the XML format to actually try and manipulate shapes? I
think its great that MS are doing it but the XML that I saw was
indescriminately *nuts*. I've never had an xml document that Visual Studio
and Oxygen would refuse to format. The best I managed to get was wordwrap!
And that was with just one square on a standard document!

:-|

Thanks again!

Simon

AlEdlund

unread,
Dec 19, 2008, 12:54:49 PM12/19/08
to
For XML I really prefer the Altova XMLSPY product when investigating how
something is put together. Visio actually uses some XML under the covers
(checkout solutionXML). SVG of course is very similar and some of the guys
have been working with WPF/Silverlight.

On the server side, I use sharepoint so all of the drawings are handled
locally. As Nikolay pointed out Server side execution of workstation
products is strongly discouraged.

al

"sh856531" <sh85...@discussions.microsoft.com> wrote in message

news:A41E931F-AC61-492B...@microsoft.com...

sh856531

unread,
Dec 19, 2008, 1:26:23 PM12/19/08
to
Hi Al,

It kinda seems to me like Microsoft have been missing a trick for a long
long time.

Switching to XML is all well and good but the Visio XML looks far to
complicated to be (easily) used. If MS were to create an API over the top of
the XML so you just had to create object hierarchies it would be so much
better.

I really don't know why MS hasnt fixed the server side issue. They've made
such a huge investment is creating the office applications and underlying
APIs that I can't for the life of me created version of each product that can
generate documents server side. They have a lot of the APIs there already -
they just need to be extracted and then they could make a packet selling
middleware licenses so that people can create office documents
programmatically on the fly.

I never did understand why they haven't done that yet. They could make an
awful lot of money if they did so I would think

Best Regards

Simon

Nikolay Belyh

unread,
Dec 19, 2008, 1:55:59 PM12/19/08
to
> Nikolay,
> I am aware of that one.

Al, that link was not for you... That was for Simon. ;-)

Kind regards.

Nikolay Belyh

unread,
Dec 19, 2008, 4:12:08 PM12/19/08
to
>
> Have you guys used the XML format to actually try and manipulate shapes? I
> think its great that MS are doing it but the XML that I saw was
> indescriminately *nuts*. I've never had an xml document that Visual Studio
> and Oxygen would refuse to format. The best I managed to get was wordwrap!
> And that was with just one square on a standard document!
>
> :-|
>

Hi Simon,

"Life sucks when you live, and then you die. And life still
sucks" :-)
(c) Dead Like Me. Very inspiring movie, by the way.

If you ask me, then, personally, I have only heard about Chris Roth
doing cool stuff with Visio XML generation (on that presentation, in
particular..) But unfortunately I have never seen this kind of things
(generation of visio xml) happening in the real life... So for me this
is basically like UFO story :-). I suppose that mere developers (like
me) might be just lazy enough to dig into XML... Though "most
attributes are optional" when you generate an XML Visio drawing (which
is true of course), IMO there are still enough of them to drive you
nuts. And that creepy XML syntax does not add any fun as well.
But what actually drove *me* nuts was a (naive) attempt to generate an
SVG out of arbitrary Visio diagram *without* Visio. This is IMO where
the "happy hardcore" lives. BTW, more about "happy hardcore" - it is
kinda music style, actually - http://www.youtube.com/watch?v=2vvdBqgWpFk
:-)

Back to the point, I think you will be able to work with a Visio XML
file in Visual Studio XML editor, when you:

1. Remove the preview picture and all other "unused stuff".
File -> Remove Unused Information -> Check all you see there, then
save as XML

2. Open the XML in Visual studio (still 2 lines)

3. Remove the xml:space='preserve' from the root element (this
attribute prevents Visual Studio from auto-formatting the document).
Now Visual Studio shall be able to format document properly.

And, in general, I am rather optimistic about Visio XML generation and
I think that it is totally possible. For example, here is your
"square" (minimalistic):
------
<?xml version='1.0' encoding='utf-8' ?>
<VisioDocument
xmlns='http://schemas.microsoft.com/visio/2003/core'
version='12.0' >
<Pages>
<Page ID='0' NameU='Page-1'>
<Shapes>
<Shape ID='1' Type='Shape'>
<XForm>
<PinX>5</PinX>
<PinY>5</PinY>
<Width>2</Width>
<Height>2</Height>
</XForm>
<Geom IX='0'>
<MoveTo IX='1'>
<X F='Width*0' />
<Y F='Height*0' />
</MoveTo>
<LineTo IX='2'>
<X F='Width*1' />
<Y F='Height*0' />
</LineTo>
<LineTo IX='3'>
<X F='Width*1' />
<Y F='Height*1'/>
</LineTo>
<LineTo IX='4'>
<X F='Width*0' />
<Y F='Height*1' />
</LineTo>
<LineTo IX='5'>
<X F='Geometry1.X1' />
<Y F='Geometry1.Y1'/>
</LineTo>
</Geom>
</Shape>
</Shapes>
</Page>
</Pages>
</VisioDocument>
-----

One more thing. It is well known, that the first mistake in a software
design is "solving the wrong problem" (c) :-). So probably if you tell
us more about the "business" task you are solving (What are these XML
files you are going to convert into drawings? Where are they coming
from? What do they mean? What do you want to do with drawings? etc...)
then probably someone will be able to help you at the "next level of
abstraction" :-)

Kind regards, Nikolay

colinm...@live.co.uk

unread,
Dec 23, 2008, 11:39:25 AM12/23/08
to
If your trying to navigate through the Visio file structure then its
useful to have some kind of XML Schema editor/viewer like Liquid XML
Studio (which is free)
http://www.liquid-technologies.com/XmlStudio/XmlStudio.aspx

Also there is a load of online documentation for the visio schemas
here, which should make life easier!
http://schemas.liquid-technologies.com/Office/2003/VisioDocument.html

Cheers Colin


On 19 Dec, 21:12, Nikolay Belyh <nbe...@gmail.com> wrote:
> > Have you guys used theXMLformat to actually try and manipulate shapes? I
> > think its great that MS are doing it but theXMLthat I saw was
> > indescriminately *nuts*. I've never had anxmldocument that Visual Studio


> > and Oxygen would refuse to format. The best I managed to get was wordwrap!
> > And that was with just one square on a standard document!
>
> > :-|
>
> Hi Simon,
>
> "Life sucks when you live, and then you die. And life still
> sucks"  :-)
> (c) Dead Like Me. Very inspiring movie, by the way.
>
> If you ask me, then, personally, I have only heard about Chris Roth

> doing cool stuff with VisioXMLgeneration (on that presentation, in


> particular..) But unfortunately I have never seen this kind of things

> (generation of visioxml) happening in the real life... So for me this


> is basically like UFO story :-). I suppose that mere developers (like

> me) might be just lazy enough to dig intoXML... Though "most
> attributes are optional" when you generate anXMLVisio drawing (which


> is true of course), IMO there are  still enough of them to drive you

> nuts. And that creepyXMLsyntax does not add any fun as well.


> But what actually drove *me* nuts was a (naive) attempt to generate an
> SVG out of arbitrary Visio diagram *without* Visio. This is IMO where
> the "happy hardcore" lives. BTW, more about "happy hardcore" - it is

> kinda music style, actually -http://www.youtube.com/watch?v=2vvdBqgWpFk


> :-)
>
> Back to the point, I think you will be able to work with a VisioXML

> file in Visual StudioXMLeditor, when you:


>
> 1. Remove the preview picture and all other "unused stuff".
> File -> Remove Unused Information -> Check all you see there, then
> save asXML
>

> 2. Open theXMLin Visual studio (still 2 lines)
>
> 3. Remove thexml:space='preserve' from the root element (this


> attribute prevents Visual Studio from auto-formatting the document).
> Now Visual Studio shall be able to format document properly.
>

> And, in general, I am rather optimistic about VisioXMLgeneration and


> I think that it is totally possible. For example, here is your
> "square" (minimalistic):
> ------

> <?xmlversion='1.0' encoding='utf-8' ?>

Guy..L

unread,
Jan 2, 2009, 3:12:01 AM1/2/09
to
Have you seen this article?

http://www.design-drawing.com/visio/rgavt4.htm

Generate visio shapes from text...

Paul Herber

unread,
Jan 2, 2009, 5:12:59 AM1/2/09
to
On Fri, 2 Jan 2009 00:12:01 -0800, Guy..L
<Gu...@discussions.microsoft.com> wrote:

>Have you seen this article?
>
>http://www.design-drawing.com/visio/rgavt4.htm
>
>Generate visio shapes from text...

One of the features discontinued as from Visio 2003.


--
Regards, Paul Herber, Sandrila Ltd.
Electrical for Visio http://www.electrical.sandrila.co.uk/

Guy..L

unread,
Jan 4, 2009, 3:54:06 AM1/4/09
to
I liked the simplicity of this text solution. It shows the link capability.
I'm sure <link/> is in the XML spec. Plus it wouldn't be too hard to
resurrect that text command structure for specific application much as I
intend and perhaps the original question posed.

Somehow all that XML handling code seems like overkill.

Regards also,
Guy..Lister
CSI

Paul Herber

unread,
Jan 5, 2009, 8:09:04 AM1/5/09
to
On Sun, 4 Jan 2009 00:54:06 -0800, Guy..L
<Gu...@discussions.microsoft.com> wrote:

>I liked the simplicity of this text solution. It shows the link capability.
>I'm sure <link/> is in the XML spec. Plus it wouldn't be too hard to
>resurrect that text command structure for specific application much as I
>intend and perhaps the original question posed.
>
>Somehow all that XML handling code seems like overkill.

I might have a go at recreating a CSV input utility. I suspect it
wouldn't be difficult, I already have applications that can import
SDL-CIF and MSCgen into Visio, CSV is a cinch in comparison. But would
anyone pay for such a utility - I doubt it.

CSV format will only be ASCII compatible, no unicode so nothing other
than English language (and maybe some other western European
languages).
Maybe that was why it was dropped, non-maintainable for other
languages.


--
Regards, Paul Herber, Sandrila Ltd.

Visio Utilities http://www.visio-utilities.sandrila.co.uk/

0 new messages