Modelside python sample errors

Post Reply
User avatar
clintonman
Captain
Posts: 5422
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Modelside python sample errors

Post by clintonman »

The python samples don't work for trueSpace7.61 unless you copy the contents of the PythonScripts folder into the
tS folder. The other option is to add 2 lines to the top of your python script:

Code: Select all

import sys
sys.path.append('PythonScripts')

This tells python to look inside the PythonScripts folder for modules to load.

Clinton
Clinton Reese

http://clintons3d.com
User avatar
Emmanuel
Chief Warrant Officer
Posts: 650
Joined: 14 Jun 2009, 06:47

Re: Modelside python sample errors

Post by Emmanuel »

Great ! Thanks for the trick Clinton !!!
I tried to load a python script the other day... and it failed. I was sorry about that and wondered what was wrong for a moment.

Would you allow me to copy the trick on my tS plugins archive page ? I plan to copy some good python scripts there in the future...
User avatar
clintonman
Captain
Posts: 5422
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Modelside python sample errors

Post by clintonman »

Emmanuel wrote:Great ! Thanks for the trick Clinton !!!
I tried to load a python script the other day... and it failed. I was sorry about that and wondered what was wrong for a moment.

Would you allow me to copy the trick on my tS plugins archive page ? I plan to copy some good python scripts there in the future...
Yes, feel free to copy anything I put up.
Clinton Reese

http://clintons3d.com
User avatar
trueBlue
Captain
Posts: 5208
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: Modelside python sample errors

Post by trueBlue »

I discovered today what happens when you run a Python script using Clinton's tip

Code: Select all

import sys
sys.path.append('PythonScripts')
trueSpace creates several files in the PythonScripts folder with the pyc extension
pyc files in PythonScripts folder.png
pyc files in PythonScripts folder.png (2.75 KiB) Viewed 1335 times
The alternate is to move, not copy, these trueSpace Python files to the tS folder
trueSpace Python files.png
trueSpace Python files.png (3.73 KiB) Viewed 1320 times
These are the files needed to run most user created phyton scripts, that use dialogs, and where trueSpace looks for them.
Personally, I like this way better, because then, they are secluded from the PythonScripts folder where you can keep user created scripts.
If you try to run any of these files from the Script Editor, they do not do anything.
I also think this is better for backwards compatibility using user created scripts and new users
I will be adding these files to the Unofficial Updates for trueSpace 7.6 and 7.61 in the near future
Post Reply