Grasshopper

algorithmic modeling for Rhino

Hi All,

 

Is there a way to install python modules into rhino.python ?

 

Like this one right here :

http://code.google.com/p/pymaps/

 

thx 

\sander

Views: 6268

Replies to This Discussion

Woah, you want to use a python-based web-mapping module that outputs javascript code in grasshopper? I'm really curious where this is going!!

 

In this case, the code in question (pymaps) is only one module (pymaps.py).

 

if you save this file into a location on your path (what's your path? more in a moment ...), you can simply type:

 

import pymaps

 

and then you can start using things from the module:

 

mymap = pymaps.Map()

mymap.height = '960px'

 

So what is your path? well, it's easy to find out. In your python code, you can always access your path with:

 

import sys

for folder in sys.path:

print folder

 

which should print out a list of folders that python uses to look for modules. if your module (in this case the pymaps.py file) is in one of those folders, you can just import it as described above.

 

If your module is not in one of those folders, you can just put it there, or you can add a new folder to sys.path like this:

 

import sys

pathToMyFolder = '/path/to/my/folder'

sys.path.append(pathToMyFolder)

 

import pymaps

 

 

is there an easy way to input code on this forum? because it seems to destroy the formatting. 'print folder' above should be indented.
When I last checked, it was close to impossible to write python code samples on the Ning system (the system this site is running on.)  This is one of the main reasons we switched over o a vbulletin based system for the Rhino.Python web site.  Things may have changed on Ning since it was over a year ago when we switched to vbulletin.
Seems like something Ning would have a strong interest in supporting, if they haven't started to do so already.

You'd think so wouldn't you? Writing VB and C# is also pretty rough going.

 

I hope they take note and allow for both monospaced inline text and proper code formatting.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Have they said no? Has anyone requested it?

I did send them a list of formatting features that would be most welcome, but this was a while ago, I'll send them again.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

You can also adjust the search paths by running the "EditPythonScript" command in Rhino and adjusting the paths in the options.  Grasshopper python should be paying attention to this.

Thanks,

-Steve

cool, that should be simple. 

but what happens in the case of libraries which are not a single file (like xlrd for example, http://www.lexicon.net/sjmachin/xlrd.htm)?

 

I guess I'd have to install Python or IronPython separately and then add the library path to rhino?

or am I completely off here?

 

Thanks!!
Daniel 

Hi Benjamin,

This looks like a good way to import modules. However, I tried it and it didn't work. Is there any alternative?

Thanks,

Also, as a note, the Google maps API used by this might be deprecated, and you'll need to edit the code in pymaps.py to use your own google maps api key. If you have trouble with pymaps, and you want to look at other python/javascript web mapping tools, you might want to check out Mapnik, modestmaps, tilestache, geodjangopolymaps, mapstraction and openlayers.

Hi all,

thanks for replying.

I basically wanted to reproduce the openstreetmap python script using the google api and I was in kind of a hurry, never a good combination.

I agree pymaps is not the module I need, what the openstreetmaps python module lacks is a way to search for street + housenumber. Plus, the google api is much more mature.

According to http://code.google.com/apis/maps/documentation/staticmaps/

an api key is no longer necessary.

Also, to be able to provide a finer grain of input, one could use google geocoding api:

http://code.google.com/apis/maps/documentation/geocoding/#Geocoding...

This interprets an address and returns a (among other things) lat/long coordinates.

 

I think the openstreetmap python script can be adapted to issue a http request for geocoding, interpet the JSON or xml response and issue a http request for the image.

Let's just hope the scaling behaves the same way as the openstreetmap.

 

Also, how about using/deploying a pastebin  for code snippets ?

dpaste.org:

http://dpaste.org/OP0N/

(snippet expires in one month)

 

 

 

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