I just discovered a nifty trick for accessing extension methods in (Iron)Python scripts. Namely, clr.ImportExtensions()
. The example below leverages the extension methods that add Rhino/GH interoperability to Plankton.
"""Provides a scripting component.
Inputs:
m: an input Rhino.Geometry.Mesh
Output:
a: a bunch of face polylines"""
import clr
clr.AddReferenceToFile("Plankton.dll")
clr.AddReferenceToFile("Plankton.gha")
import Plankton
import PlanktonGh
# import class containing extension methods
clr.ImportExtensions(PlanktonGh.RhinoSupport)
# import mesh via Rhino.Geometry.Mesh extension method
pmesh = m.ToPlanktonMesh()
# TODO: do something exciting with our new halfedge mesh
# export polylines via Plankton.PlanktonMesh extension method
a = pmesh.ToPolylines()
via http://stackoverflow.com/questions/628482/can-you-use-linq-types-and-extension-methods-in-ironpython