Primitive tsxPython (ptsxpy), another Python interpreter plugin for tS series

free scripts, plugins, models, textures
Post Reply
User avatar
borgcone
Petty Officer Third Class
Posts: 11
Joined: 06 May 2018, 21:09
Type the number ten into the box: 10

Primitive tsxPython (ptsxpy), another Python interpreter plugin for tS series

Post by borgcone » 03 Mar 2019, 18:46

I finished to remaster my old plugin, "primitive tsxPython" (ptsxpy), for tS4.3, tS5.1, tS6.0, tS6.6, and Model side of ts7.6*.

Primitive tsxPython (ptsxpy) is another Python interpreter plugin for the trueSpace series. You can execute almost all tsxAPI functions defined in tSx (trueSpace extension) document from your script. The plugin would expand application of your Generative 3D Modelings, 3D animations, and 3D printing, etc. Draw out the hidden abilities of the trueSpace!

Visit the web site and download the FREE plugin and sample scripts!
https://biglode.com/ptsxpy

Join the user forum to discuss about the plugin and to exhibit your works! Testers are also welcome.
Your help improves the qualities of the the plugin.

Thank you.

Short movies:













Related topics:
Where is the DEVELOPER'S GUIDE?
https://www.united3dartists.com/forum/v ... f=4&t=5473

Are the tsxAPI*.doc redistributable? License terms?
https://www.united3dartists.com/forum/v ... f=4&t=5495

(edited Mar 6 2019: Added tS6.0 to the first line.)
Last edited by borgcone on 06 Mar 2019, 04:58, edited 1 time in total.
borgcone ... or 3DfromNULL at https://biglode.com/ptsxpy

clintonman
Captain
Posts: 2367
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Primitive tsxPython (ptsxpy), another Python interpreter plugin for tS series

Post by clintonman » 04 Mar 2019, 05:06

Looks really nice.
I have python 2.7 64bit installed on my system. Would I be able to use the python 3 32bit version of your plugin without any interference or problems from the other python?
Clinton Reese

http://clintons3d.com

User avatar
borgcone
Petty Officer Third Class
Posts: 11
Joined: 06 May 2018, 21:09
Type the number ten into the box: 10

Re: Primitive tsxPython (ptsxpy), another Python interpreter plugin for tS series

Post by borgcone » 04 Mar 2019, 07:04

clintonman wrote:
04 Mar 2019, 05:06
I have python 2.7 64bit installed on my system. Would I be able to use the python 3 32bit version of your plugin without any interference or problems from the other python?
As I wrote to "Trouble Shooting" in FAQ page, unfortunately pythonxx.dll in the system directory interferes the plugin.
- C:\Windows\SysWOW64 (if 64 bit Windows)
- C:\Windows\System32 (if 32 bit Windows)
The solution to avoid that is to rename or to move pythonXX.dll in the system directory temporally, AFAIK.
Please let me know if you (or someone else) have any hint to solve the problem.

Thank you.

The source code where main dll loads sub dll for each tS is:

Code: Select all

