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 think you need to put your name on this editing somewhere, you need to take the credit for it.
Electronic and Electrical engineering, business and software stencils for Visio -

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

Yacine

#16
I'm fighting for the cause. ;) :D
Yacine

Yacine

#17
Quote from: Surrogate on February 05, 2022, 04:40:22 PM
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 


I work on my employer's computer which has Visio installed and - luckily - allowed me to install Miniconda (over a year ago)
and a second, personal one - which has Linux installed, because I am too greedy to pay for Windows and Visio. But it has Miniconda installed.

Bad constellation for investigating on path problems. I can't afford to mess up my "company" computer and can't really try windows and visio stuff on my personal one.




Anyway, let's dive into that ugly problem!
As matter of fact, when I tried checking my wiki examples in vs code, I also got path problems. Spent some time on it and gave up! Shame!
But giving up is not acceptable! (The world beyond this door is so green and shiny ;) ).
The target being to have ONE working, dumb and easy solution for ALL "visioneers"!


Lazy solution:
Use the installers of the heavier installations (Anaconda, Miniconda, ...) to set up the paths.


Hard-working solution:
Try different settings in editing window's path setting.
https://www.opentechguides.com/how-to/article/windows-10/113/windows-10-set-path.html


I would really appreciate your feedback,
Y.


PS: By the way, there are tons of tutorials showing this process in Linux. But since "Visio" is "Windows", our solution also needs to be a "Windows" one!
Yacine

Surrogate

Quote from: Yacine on February 06, 2022, 02:11:19 PMLazy solution:
Use the installers of the heavier installations (Anaconda, Miniconda, ...) to set up the paths.
I already had the previously downloaded Miniconda, installed today but it did not work without intervention  :o
Then I installed Anaconda, a lot of packages installed at once. everything worked almost immediately.
Powershell default command conda activate base, replaced by .\conda activate base.


Hallelujah !!!

Yacine

#19
If now you can also get Jupyter lab running, then we can start playing. :D :D :D


BTW, don't forget to add a new environment, that you can mess up.
Yacine

wapperdude

@Yacine:  I bet I'm lazier than you!!! ...reference your comment in another post.  I'm to lazy to fetch that linik!   ;) ;D

I've been following the serpentine comments in this post, and when reference to thim in other posts occurs. 

My take-away, from the perspective of the "average" user / newbie would be "Really!?!  Why???"  The appeal seems like it would be of more interest for a serious, full-time develper.  VBA is built-in.  Nothing extra to install.  Not terribly difficult to learn ... if you devote reasonable amount of time.  AFAIK, all coding paths need investment time.  None suitable for the spoonfed, easy button, I want a solution now crowd.  But, VBA, because of its age, has a bounty of existing code macros that come close to plug n play.  Add to that a host of websites that have forums to address solutions.

Then, there's me.  Fully retired.  No driving need for Visio, other than participation in the Forum, and  perhaps, occassional DIY projects.  None of which warrant the need to delve into Python and the numerous enabling/support apps needed to go with it.  Indeed, most of my Visio needs don't even involve coding.  So, I watch all of this out of fascination.   

The Forum regulars need to forge a path and must demonstrate Python's utility and benefit,,,with actual examples/application, to convince Chris that there's merit and interest, that it warrants a separate, dedicated section on the Forum.
Visio 2019 Pro

vojo



https://software-solutions-online.com/vba-vs-python/#:~:text=Python%20is%20a%20General%2DPurpose,the%20Visual%20Basic%20Runtime%20Library.

https://dataresident.com/python-vs-vba/

It looks like the big difference is VBA is tied to MS platforms (and since Visio is likewise tied to MS platforms, might be moot)
Other than that, its a fashion statement:  I am sure there is somebody out there doing Pascal to Visio but not many do anything with Pascal anymore. ;-)

Psersonally I have done alot with both
- Upside VBA can do OOP and does interface seemless to MS tools
- downside of VBA is the need to defeat all MS security issues
- Upside of Python, alot and I mean alot of free modules for very complex tasks  (Try numpy or scipy in VBA).
- downside of Python is that editor uses alot of spacing to establish context....hard to debug but getting better
-

wapperdude

Visio 2019 Pro

Visisthebest

#23
Actually I see you can program Python by creating Visio diagrams:

https://github.com/vesellov/visio2python

Does that mean we can program Visio by programming Python with Visio diagrams? [mind=blown!]  ;D ;D ;D

If we create self-improving Visio diagrams that write Python code that creates better Visio diagrams have we achieved the Visio singularity?

(All kidding aside, I think Python is an excellent programming language)

And this tool:

https://github.com/vesellov/visio2python

is another amazing demonstration of what is possible with Visio!
Visio 2021 Professional

Yacine

#24
@Wapperdude,
You are absolutely right with your statement, that Python is not suited for newbies and people looking for a quick way to draw, but so are - at a lower level - Visio's pro features.
At work, none of my colleagues would dare opening a shapesheet or write VBA code (for Visio at least - Excel is another story).
It took me probably half a year to grasp the concept of shapesheets.

So we are an elitary club of people trying to stretch the boundaries of Visio. Yesterday we've even implemented that crazy for loop in the shapesheet - something M$ did not come up with.
We've mastered the shapesheet, we know a lot about VBA and here is a new tool that can do even more stuff, so why not try it?

This complicated installation is definitely something that shall become easier, but otherwise the technology is already quite mature. As a matter of fact, I use it on a daily basis for automating dumb tasks.

By no means would Python replace VBA. It is a complement.

VBA has also a lot of advantages. Forms are easier to write and handle, it is built in, better debugging, code completion (in a way), etc.


The day Wapperdude comes to us with some Python code, I'll throw a party.  ;D :o 8)
Yacine

wapperdude

Hope you invite me to the party!!!

Yeah.  At work, I was the "go to guy" for all things Visio. I remember, "Shapesheet???  We're allowed to modify the shapesheet!?!  Really?!?
Visio 2019 Pro

Yacine

Quote from: wapperdude on February 11, 2022, 06:17:19 AM
Hope you invite me to the party!!!
Sure I will. You'll be the honor guest.
Yacine

Yacine

#27
I would like to repeat my offer to set up a teams meeting.
Rather during the weekend (Saturday?).
Time? Paul is in my time zone. Surrogate is some hours ahead. If the US wanted to join, they are some 7 hours back.
Saturday 7 p.m. German time (UK = 6 pm, Russia = 9pm - 12pm, US = 10am - 1pm)
Let me know.


I've also seen these Youtube live streams, where people can comment. Dunno what is necessary to implement such a thing.
Yacine

Surrogate

Sorry, but i cant take part in your meeting  :(

Today i left Moscow, i'll go to Russian country-side. Not sure that i find there good internet connection...

I''ll be back in Monday, may be in Tuesday.

wapperdude

As FYI, Saturday doesn't work...Grandson's birthday.  But, my participation would be more of onlooker anyway.
Visio 2019 Pro