Looking for a visual representation of the Visio COM

Started by PF4VisioGuy, September 01, 2018, 01:28:13 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

PF4VisioGuy

Hi guys

I am looking for something like this.
If you know of a better and more complete one could you please post a link?


PF4VisioGuy

I have also found this. Is it still valid ? How much is it missing ? The date on the page is 2014 although the doc is 2002

https://docs.microsoft.com/en-us/previous-versions/office/developer/office-xp/aa188224(v%3doffice.10)


PF4VisioGuy

For whoever is interested in getting a quick overview of classes and how they relate to each other, what properties and so on open the vba editor for your visio and then righ click in the text window and select Object Browser ...

PF4VisioGuy

The VBA object browser, definitions etc are very useful if you come from the Python side
The Python COM calls via Win32 lack the Visio defined constants ex for selecting the row, column in the shape sheet

Nikolay

Well, here we go..
It looks like now you start understanding some of the precautions against python :)

There is no autocomplete for Visio for Python! Isn't that fatal enough in the year 2018?

BTW, how does one define intellisense rules for VS Code for example?
Maybe it's possible to export VBA type library and create a definitions file for python?

PF4VisioGuy

You must understand that I have a couple of tens of lines of win32com code to make the graph but I have a couple of thousands of line of Python code to collect the data I am mapping with Visio hence the need to integrate in Python
What you said it is a good idea but I don't think that I need all of them
Besides that I can use the VBA IDE to get the code I need (actually I am lazy and I use the macro recorder) and then I copy that and replace the constants with numbers in Python so I do take advantage of the VBA IDE autocompletion in an indirect way :-)

Nikolay

QuoteThe Python COM calls via Win32 lack the Visio defined constants ex for selecting the row, column in the shape sheet

The constants part can be done, you don't really need to define them:


import sys
import win32com.client
from win32com.client import constants as c  # <----- import constants

# use gencache
app = win32com.client.gencache.EnsureDispatch("Visio.Application")

doc = app.Documents.Add("")
page = app.ActivePage
shape = page.DrawRectangle(0,0,1,1)

# Here we go
shape.CellsSRC(c.visSectionObject, c.visRowFill, c.visFillForegnd).Formula = "2"

app.Quit()
exit(0)

Visio Guy

Not sure if you are more interested in learning Visio's object model or in diagramming it. But I've noticed that one item to stress is that there are two main trees for getting at things: the document way and the window way.

Roughly put:

document > pages > page > shapes > shape > cells > cell
document > masters > master > shapes > shape > cells > cell

and

window > selection > shape > cells > cell
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

PF4VisioGuy

The diagram is just a quick way to visualize the objects and how they relate to each other
I will leard the COM interface as much as I need as I do not live by writing code for Visio
I create network diagrams with Visio and I like to be good at that. We have a large undocumented network