Grasshopper

algorithmic modeling for Rhino

Hi,

I have some python scripts that wished to create a grasshopper plugin out of them.

Does anyone know how to compile python script into a gha plugin by not using the ghuser method? And is it possible to import classes that are stored in .dll or .py and could be referenced from the default folder of grasshopper? 

Thanks in advance!

Kenneth

Views: 2049

Replies to This Discussion

you cannot create a GHA with python. Rhino 6 WIP includes a version of grasshopper with this functionality (although I think it creates a "GHP" rather than a GHA if memory serves). 

As for referencing dlls - I believe you can use something like the following:

import clr

clr.AddReferenceToFileAndPath("PATHTOYOURDLL')

import YOURLIBRARYNAME

and you should be able to import python libraries (that are ironpython compatible and located somewhere python knows about them - try the python editor in rhino to check those paths) just using an import statement.

I am not sure how you refer to an external python file from the default grasshopper folder - this might help.

It is actually possible to compile IronPython code to a .dll which you can then reference/import in your scripting/userobject components (that is, as opposed to .py files). That said, this is probably only worth the effort if you're worried about people not peaking at your code. To reference/import assemblies (or .py files) in your Grasshopper libraries you can add this path in the script itself, or, hardcode the path in the RhinoPython settings using the EditPythonScript editor (see point B here). 

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service