Jump to content

VW Installed Python Modules?


Recommended Posts

Is there a list of installed Python Modules for VW2022?

 

I am looking to use tkinter to store some text to the clipboard in a cross platform script. From looking in the VW App, it appears that tkinter is there, but when I try to use tkinter it can't be found.

 

I know tkinter for dialogs is discourages, but what about for other functions?

 

Can I specify the path as part of the use tkinter?

 

Newbie to Python. Hating the captilazation and white space delimiting. 😉

 

Thanks for any help.

  • Laugh 1
Link to comment

Are you on Mac? I've heard somewhere that Tkinter may need to be installed separately as its own package on the MacOS.

On my windows one, it comes with Python3.8 that ships with Vectorworks

 

 

Link to comment

tkinter could be installed with the Marionette python Modul importer. But at the Moment this maybe also not work out of the box. And by using tkinter I had negative effects resp. some functions maybe additional code to make it run in an embedded python.

Maybe off-topic. For Crossplatform Clipboard, this script could be used:
 

import math
import os
import subprocess

major, minor, maintenance, platform = vs.GetVersion()

text = 'Hello World'

def addToClipBoardWin(text):
	command = 'echo ' + text.strip() + ' | clip'
	os.system(command)
	
def addToClipBoardMac(text):
	process = subprocess.Popen('pbcopy', env={'LANG': 'en_US.UTF-8'}, stdin=subprocess.PIPE)
	process.communicate(text.encode('utf-8'))


if platform == 1:
	addToClipBoardMac(str(text))
else:
	addToClipBoardWin(str(text))

 

  • Like 4
Link to comment

@DomC Thank you for the help. Exactly what I was looking for, a cross platform way to get data onto the clipboard.

 

My script will just be one line to put the data I want into text. 🤣

 

I found several similar things on-line, but none as clearly done as yours.

 

Thanks again.

 

 

  • Like 2
Link to comment
Posted (edited)
On 4/29/2022 at 3:36 PM, Jayme McColgan said:

a down and dirty way is to look at the site-packages folder... 

/Applications/Vectorworks 2022/Vectorworks 2022.app/Contents/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages

 

It's there.

I don't understand what is going on, I file now a report and hopefully @K.Lalkovski can get a look into that.

Edit: no, decided not to file a report. Tkinter is not working easily anywhere, particularly on Mac, and there is even the limit of it being somehow commercial.

Edited by _c_
  • Like 1
Link to comment
Posted (edited)

On a side note, heres a snippet that lists out all installed modules for your python environment (adapted for vectorworks, by adding vs.CreateText(), to be run on design/sheet layer). 

 

def list_modules():
    import pkg_resources
    installed_packages = {d.project_name: d.version for d in pkg_resources.working_set}
    # print(pkg_resources.working_set)
    text_data = []
    for k, v in installed_packages.items():
        # print(f"{k} : {v}")
        text_data.append(f"{k} : {v}")

    import vs
    vs.CreateText(f"{vs.Chr(13)}".join(text_data))

 

Edited by twk
  • Like 3
Link to comment
On 5/1/2022 at 4:05 AM, _c_ said:

 

It's there.

I don't understand what is going on, I file now a report and hopefully @K.Lalkovski can get a look into that.

Edit: no, decided not to file a report. Tkinter is not working easily anywhere, particularly on Mac, and there is even the limit of it being somehow commercial.

Are you sure @_c_?  In my clean install of VW2022SP3, tkinter is not in the site-packages folder.

 

It is in:

 

/Applications/Vectorworks 2022/Vectorworks 2022.app/Contents/Frameworks/Python.framework/Versions/3.9/lib/python3.9

 

@DomC gave me what I need without it, so I didn't try moving it to site-packages. I don't have enough Python experience to know it it can just be moved or if there needs to be an official install done.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...