Static Public Member Functions

FBPython Class Reference

Search for all occurrences

Detailed Description

FBPython is for python users to run python script and communicate with MotionBuilder internal python facility.

Warning: When the user is calling the methods of FBPython in another thread other than MotionBuilder main thread, the user needs to create new thread state because Python internally prevents from illegal access to its internal Python objects if the current thread is not created by Python or has no thread state. In order to address this issue, the user could use the following workaround.

    PyGILState_STATE gstate;
    gstate = PyGILState_Ensure();

    FBPython::ParseLine("import sys");
    FBPython::EvalLine(); // MotionBuilder would crash if PyGILState_Ensure is not called before it.

    PyGILState_Release(gstate);

PyGILState_Ensure will create a new thread state for current calling thread.

Definition at line 93 of file fbpython.h.

#include <fbpython.h>

List of all members.

Static Public Member Functions

static const char * GetVersion ()
 Get the version of the Python interpreter.
static const char * GetPlatform ()
 Get the target platform of the Python interpreter.
static const char * GetStdout (FBPythonContext *pPythonContext=NULL)
 Get the value of stdout.
static const char * GetStderr (FBPythonContext *pPythonContext=NULL)
 Get the value of stderr.
static bool ParseLine (const char *pLine, FBPythonContext *pPythonContext=NULL)
 Submit a line of code for parsing.
static bool EvalLine (FBPythonContext *pPythonContext=NULL)
 Submit the last line of code parsed for evaluation.
static bool EvalFile (const char *pFilename, FBPythonContext *pPythonContext=NULL)
 Execute a python script file within the given context.
static bool ExecuteScript (const char *pFilename)
 Put a python script file in the execution queue.
static bool ClearContext (FBPythonContext *pPythonContext=NULL)
 Clears the python context.

Member Function Documentation

static const char* GetVersion ( ) [static]

Get the version of the Python interpreter.

Returns:
A string indicating the version of the interpreter.
static const char* GetPlatform ( ) [static]

Get the target platform of the Python interpreter.

Returns:
A string indicating the platform for which the interpreter was compiled.
static const char* GetStdout ( FBPythonContext pPythonContext = NULL) [static]

Get the value of stdout.

Parameters:
pPythonContextContext to get the Stdout from.
Returns:
A string containing the last stdout output.
static const char* GetStderr ( FBPythonContext pPythonContext = NULL) [static]

Get the value of stderr.

Parameters:
pPythonContextContext to get the Stderr from.
Returns:
A string containing the last stderr output.
static bool ParseLine ( const char *  pLine,
FBPythonContext pPythonContext = NULL 
) [static]

Submit a line of code for parsing.

Parameters:
pLineLine of code that the Python interpreter should parse.
pPythonContextContext in which the parse will occur.
Returns:
true If there was a Python interpreter and the line was valid.
false If there were no interpreter or if there was an error parsing the code (consult stderr for more infos)
static bool EvalLine ( FBPythonContext pPythonContext = NULL) [static]

Submit the last line of code parsed for evaluation.

Parameters:
pPythonContextContext in which the execution will occur.
Returns:
false If there were no interpreter or there were errors/unhandled exceptions. (consult stderr for more infos)
true If there was a Python interpreter and the code ran succesfully. (consult stdout for output, if any)
static bool EvalFile ( const char *  pFilename,
FBPythonContext pPythonContext = NULL 
) [static]

Execute a python script file within the given context.

Parameters:
pFilenameThe script file to execute.
pPythonContextContext in which the parse will occur.
Returns:
false If there were no interpreter or there were errors/unhandled exceptions. (consult stderr for more infos)
true If there was a Python interpreter and the code ran succesfully. (consult stdout for output, if any)
Remarks:
This function can only be used in the UI thread.
static bool ExecuteScript ( const char *  pFilename) [static]

Put a python script file in the execution queue.

Clears the current context.

Parameters:
pFilenameThe script file to execute.
Returns:
false If there were no interpreter or there were errors/unhandled exceptions. (consult stderr for more infos)
true If there was a Python interpreter and the code ran succesfully. (consult stdout for output, if any)
Remarks:
This function can be used in any thread.
static bool ClearContext ( FBPythonContext pPythonContext = NULL) [static]

Clears the python context.

Parameters:
pPythonContextContext to clear.
Returns:
false If there were no interpreter or if the context is invalid.
true If there was a Python interpreter and the context was valid.

The documentation for this class was generated from the following file:

FBPython FBPython FBPython FBPython FBPython FBPython FBPython FBPython FBPython FBPython
FBPython FBPython FBPython FBPython FBPython FBPython FBPython FBPython FBPython FBPython