Grasshopper/dev

This sketch folder has work-in-progress that might not yet be considered stable.

GHPython Block Scripts

These scripts are run using GHPython semantics: the block inputs are provided as global variables, the block outputs are read from global variables, and objects are translated as per the menu settings for each input or output port.

CSV1.2Loader.py

# CSV1.2Loader.py - the v1.2 CSV mocap data file loader script inside the eponymous GhPython object.

# Demonstration of parsing an Optitrack motion capture CSV file.
#
# inputs
#   path    - string with the full path to the CSV file
#   stride  - the sequence interval between successive points; 1 returns all points, >1 subsamples
#
# outputs
#   out      - debugging text stream
#   names    - data tree of body names
#   planes   - data tree of Plane trajectories, one branch per rigid body, each leaf a list of Planes

# set up the Python load path
import pythonlibpath
pythonlibpath.add_library_path()

# import the OptiTrack CSV v1.2 file loader
reload(optitrack.optiload)
import optitrack.optiload

# load the file
take = optitrack.optiload.load_csv_file(path)

print "Found rigid bodies:", take.rigid_bodies.keys()

# emit all return values
rb_names = take.rigid_bodies.keys()
rb_planes = optitrack.optiload.all_Planes(take, int(stride))
rbm_names = optitrack.optiload.rigid_body_marker_names(take)
rbm_points = optitrack.optiload.rigid_body_marker_points(take, int(stride))