News:

BB code in posts seems to be working again!
I haven't turned on every single tag, so please let me know if there are any that are used/needed but not activated.

Main Menu

Visio and Python

Started by Paul Herber, January 30, 2022, 03:03:11 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Paul Herber

I've been meaning to have a look at Python for a while, finally got around to it, and I've documented it as well for anyone else on this course ...

https://www.paulherber.co.uk/stuff-about-visio/visio-and-python/
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

wapperdude

I hate snakes.  Ask Yacine.  He's been encouraging me to join Slytherin House for years.
Visio 2019 Pro

Paul Herber

Quote from: wapperdude on January 30, 2022, 03:16:15 PM
Slytherin House

Ah, an HP reference.
No Monty allowed in HP. Lot's of Monty in Python!

Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

Paul Herber

Any suggestions for an app that I could host on my website where we could create an archive of Visio Python code snippets? Open-source would be first-rate.
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

vojo


Paul Herber

Quote from: vojo on February 02, 2022, 02:24:31 AM
you mean something like this for visio python
http://visio.mvps.org/VBA/default.html

Something along those lines perhaps, if not a web page with code then maybe some form of collaboration system where registered users can donate code.
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

Paul Herber

How about a wiki? I could install DocuWiki quite easily.
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

Paul Herber

I've created
https://python-and-visio.paulherber.co.uk/
Nothing of interest there yet ... It'll be public readable but writeable by invitation only.
If you wish to contribute please email me.
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

vojo


Yacine

#9
Hello Paul,
I spent a couple of hours on the wiki and came to the following conclusion.

The Visio-Python couple is a much over-estimated problem, or hurdle. What ever you may name it.

There are only two things needed:
- a propper Python installation and
- a handle on Visio's objects.

That is all that is needed and it resolves all questions and fears.

Really! That's the end of the story.

Well not really, since the fun starts with leveraging Python's power to work with Visio.

That brings us to your idea about code snippets. But they won't particularly be some Visio-Python things, but rather Other-App-Python with some focus on Visio ones.
I'm struggling finding the right wording.

Basically, after having found how to interact with Visio, it is all but a matter of pure Python.
Special would be the fact that we deal with a COM-capable program,
and further special that we deal with a graphics program and a bit more with Visio.
Arrgh! It's not getting any better. Sorry!

Anyway, having mastered the "art of accessing Visio objects", all further articles can only be Examples on how to use it.

I've added an article about pure python stuff and one for examples one might want to see.

As for your wiki,
You see that I am using the forum to comment on it. I somehow miss a chat fuction in the wiki itself. You may argument that Visguy's forum is good enough!?!
I would also wish to have more colaboration from other visioneers. An open (or more open) wiki might me a solution? Specially for the wish list.
I'm not so fund of your wiki's possibilities.

So far for a lazy Saturday morning ...
yours,
Y.
Yacine

Yacine

I would suggest to loosen the registration process to the wiki in order to get more users involved.
The essence of a wiki being, that every edit can be corrected afterwards.
I plead for an optimistic approach, waiting for bad things to happen.
Yacine

Paul Herber

Hi Yacine, wow, you've expanded the wiki a lot. You seem to be an experienced programmer, so to you it seems like an easy task to interface Python to Visio. To me Python is a new concept, I spent my working life using assembler, C and that ilk. Looking at the type of questions asked in this forum about VBA programming, and the sort of VBA listings like:
http://visio.mvps.org/VBA/default.html
I see this wiki as a repository for getting people up to speed and some basic on how to loop through pages, shapes, access layers and change shape attributes.
Unless Chris wants to add a Python category to this forum...
I have invited a couple of others, but I don't want to open it up to the public for write access yet, keeping spammers at bay can be a nightmare.
Anyone interested in Python on this forum must have seen the invitation above, and they can see it again, now, please let me know your interest!
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

Surrogate

#12
Quote from: Yacine on February 05, 2022, 12:21:08 PM
There are only two things needed:
- a propper Python installation and
- a handle on Visio's objects.
A stumbling block for me: installing Python

Half a year ago I installed Python 3.8 and started to learn the basic operations. When I wanted to work with the openpyxl library there appeared to be a problem with the path where python was installed. There seems to be a limit of the path length (80 characters) and also my path contained cyrillic characters.  :o
Yesterday I uninstalled and installed Python 3.10, in the c:\python folder and again some problems. An error in the import win32com.client line pops up. PATH problem again 

Paul Herber

I think this one of the doubts I have about Python, it can be fine for creating and using scripts for your own use, but when you want to distribute them to the public or customers then you have no control over which packages the user has installed. Programming in C# doesn't have that problem but I don't know about VBA, probably not.
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

Yacine

#14
Quote from: Paul Herber on February 05, 2022, 03:19:40 PM
To me Python is a new concept, I spent my working life using assembler, C and that ilk.
Assembler and C? That is what I call "hardcore" programming.
Python is kindergarten compared to them.

It has some hurdles, I agree.
And you two nailed them, PATHs and the distribution of applications.
That said, they are only hurdles not limitations. Both can be solve
I will try to come back on them in the wiki.


Meanwhile remember Stackoverflow is Python's Google.

Quote from: Paul Herber on February 05, 2022, 03:19:40 PM
I see this wiki as a repository for getting people up to speed and some basic on how to loop through pages, shapes, access layers and change shape attributes.

I've set up some examples and hope having caught the essence of your question.
You will notice that the "visio" part of the code is really tiny. Most of the code is basic Python stuff.
Let me know your opinion.
https://python-and-visio.paulherber.co.uk/doku.php?id=examples_of_python_programs


Quote from: Paul Herber on February 05, 2022, 03:19:40 PM
Unless Chris wants to add a Python category to this forum...
This would be great.
Where is Chris anyway? Haven't read anything from him in months! Chris, are you fine?

Quote from: Paul Herber on February 05, 2022, 03:19:40 PM
I have invited a couple of others, but I don't want to open it up to the public for write access yet, keeping spammers at bay can be a nightmare.
Anyone interested in Python on this forum must have seen the invitation above, and they can see it again, now, please let me know your interest!
Sure!
Yacine

Browser ID: smf (possibly_robot)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 461 (show)
Files included: 32 - 1207KB. (show)
Memory used: 1296KB.
Tokens: post-login.
Cache hits: 13: 0.00151s for 26,725 bytes (show)
Cache misses: 3: (show)
Queries used: 16.

[Show Queries]