News:

Happy New Year!

Main Menu

Python ... again

Started by Yacine, May 01, 2024, 11:25:25 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yacine

Mühsam ernehrt sich das Eichhörnchen.
I'll have a look at it during the weekend.
Yacine

Yacine

uploaded revision 0.1.4
visio_connect now safely handles monikers of unsaved files and reports according exception.Added tests for monikers and improved regular connect test.Added module select assign
https://pypi.org/project/visiopy/
https://github.com/Y4cine/visiopy
Yacine

Surrogate

#32
Quote from: Yacine on June 30, 2024, 12:05:17 PMvisio_connect now safely handles monikers of unsaved files and reports according exception.Added tests for monikers and improved regular connect test.Added
Yes, monikers are works. But I get error
----> 6 vInit(0, globals_dict = globals())Please check my notebook.

Yacine

The output looks like one of the previous versions. Can you confirm that you have 0.1.4 installed
Yacine

Surrogate

#34
Quote from: Yacine on July 04, 2024, 11:02:38 AMCan you confirm that you have 0.1.4 installed
I first installed pyvisio on July 2. I think this is the most current version.
How can I check this?

PS I may have a problem with my environment.
I've been using miniconda. I recently tried to update it, but something went wrong.
Now I do all my experiments in Jupiter Notebooks.

Surrogate

#35
Quote from: Surrogate on July 04, 2024, 11:07:24 AMHow can I check this?
Just try use now VS Code: pip install pyvisio
Collecting pyvisio
  Obtaining dependency information for pyvisio from https://files.pythonhosted.org/packages/c9/da/dc14727612338169c37542ec9ffd175e6e1f843e7e497eadb8413070ba4c/pyVisio-0.2.0-py3-none-any.whl.metadata
  Downloading pyVisio-0.2.0-py3-none-any.whl.metadata (6.1 kB)
> pip show pyvisio
Name: pyVisio
Version: 0.2.0
Summary: Interactive and dynamic data visualization library
Home-page: https://github.com/kayahuseyinn/pyVisio

Surrogate

#36
ooops!
I installed pyvisio instead of visiopy  :o
My bad...
> pip install visiopy 
Requirement already satisfied: visiopy in c:\anaconda\lib\site-packages (0.1.4)
Requirement already satisfied: pywin32 in c:\anaconda\lib\site-packages (from visiopy) (305.1)

Surrogate

#37
I updated to 0.2.0, this tool didn't works for me
> pip show visiopy
Name: visiopy
Version: 0.2.0
Just I make some changes for my notebook Surrrogate_pyvisio_tests.ipynb
from visiopy import vDocs, vInit

vDocs()
# to display your open Visio files

vInit(0, globals_dict = globals())
# connects to the first document as displayed above.

shps = [shp for shp in vPg.Shapes]
for shp in shps:
  print(shp.ID)
  shp.Cells("PinX").Formula = int(shp.Cells("PinX").ResultInt("mm")*10)/10 + "mm"
  shp.Cells("PinY").Formula = int(shp.Cells("PinY").ResultInt("mm")*10)/10 + "mm"
And get ner error in next line
Quote---------------------------------------------------------------------------

TypeError                                Traceback (most recent call last)
Cell In[3], line 6
      3 vDocs()
      4 # to display your open Visio files
----> 6 vInit(0, globals_dict = globals())
      7 # connects to the first document as displayed above.
      9 shps = [shp for shp in vPg.Shapes]

TypeError: vInit() got an unexpected keyword argument 'globals_dict'


Yacine

#38
Sorry - my bad, lazy me!

It's now:
from visiopy import vInit
vInit(g=globals())

I shortened the variable to "g" for efficiency.

But, I'm glad you're trying to use the tool. I'm here in case you need more assistance. We can also schedule a teams meeting, if that would help. Drop me a message if you want.
Yacine

Surrogate

Quote from: Yacine on January 10, 2025, 04:57:38 PMI'm glad you're trying to use the tool.
I find visio_connect.py, especially Line74! I understand how works vInit;D
Thank you!

Yacine

and an additional note: the visio constants are available as "c.constant" - e.g. c.VisTagDefault
That's something I often stumble upon when pasting code from the macro recorder.

And last hint, the syntax is case sensitive!
Yacine

Surrogate

Quote from: Yacine on January 13, 2025, 01:38:01 PMand an additional note: the visio constants are available as "c.constant" - e.g. c.VisTagDefault
This opportunity is intresting for me, but where I wrong?
from visiopy import vInit
vInit(new = True, g=globals())
vApp.Visible = True
c = []
print(c.VisTagDefault)

Quote from: Cell Output----> 6 print(c.VisTagDefault)
AttributeError: 'list' object has no attribute 'VisTagDefault'




Yacine

with c= [], you've overwritten the initial instantiation by vInit.
Write the same code but without c=..
Yacine

Surrogate

#43
Quote from: Yacine on January 13, 2025, 02:35:29 PMWrite the same code but without c=..
On my side print(c.VisTagDefault) does not work...
Yesterday I once again did the stupid thing of upgrading my Jupyter Notebook. Now I have a broken both  Jupyter Notebook and  JupyterLab.
QuoteWARNING: Ignoring invalid distribution ~otebook (C:\anaconda\Lib\site-packages)

Yacine

from visiopy import vInit
vInit(new = True, g=globals())
vApp.Visible = True
print('Test: ',c.visTagDefault, c.visSectionUser)


output:
Instantiated the variables vApp, vDoc, vPg and vWin for the document Drawing7,
as well as the variable c for the Visio constants
Test:  0 242

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: 565 (show)
Files included: 32 - 1207KB. (show)
Memory used: 1276KB.
Tokens: post-login.
Cache hits: 13: 0.00165s for 26,544 bytes (show)
Cache misses: 3: (show)
Queries used: 16.

[Show Queries]