algorithmic modeling for Rhino
Hello,
Since there are a couple of methods I have written in GHPython that I find myself using often, I would like to create my own library that I can call my methods from.
I'm guessing that this might even make my definitions quicker...Is that true?
What I did so far was to open EditPythonScript in Rhino, write my sample definition in the same format as other modules (such as curve.py) and save my script as "myownstuff.py" in the same path. I thought this might suffice, but I don't even know how I would import/call my functions. I was hoping it would be as simple as writing:
import Rhino.myownstuff
myownstuff.myrectangle(pt1,pt2)
One problem might also be that in my sample function I am using rhinoscriptsyntax:
I've already found some answers to this question (I think), but they are too vague and technical for me as a non-programmer to understand. I might be using the wrong search keywords, in which case I'd be glad if you could direct me to an appropriate page.
Otherwise, if somebody could provide a little step-by-step guide on how to do this, that would be really helpful!
Cheers,
Max
Tags:
Hi Max, Python modules are actually pretty simple. They are just folder structures with .py files that contain functions and classes and what not. You can have a look at the rhinoscriptsyntax module to see how the McNeel boys organized that one*. So the most basic module might look something like the attached file. If you place this file in any of the folders which your RhinoPython can access, you should be able to import foo and then call foo.bar() which should print out hamSpamEggs.
*usually somewhere here: C:\Users\YOURUSERNAMEHERE\AppData\Roaming\McNeel\Rhinoceros\5.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript
Edit: I can't imagine that I will make things compute faster as it is still not compiled code, like when developing a .gha with C# or VB.
True, that is actually really straightforward.
Thanks Anders!
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
© 2024 Created by Scott Davidson. Powered by