// Load a dll for each tS version
static bool
loaddllforeachtsver()
{
 char *dllnum;
 char loadpath[ 1000 ];
 DWORD errcd;

 // Get trueSpace major/minor version
 tsxGetTsVersionNbrs( &TsverMajor, &TsverMinor );
 dbg1( 1, "tSver=%d.%d \n", TsverMajor, TsverMinor );
 // Get method table pointers
 TSmode =
  ( ( TsverMajor == 500  &&
      TsverMinor == 1 )  ||
    TsverMajor / 100 == 4 )? 4 :
  TsverMajor / 100;
 switch ( TSmode ) {
   case 4:
		dllnum = "43";
		break;
   case 5:
		dllnum = "51";
		break;
   case 6:
   case 7:
		dllnum = "66";
		break;
   default:
		MessageBox( NULL,
			"The tsx does not support this tS version.\n",
			"ptsxpy",
			MB_OK + MB_ICONEXCLAMATION );
		return false;
 }

 dbg1( 2, "(0.5) ThisDLLDir=[%s]\n", ThisDLLDir );
 sprintf_s( loadpath, sizeof( loadpath ), "%s\\ptsx"
#ifdef PY3_BY_PROPERTYSHEET
  "3"
#else
  "2"
#endif
  "pysb%s"
#ifdef _DEBUG
  "_d"
#else
  ""
#endif
  ".dll", ThisDLLDir, dllnum );
 // Add this DLL's directory to Path environment variable
 char wks1[ 3000 ];
 GetEnvironmentVariable( (LPCTSTR)"Path", (LPTSTR)wks1, sizeof( wks1 ) );
 strcat_s( wks1, sizeof( wks1 ), ";" );
 strcat_s( wks1, sizeof( wks1 ), ThisDLLDir );
 SetEnvironmentVariable( (LPCTSTR)"Path", (LPCTSTR)wks1 );
 dbg1( 2, "Path=%s\n", wks1 );
 dbg1( 2, "(1) loadpath=%s\n", loadpath );
 // 
 if ( !is_dllforeachver_loaded ) {
   if ( !( HInst_dllforeachtsver = ::LoadLibrary( loadpath ) ) ) {
     errcd = GetLastError();
     dbg1( 1, "Failed to LoadLibrary( \"%s\" ).  errcd=%ld\n",
      loadpath, errcd );
     return false;
   }
   is_dllforeachver_loaded = true;
 }
 return true;
}
borgcone ... or 3DfromNULL at https://biglode.com/ptsxpy

clintonman
Captain
Posts: 2367
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Primitive tsxPython (ptsxpy), another Python interpreter plugin for tS series

Post by clintonman » 04 Mar 2019, 15:44

borgcone wrote:
04 Mar 2019, 07:04
As I wrote to "Trouble Shooting" in FAQ page, unfortunately pythonxx.dll in the system directory interferes the plugin.
- C:\Windows\SysWOW64 (if 64 bit Windows)
- C:\Windows\System32 (if 32 bit Windows)
The solution to avoid that is to rename or to move pythonXX.dll in the system directory temporally, AFAIK.
Please let me know if you (or someone else) have any hint to solve the problem.

Thank you.

The source code where main dll loads sub dll for each tS is:
I have an idea, maybe if you place it at the start of the path instead of the end then maybe it finds your dll first. Something like this:

Code: Select all

char wks_pre[ 3000 ];
 GetEnvironmentVariable( (LPCTSTR)"Path", (LPTSTR)wks1, sizeof( wks1 ) );
 strcat_s( wks_pre, sizeof( wks_pre ), ThisDLLDir );
 strcat_s( wks_pre, sizeof( wks_pre ), ";" );
 strcat_s( wks_pre, sizeof( wks_pre ), wks1);
 SetEnvironmentVariable( (LPCTSTR)"Path", (LPCTSTR)wks_pre );

Clinton Reese

http://clintons3d.com

User avatar
borgcone
Petty Officer Third Class
Posts: 11
Joined: 06 May 2018, 21:09
Type the number ten into the box: 10

Re: Primitive tsxPython (ptsxpy), another Python interpreter plugin for tS series

Post by borgcone » 04 Mar 2019, 19:30

clintonman wrote:
04 Mar 2019, 15:44
I have an idea, maybe if you place it at the start of the path instead of the end then maybe it finds your dll first. Something like this:
I'm sorry for confusing you. The code I wrote (mistakingly) in my first reply was not for loading pythonXX.dll but for loading ptsx2pysb66.dll etc. from ptsx2py.tsx etc.
The plugin uses Py_SetPythonHome() and Py_Initialize() to load python2X.dll/python3X.dll in accordance with the manner prescribed by Python.org.

I've just tested (after I read your advice) the latest released version, 0.0.3, and it seems that we don't need to worry about the interference. The test sequence is:
(1) Some Python2.X(32bit) and Python3.X(32bit) have already been installed in my 64bit PC.
--> OK (the tsx loads the right Python dll)
(2) I copied Python36.dll(32bit) to both Windows\SysWOW64 and Windows\System32.
--> OK (the tsx loads the right Python dll)
(3) I deleted the copies.
(4) I uninstalled Python 2.7 (32bit)
--> OK (the tsx loads the right Python dll)
(5) I Installed Python2.7.15(64bit) in order to experience a similar situation.
--> OK (the tsx loads the right Python dll)
(6) I copied Python27.dll(64bit) to both Windows\SysWOW64 and Windows\System32.
--> OK (the tsx loads the right Python dll)

