Posted By: Cellulaer
Python Plugin for C-Script - 12/30/03 07:49
First Beta version of GSPython.dll is now available. You can write Python code inside your c-script files.
At the moment the only thing you can pass back and forth between Python and Acknex are strings.
Any feedback would be appreciated.
Download Now
Example:
Code:
At the moment the only thing you can pass back and forth between Python and Acknex are strings.
Any feedback would be appreciated.
Download Now
Example:
Code:
include <gspython.wdl>;
// Define a string for you to use. I default it to 1000 characters here.
string MyPythonString[1000];
text python_txt
{
layer = 1;
pos_x = 50;
pos_y = 50;
strings = 1;
font = standard_font;
string = MyPythonString;
alpha = 100;
flags = narrow, transparent, visible;
}
function EvaluatePython() {
dll_handle = dll_open("GSPython.dll");
// Fill our test string with something
str_cpy(MyPythonString,"123");
// Create and Initialize the Python Engine
Python_Init();
// Link MyPythonString to a string variable defined in Python named AckNexStr.
// Changes to one effect changes to the other.
Python_LinkStr("AckNexStr",MyPythonString);
// Evaluate code.
Python("
# Print goes nowhere right now
print 2+2
# Test the Acknex<->Python string interface
AckNexStr.Value = AckNexStr.Value + '456' + AckNexStr.Value
");
// Free the Python Engine
Python_Free();
dll_close(dll_handle);
}