Do you forsee any problems with using Python to automate diagram creations ?

Started by PF4VisioGuy, August 21, 2018, 01:42:21 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

PF4VisioGuy

Thanks a lot, that put me on the right direction
The VBA Visio Object model is here, well structured

https://docs.microsoft.com/en-us/office/vba/api/overview/visio

I guess the python class win32.com.client is just a proxy to expose the COM API to Python so I guess with thart module and the above page I have everything I need tostart playing with these

Yacine

I had some time to play and used it for a very early concept of what a visio library for Jupyter could look like.

Most of you would ask "why?".
Because those notebooks offer the right balance between concatenating basic commands and complex scripts.
They are available and interactive.
Once the right sequence of commands is found, you can save and re-use it.
They offer an ecosystem of endless other applications: databases, statistics, file handling, AI, ...
The technical support is very good due to a huge community

Why not VBA?
- missing the "foreign" ecosystem
- less re-useable because the code is not so easily stored as separate file. It must be loaded in a stencil or the doc. --> less interactive and live improvment

Why not Visual Studio?
- Visual Studio is best for delivering closed solutions. "Living" projects almost impossible to hangle. Specially with a community.

Why not Linqpad?
- Very good, but:
  - proprietary, not open source
  - limited to Microsoft ecosystem.

----

So what did I think of in matter of functions?
1) Basic connection and file handling stuff
2) Functions to handle the basic pages, shapesheet, layers and formats stuff
3) Solutions for recurrent questions of the forum (display prop fields in shapes, smartshapes behaviours, etc.)


Let me know your comments, I look forward to a vibrant discussion.
Yacine

vojo

played with same question

the problem with Python is its tailored to the Linux crowd (love to change their car's water pump daily)
- no real GUI (Tkinter, PYQT, etc all assume external graphics packages...so really cant bundle legally)
- Several GIT packages for Excell (work well)..but nothing really for Visio other than people playing
- Vpython more for scientific typs
- various drawing solutions in python immature or not maintained

I think a good path is the following
- effort to create a visio add on that can call python code (scripts or project) and can receive python calls.
    - hide all the minutia (similar to the various excell approaches)
- develop a family of python class instances for shapes in a module
    - fully articulated class instance a square and another for circle
    - add on can task via by class instance name
    - python can task by class instance name
    - for example
         Python side:
             square123 = square (color, size, <etc>)
             square456 = square (color, size, <etc>)
             def get_manifest:
                  <present list of shapes on python side...probably a list of tuples of (name, shape instance) >
             def get_shape (name, <etc>):
                  <present for example square123 and all its attributes to outside world>
             def set_shape (name, type, <etc>):
                  <set shape data or create a new shape>
             def del_shape (name, <etc>):
                  <deletes shape out of manifest...here line101112>

         VBA side:
             vbashape manifest = py.shape_manifest
             vbashape123 = py.get_shape (squar123, <etc>)
             vbashape456 = py.get_shape (squar456, <etc>)
             vbashape789 = py.get_shape (circle 123, <etc>)
             vbashape101112 = set_shape(line101112, <etc>)      //returns error since not in manifest

             size = vbashape 123.size
             vbashape 456.color = blue
             <update back to python...e.g manifest>
             vbashape 789.addprops (5 rows)
             vbashape789.props1 = author

The point is
- visio addon interfaces to python or maybe even the module directly
- python module is a library of shape definitions
- python program creates uniqes...5 squares, other non visio items, etc

Two way comms between Visio and the python program to modify shapes listed in the manifest from either side
(of course, the above has syntax problems but I think gives the general idea - both sides can create, delete, alter shapes)
(basically by refreshing the manifest then pick the shape...maybe VBA code has refresh manifest in the VBA shape binding)

Check out the python projects to deal with Excell...lots of good examples where...I know of 5 at least in pypi.
- Excell can task python (unique functions or even DB access )
- Python can task Excel (excell is the just the presentation screen)
- or both ways
             
                 
             
       

vojo

I guess I should have read the PDFs first ;-)
just make most of them callible from Visio side the world

PF4VisioGuy

This looks very interesting Yacine
I am not a programmer but a network engineer with some Python skills.
I will definitely help with testing and improvement ideas as I will use this on a daily basis


PF4VisioGuy

One thing that I would like Visio to have is markdown language for text in text shapes

Yacine

Quote from: vojo on August 24, 2018, 03:24:47 PM
just make most of them callible from Visio side the world
Jupyter to Viso is clear to me. The other way around not that much. Can you give some hints?
Yacine

Benblack

I've been doing Python programming for about two years and I haven't had any problems that you're interested in right now. You can safely act and try something new, and professionals will always help you. This programming language is unique cause it is very flexible and suitable for different platforms, so there are almost never any problems with it use. If these problems arise, then they are either not so serious and they can be solved independently, or they can be solved with the help of the Internet. I very often serve on different forums and look for answers to various problems related to Python. Recently I saw your problem on https://soax.com/ and in the same way I helped a person solve it, as I am helping you now. Good luck friend!