Importing .gha components in Python

The namespace to import might not be identical to the filename of the .dll or .gha assembly. You can inspect the GrasshopperTeklaLink.gha after referencing like so (for the KangarooSolver.dll here):

import System

def inspectAssembly(assemblyName):
    
    """ Inspect a .NET assembly and print its available types. The 
    assemblyName is the full name of the file to inspect including 
    its extension e.g. "Kangaroo0096.gha" """
    
    # Load the assembly and print its full name
    assembly = System.Reflection.Assembly.Load(assemblyName)
    print assembly.FullName
    
    # Iterate the types in the assembly
    for i in assembly.GetTypes():
           print i

inspectAssembly("KangarooSolver.dll")
4 Likes