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
Tags:
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
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
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,
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:
(snippet expires in one month)
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