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
Tags:
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).
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by