Importing .gha components in Python

Hi everyone,

I am very new to grasshopper and Python.

I am struggling to use the GrasshopperTeklaLink inside my Python, but not able to access the same.

I got an error that “No module named GrasshopperTeklaLink” while importing in the Python (as shown in the picture)

Please someone help me to sort this out and thanks in advance.

Kind Regards
M. A. Mohammed Riaz

I don’t have GrasshopperTeklaLink installed, but here is an example of using Plankton in GhPython:

import clr
import Grasshopper
clr.AddReferenceToFileAndPath(Grasshopper.Folders.DefaultAssemblyFolder + "Plankton.dll")
clr.AddReferenceToFileAndPath(Grasshopper.Folders.DefaultAssemblyFolder + "Plankton.gha")
import Plankton
import PlanktonGh
1 Like

Hi Mahdiyar,

Thanks for your reply and suggestions.

I dont have any kind dll file for grasshopper tekla link and I tried as you mentioned but still it is not working.

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


Hi Anders,

Thank you for your suggestion, I got the point and I found that GTLink is the namespace for import.

Once again thank you for the solution.

1 Like