So, when you (or someone else) find any interference, please report to me (here or at the user forum of the plugin).

Thank you.

For your information, my (more inelegant) code for loading a Python dlls is:

Code: Select all

#ifdef PY3_BY_PROPERTYSHEET
 char wks1[ 1000 ];
 strcpy_s( wks1, sizeof( wks1 ), ThisDLLDir );
 size_t sz1;
 static wchar_t *wcp1 = Py_DecodeLocale( wks1, &sz1 );
 if ( wcp1 == NULL ) {
   return false;
 }
 Py_SetPythonHome( wcp1 );
 wchar_t *wcp2 = Py_GetPath();
 size_t pos1;
 char *p2 = Py_EncodeLocale( wcp2, &pos1 );
 //Py_SetPath( wcp1 );

 PyImport_AppendInittab( "ptsxgp", PyInit_ptsxgp );
 PyImport_AppendInittab( "ptsxpy", PyInit_ptsxpy );

 Py_SetProgramName( L"scrxx" );
#else
 ::Py_SetProgramName( "scrxx" );
 Py_SetPythonHome( ThisDLLDir );
#endif

 Py_Initialize();

#ifndef PY3_BY_PROPERTYSHEET
 // Add new module names to python and init method table for each.
 addnewmodule( "myredirect", Myredirect_methods );
 addnewmodule( "ptsxgp",     Gpmethods );
 addnewmodule( "ptsxpy",     Methods );
#endif
borgcone ... or 3DfromNULL at https://biglode.com/ptsxpy

clintonman
Captain
Posts: 2367
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Primitive tsxPython (ptsxpy), another Python interpreter plugin for tS series

Post by clintonman » 05 Mar 2019, 04:55

Good news then. :bananathumb:
Clinton Reese

http://clintons3d.com

User avatar
borgcone
Petty Officer Third Class
Posts: 11
Joined: 06 May 2018, 21:09
Type the number ten into the box: 10

Re: Primitive tsxPython (ptsxpy), another Python interpreter plugin for tS series

Post by borgcone » 05 Mar 2019, 14:03

Added two movies.



borgcone ... or 3DfromNULL at https://biglode.com/ptsxpy

User avatar
Emmanuel
Master Chief Petty Officer
Posts: 515
Joined: 14 Jun 2009, 06:47

Re: Primitive tsxPython (ptsxpy), another Python interpreter plugin for tS series

Post by Emmanuel » 08 Mar 2019, 19:28

Very impressive !

User avatar
borgcone
Petty Officer Third Class
Posts: 11
Joined: 06 May 2018, 21:09
Type the number ten into the box: 10

Re: Primitive tsxPython (ptsxpy), another Python interpreter plugin for tS series

Post by borgcone » 10 Mar 2019, 18:21

Emmanuel wrote:
08 Mar 2019, 19:28
Very impressive !
Thank you.

Added a sample script for collision detecting functions.
borgcone ... or 3DfromNULL at https://biglode.com/ptsxpy

User avatar
borgcone
Petty Officer Third Class
Posts: 11
Joined: 06 May 2018, 21:09
Type the number ten into the box: 10

Re: Primitive tsxPython (ptsxpy), another Python interpreter plugin for tS series

Post by borgcone » 24 Apr 2019, 17:25

Added two samples.



Before executing the script for above, you need to select the "Simple volumetric" by hand as a foreground shader.



The roulette can be made from the empty. No texture maps needed. Of course, you can select from single-zero "0", double-zero "00", and triple-zero "000" wheel.

Related topic:
Foreground Shader selection from tsxAPI?
viewtopic.php?f=12&t=5630
borgcone ... or 3DfromNULL at https://biglode.com/ptsxpy

Post Reply