Visio Guy

Visio Discussions => Programming & Code => Topic started by: Yacine on October 03, 2018, 12:55:23 PM

Title: Working with Visio the Geek way - Jupyter/IPython Notebooks
Post by: Yacine on October 03, 2018, 12:55:23 PM
It's the end of summer, but for me it's already Christmas time.

I've been gifted with a new toy.

It has several names, depending on the point of view: Python, IPython, Jupyter Lab.
So I've been playing for over a month now with Jupyter Lab and got absolutely addicted.
With it I solved problems, I have on my desk for almost 10 years.
Why? Because:So what am I trying to say?The way there is easy: https://www.anaconda.com/ (https://www.anaconda.com/)

I'll share my Visio-IPython library in a separate post.
----
What did I end up with?What did I accomplish so far special?
Title: Re: Working with Visio the Geek way
Post by: wapperdude on October 03, 2018, 02:00:32 PM
Ahh!  What every "I hate programming." individual ought to have!

But, alas, only now has the need so diminished, that the bigger challenge would be finding a use for it.  Bummer!

Well, Merry Christmas!!!  Bake up some holiday goodies...so to speak.

Wapperdude
Title: Re: Working with Visio the Geek way
Post by: Gustavo on October 08, 2018, 06:39:50 PM
Very interesting your work and experience with Python & Visio Yacine. I've trying to take a look to the technology since you described it some months ago, but the timeline of some deliverables i got, has slowed my learning curve. I think it would have potential to translate the visio data model to some web delivered apps, but I'm not so sure.  An effortless dynamic manipulation of strings in shapesheet cells has been a dream to visio developers, and so far I had to do it using two or more additional cells in the shapesheet. Which other applications do you envision by using these two technologies together? best regards.
Title: Re: Working with Visio the Geek way
Post by: Yacine on October 09, 2018, 04:30:26 PM
Hi Gustavo,
very nice question indeed ... for which I can only provide an ambiguous and indirect answer.

There are 3 aspects to consider:
So for myself, the scenario would look as follows:Future development ideas are:Basically the applications of the combination Visio/Python are endless. It's your personal preference that will most often dictate the tool of choice. Seldom enough there will be rational reasons for one tool over another. But at equal levels of comfort with all the tools, it's probably Python that you'll use for the next task to accomplish.
I'm sure you can come up with more ideas. I'd love to read you contributions.



So as of today October, 9th 2018, the current version of my Visio library looks as in the attachment ... still in very early stage.There are some initializing scripts, some direct API calls and some snippets I used so far for either honest working or for testing functions.Your suggestions are welcome.
Title: Re: Working with Visio the Geek way - Jupyter/IPython Notebooks
Post by: vojo on October 09, 2018, 07:11:25 PM
if it were me, I would consider a whole different approach
- use visio as a basic display pane (similar to tkinter without all the dependences on open GL license)
- user python to create the drawing
- work flow like this
    - call up python function   e.g.  s1 = pysquare (x,y,xpos,ypos)
          - add to list  e.g.   shapelist = list()
                                     shapelist.append(s1)
    - run it thru a bunch a transforms of interest   e.g. 3D==>2D projects, add some text, etc
    - call up pithing function  e.g. c1 = pycircle (r, xpos, ypos)
    - transforms et al
                                      shapelist.append(c1)
    - when all done, call a python function  e.g. pycommit_to_visio (shapelist)
      (this draws the actual shapes)
- put functions in a module
    - squar
    - circle
    - transforms
    -etc.

I am sure you can do it in xml as well...but this removes that step or at least make the process cleaner

Just a thought
Title: Re: Working with Visio the Geek way - Jupyter/IPython Notebooks
Post by: Yacine on October 10, 2018, 06:38:24 PM
@vojo,
yes, but this is a step further than where I am now.
For the time being I'm still developing (actually playing) and am my own customer /consumer.
Only once I want to distribute my scripts, I will start writing GUI forms with tkinter or Qt to make them fool proof.
But basically I totally agree with your thoughts.

Cheers, Y.

PS: one additional idea - presenting the script encapsulated in a GUI will of course break totally the idea of the titel ('the Geek way'). This will be the "safe" way.
Title: Re: Working with Visio the Geek way - Jupyter/IPython Notebooks
Post by: vojo on October 11, 2018, 02:27:43 AM
no no...stay way from tkinter since you would have to include all kinds of extra modules to make it an EXE.
Tkinter is not a single/few self contained/tkinter modules...it assumes the local platform has openCL et al installed. 
it usually does...but that means you would have to ship this as a zip of all your source code.
maybe you want to do that??   that just means that its for pythonistas only...which might be the first/ideal target audience.
(you could look at augmenting pycad with a "visio behavior" module if you want to do more than generatel visio xml).
(conversely, I am pretty sure there are python apps on GitHub that do xml generation...maybe just tailor one of them for visio)

zip of source is, effectively, like shipping 100s of VBA scripts to get this going.  my guess is that you want to learn python
otherwise, mind as well have VBA script library / launcher / add on

I guess I am obtuse...not sure of the value of generating visio XML from python unless that is a first step to a long term plan.
(you don't need any interlock with visio to generate visio xml....python -->xml --> visio....days apart).

sorry for any heartburn  :-)
Title: Re: Working with Visio the Geek way - Jupyter/IPython Notebooks
Post by: wapperdude on October 11, 2018, 02:54:13 AM
Quotetkinter

???  I thought that was a typo ...  ;D

@Yacine, Vojo:  you guys are giving me a headache.  And people wonder why I hate programming.   >:(
Title: Re: Working with Visio the Geek way - Jupyter/IPython Notebooks
Post by: Yacine on October 11, 2018, 04:20:41 PM
Quote from: wapperdude on October 11, 2018, 02:54:13 AM
Quotetkinter

???  I thought that was a typo ...  ;D

You're kidding us. You cannot pretend hating programming, we've seen your connection macros.

By the way TKinter isn't that "esoteric":
https://www.youtube.com/playlist?list=PL6gx4Cwl9DGBwibXFtPtflztSNPGuIB_d
Title: Re: Working with Visio the Geek way - Jupyter/IPython Notebooks
Post by: wapperdude on October 11, 2018, 10:59:12 PM
Being able to do something, doesn't mean you enjoy it. 

And I really don't enjoy it.  But, sometimes, you do what you have to do, do it the best you can...at the time.  But the scope of this thread is way beyond where I can follow.
Title: Re: Working with Visio the Geek way - Jupyter/IPython Notebooks
Post by: Yacine on October 12, 2018, 10:13:56 AM
Quote from: wapperdude on October 11, 2018, 10:59:12 PM
Being able to do something, doesn't mean you enjoy it.  ...

That's where Python and especially Jupyter Lab jump in.
I do also know how frustrating a difficult coding job can become.
One rough idea, hundreds of debugging loops, short happy moment and 2 days later you wont even recall what, why and how you did it.
In Jupyter Lab you'll have much more small satisfaction moments ... and if you're disciplined enough to comment you code (Markdown cells), you'll be able to understand what you did even months afterward.


Quote from: wapperdude on October 11, 2018, 10:59:12 PM
... But the scope of this thread is way beyond where I can follow.
... sure but not because it is so difficult, but rather because you haven't look at it yet.
Yes I did watch a whole bunch of youtube videos on the subject, but I had no other help than that. ... and it was enough to get me started.
I would even state that Python is easier than VBA and the Visio shapesheet.
And for someone having mastered the subject of the setref-stuff (you're subjectively the only one in the forum who specialised on this matter) this tiny hurdle should be a joke.... not to speak about the connection-stuff which is almost as "esoteric". ;)