A Place to Share Python Scripts

I just started a new github repo for sharing python scripts for Rhino and Grasshopper:
www.github.com/localcode/rhinopythonscripts

If you'd be interested in sharing scripts, please feel free to check it out (or fork it, as the case may be).
I'd love to share ideas about how to work with python in Rhino, using a shared repository. You can also fork it and edit the documentation, add examples, or whatever you want. I was simply hoping to start a somewhat informal way to share scripts that could grow into something really helpful.

I just put it up within the past few hours, so what I've done so far is poorly documented and incomplete, but I'll certainly be adding to this on a regular basis.


Cheers,

Ben

  • Benjamin Golder

    Added a bit more.

    There's a nice new module called "RunCPythonScript" for running scripts that don't work too well in IronPython. It let's you run scripts on other versions of python that you have installed on your computer.

  • Benjamin Golder

    Added GeoJson2Rhino script which translates GeoJSON objects (a common data format for GIS) into Rhino Objects. It still needs some testing, but most of the work is done. Please try it out if you have any GeoJSON data around.

    GeoJSON format:

    http://geojson.org/geojson-spec.html

    also, this will hopefully play nice with the PostSites module I've been working on, for importing GIS site data from a database using PostGIS.

    PostSites module:

    https://github.com/bengolder/postsites

  • Saeran Vasanthakumar

    This is a great resource. I've been trying to work around the fact that I can't install the geojson module directly into RhinoPython, and finding this should save me a lot of trouble. Thanks for starting this. 

    But before I can engage - I'm having some trouble trying to load a geojson file using your GeoJson2Rhino function.

    Right now my script looks like this:

    import rhinoscriptsyntax as rs  
    import sys rp_scripts = "rhinopythonscripts"
    sys.path.append(rp_scripts)
    import rhinopythonscripts
    import GeoJson2Rhino as geojson

    layer_1 = rs.GetLayer(layer='Layer 01')
    layer_color = rs.LayerColor(layer_1)

    f = open('test_3.geojson')
    gj_data = geojson.load(f,layer_1,layer_color)
    f.close()

     

    In particular:

     f = open('test_3.geojson')  
    gj_data
    = geojson.load(f)

    works fine when I'm trying to extract geojson data from regular python 2.7. However in RhinoPython I'm getting the following error message: "Message: expected string for parameter 'text' but got 'file'"; in reference to the "gj_data = geojson.load(f)" line.

    I've been looking at the GeoJson2Rhino script and I think I've set the parameters for the function correctly. Is the issue the way I'm trying to open the file?