chrono::parsers::ChPythonEngine Class Reference

Description

Class for a Python parser.

This is an interpreter that can parse Python programs, from a single formula up to large programs.

#include <ChParserPython.h>

Public Member Functions

 ChPythonEngine ()
 Create a Python parser, an interpreter that can parse Python programs. More...
 
void Run (const char *program)
 Execute a program. More...
 
bool GetFloat (const char *variable, double &return_val)
 Retrieve a value of an existing floating point variable. More...
 
void SetFloat (const char *variable, const double val)
 Set a value of a floating point variable. More...
 
bool GetInteger (const char *variable, int &return_val)
 Retrieve a value of an existing integer variable. More...
 
void SetInteger (const char *variable, const int val)
 Set a value of a integer variable. More...
 
bool GetBool (const char *variable, bool &return_val)
 Retrieve a value of an existing bool variable. More...
 
void SetBool (const char *variable, const bool val)
 Set a value of a bool variable. More...
 
bool GetString (const char *variable, std::string &return_val)
 Retrieve a value of an existing string variable. More...
 
void SetString (const char *variable, std::string &val)
 Set a value of a string variable. More...
 
void SetList (const char *variable, const std::vector< double > &val)
 Set a value of a numeric list variable. More...
 
bool GetList (const char *variable, std::vector< double > &return_val)
 Retrieve a value of an existing numeric list variable. More...
 
void ImportSolidWorksSystem (const std::string &solidworks_py_file, ChSystem &msystem)
 Load a .py file as it is saved by the SolidWorks add-in exporter. More...
 

Constructor & Destructor Documentation

◆ ChPythonEngine()

chrono::parsers::ChPythonEngine::ChPythonEngine ( )

Create a Python parser, an interpreter that can parse Python programs.

NOTE: currently only one instance at a time can be created.

Member Function Documentation

◆ GetBool()

bool chrono::parsers::ChPythonEngine::GetBool ( const char *  variable,
bool &  return_val 
)

Retrieve a value of an existing bool variable.

Returns false if unsuccesfull.

◆ GetFloat()

bool chrono::parsers::ChPythonEngine::GetFloat ( const char *  variable,
double &  return_val 
)

Retrieve a value of an existing floating point variable.

Returns false if unsuccesfull.

◆ GetInteger()

bool chrono::parsers::ChPythonEngine::GetInteger ( const char *  variable,
int &  return_val 
)

Retrieve a value of an existing integer variable.

Returns false if unsuccesfull.

◆ GetList()

bool chrono::parsers::ChPythonEngine::GetList ( const char *  variable,
std::vector< double > &  return_val 
)

Retrieve a value of an existing numeric list variable.

Returns false if unsuccesfull.

◆ GetString()

bool chrono::parsers::ChPythonEngine::GetString ( const char *  variable,
std::string &  return_val 
)

Retrieve a value of an existing string variable.

Returns false if unsuccesfull.

◆ ImportSolidWorksSystem()

void chrono::parsers::ChPythonEngine::ImportSolidWorksSystem ( const std::string &  solidworks_py_file,
ChSystem msystem 
)

Load a .py file as it is saved by the SolidWorks add-in exporter.

Such a .py file is a Python program that creates an equivalent mechanism in Chrono and contains a sequence of Chrono physics item object (bodies, links, etc.). This function populates the specified Chrono system with all these Chrono objects. This function may throw on error, so it should be called in a try-catch block

Add the ChPhysicsItem to the ChSystem

◆ Run()

void chrono::parsers::ChPythonEngine::Run ( const char *  program)

Execute a program.

If fails, it throws an exception, so it is wise to put it inside try..catch blocks.

◆ SetBool()

void chrono::parsers::ChPythonEngine::SetBool ( const char *  variable,
const bool  val 
)

Set a value of a bool variable.

If a variable with the same name is existing, it is overwritten, otherwise it is created (in main namespace)

◆ SetFloat()

void chrono::parsers::ChPythonEngine::SetFloat ( const char *  variable,
const double  val 
)

Set a value of a floating point variable.

If a variable with the same name is existing, it is overwritten, otherwise it is created (in main namespace)

◆ SetInteger()

void chrono::parsers::ChPythonEngine::SetInteger ( const char *  variable,
const int  val 
)

Set a value of a integer variable.

If a variable with the same name is existing, it is overwritten, otherwise it is created (in main namespace)

◆ SetList()

void chrono::parsers::ChPythonEngine::SetList ( const char *  variable,
const std::vector< double > &  val 
)

Set a value of a numeric list variable.

If a variable with the same name is existing, it is overwritten, otherwise it is created (in main namespace)

◆ SetString()

void chrono::parsers::ChPythonEngine::SetString ( const char *  variable,
std::string &  val 
)

Set a value of a string variable.

If a variable with the same name is existing, it is overwritten, otherwise it is created (in main namespace)


The documentation for this class was generated from the following files:
  • /builds/uwsbel/chrono/src/chrono_parsers/ChParserPython.h
  • /builds/uwsbel/chrono/src/chrono_parsers/ChParserPython.cpp