OS. Generate OpenSTAAD Output

  1. Type print( str(nodeCount) + ' joints') and then press Return.

    Working from the inner-most operation outward, this line is first converting the numerical result stored in nodeCount to a string. This is then combined with the text string ' joints' to make the output easier to interpret. Then the entire concatenated string is being printed to the terminal.

  2. Type print(str(beamCount) + ' members').

    Similarly, this is concatenating the beamCount value, converted to a string, with some text and displaying that result to the terminal.

  3. To print the beam numbers in the model, type the following statements and press Return at the end of each statement:
    print("Beam Numbers")
    for beam in beams:
        print(beam)

    This uses a for loop to print each beam number within the array named beams.

  4. To print the support reaction values at node 1 for load case 1, type the following statements and press Return at the end of each statement:
    print("Support Reactions")
    for reaction in reactions:
        print(reaction)
Your final program should look like:
from comtypes import automation
from comtypes import client
import ctypes
os = client.GetActiveObject("StaadPro.OpenSTAAD")
geometry = os.Geometry
geometry._FlagAsMethod("GetNodeCount")
geometry._FlagAsMethod("GetMemberCount")
nodeCount = geometry.GetNodeCount()
beamCount = geometry.GetMemberCount()
def make_safe_array_double(size): 
    return automation._midlSAFEARRAY(ctypes.c_double).create([0]*size)
def make_safe_array_int(size): 
    return automation._midlSAFEARRAY(ctypes.c_int).create([0]*size)
def make_safe_array_long(size): 
    return automation._midlSAFEARRAY(ctypes.c_long).create([0]*size)
def make_variant_vt_ref(obj, var_type):
    var = automation.VARIANT()
    var._.c_void_p = ctypes.addressof(obj)
    var.vt = var_type | automation.VT_BYREF
    return var
geometry._FlagAsMethod("GetBeamList")
safe_array_beam_list = automation._midlSAFEARRAY(ctypes.c_long).create([0]*beamCount)
beams = make_variant_vt_ref(safe_array_beam_list, automation.VT_ARRAY | automation.VT_I4)
geometry.GetBeamList(beams)
output = os.Output
output._FlagAsMethod("GetSupportReactions")
nodeNo = 1
loadcaseNo = 1
safe_array_reactions = make_safe_array_double(6)
reactions = make_variant_vt_ref(safe_array_reactions, automation.VT_ARRAY | automation.VT_R8)
output.GetSupportReactions(nodeNo, loadcaseNo, reactions)
print(str(nodeCount) + ' joints')
print(str(beamCount) + ' members')
print("Beam Numbers")
for beam in beams:
    print(beam)
print("Support Reactions")
for reaction in reactions:
    print(reaction)