+ Reply to Thread
Results 1 to 6 of 6

Thread: python development environments

  1. #1

    python development environments

    Hello,

    I started looking at python and rhino (win7) recently and had some questions regarding which python development environment is recommended. It looks like there are 3 ways:

    1. TestInteractivePython

    This brings up the python shell allows me to write python scripts outside with my favorite text editor. If I do

    import sys
    sys.path.append ("my/path/to/my/scripts")

    then I can import my python scripts and then call them from the python shell. It's great. But I find that when the python shell is active, I am not able to select rhino objects. I can select objects only after exiting the python shell. I feel most comfortable with this but seems painful to go back and forth all the time.


    2. EditPythonScript

    This brings up the built-in IDE. Do I have to edit the scripts in the editor provided? Can I import scripts? How do I add a command similar to what's described in http://python.rhino3d.com/threads/27-Add-a-command but for the windows 7 environment? How would I import other modules like gecode (http://pypi.python.org/pypi/gecode-python/) into it?


    3. Rhino.python for grasshopper

    This allows me to embed python scripts inside grasshopper. This looks useful for creating knobs and sliders GUI to attach to my python scripts but it seems this would be useful most likely for small/medium python scripts before the run time becomes an issue. Grasshopper looks cool but for complex programming I would prefer to implement it textually so I can use some SCM and IDE, etc.


    So, I'm leaning towards #2. Thanks for your suggestions and comments.

  2. #2
    Hi Robert,

    welcome to the forum.
    Yes, the _EditPythonScript editor is the place where we write most scripts to automate specific tasks. I've answered some general questions I had, too, about the environment here:
    http://python.rhino3d.com/threads/67...t-have-like-me

    On the other hand, you can use the interactive editor and the GhPython component to test some code quickly with different values. The idea is that the code can run mostly unchanged.

    >>Do I have to edit the scripts in the editor provided?
    Not really, you can use any text or code editor, even Notepad (I would not recommend that editor for this task though).

    >>Can I import scripts?
    If you mean modules, the answer is yes. Also if you mean reading text, the answer is yes. All you need to make sure to import modules, as you already noticed, is that the path to it can be found by the runtime.

    About the question of commands, I'd say that it is supposed to work also on Windows. I haven't looked too carefully into that lately, though. The idea for the release of Rhino.Python is surely to have that working.

    >>How would I import other modules like gecode into it?
    1) Make sure that the path can be found 2) Type "import ..." or any other normal Python import statement
    The example you provided is a big exception, though. gecode is not written in Python, so it cannot be referred to as a "Python module" only, it is a wrapper/binding module to a C++ library. Rhino currently uses a .Net implementation of Python, called IronPython, to be able to execute its code both on Windows and on Mac. To make the story short, this means that we cannot import gecode easily, just as we would do with normal Python modules, because the C++ part is not meant for the Python runtime used in Rhino.

    Does this help, at least a little?
    Thanks,
    - Giulio
    ___________________
    giulio@mcneel.com

  3. #3
    Hi Giulio,

    Thanks for taking the time to respond. They were very helpful indeed.

    Regarding gecode, would it work if I provided a DLL? Perhaps someone has tried this with other packages, and not particularly gecode.

    Cheers,
    -Robert

  4. #4
    Senior Member Steve Baer's Avatar
    Join Date
    Apr 2010
    Location
    Seattle
    Posts
    1,464
    Blog Entries
    19
    Hi Robert,
    The only way to access gecode would be if there were a .NET binding for the C++ library. Anything in .NET can be access by python in Rhino.
    Thanks,
    -Steve

  5. #5
    Thanks Steve. I'll start down the path of compiling gecode with visual studio 2010 (?), and share what I find.

    -Robert

  6. #6
    Senior Member Steve Baer's Avatar
    Join Date
    Apr 2010
    Location
    Seattle
    Posts
    1,464
    Blog Entries
    19
    You might want to look around and see if someone else has already started writing .NET bindings for this library.

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts