OS. Interpreting OpenSTAAD API Syntax for Python
The functions documented for the OpenSTAAD are given in the C++ syntax. It’s typically a simple process to interpret these for use in a Python program.
Classes and Methods
Classes syntax are listed in the format OSClassUI::Method
. In Python, this should be instead given as
Class.Method
.
In the example, OpenSTAAD was instantiated using the variable os
. Classes were then called using the format
os.Class
(for example, the
Geometry class was referenced using os.Geometry
). In the C++ syntax
used in the documentation, where you see OSClassUI
, instead simply use
Class
in Python.
The exception of course is the root
OpenSTAAD
functions, which will use whatever variable you have used to instantiate OpenSTAAD
(looking to the example again, this would be os.GetBaseUnit
). That
is, the OpenSTAAD object acts as the class for these functions.
_FlagAsMethod
function to identify each OpenSTAAD method as a method
once.Return Values
The syntax listed indicates if a function has a return value with a
leading VARIANT
. This simply means that function will return a
value that typically will be stored into a variable. If the function syntax is
listed with a leading void
, then there is no return value.
Variables and Parameters
The syntax listed typically
indicates parameters as type VARIANT FAR
, which is not
necessarily useful.
string,
long). In Python, you don’t have to declare a variable type, it will be decided when the value is interpreted. Of course, it does matter if the variable contains a string or a number and what type of number when you want to use it in another function. OpenSTAAD may return integers or floating point decimal places.