algorithmic modeling for Rhino
Being able to use Python in Grasshopper opens up Grasshopper to tons of excellent scientific computation and simulation libraries, including NetworkX.
Using NetworkX for the first time, I was able to translate the topology of a Rhino Mesh into a NetworkX Graph object, and then I used a custom function to weight the edges between nodes. In this case, the weight between any two mesh vertices is the distance multiplied by the difference in height, causing a least cost path algorithm to find the shortest, flattest paths between two points.
The python code can be viewed here:
https://gist.github.com/1057297
Tags:
Hi,
Thanks for your code, it's very interesting.
It's possible using NetworkX for geodesic courbe in respecting geometric conditions.
The conditions may, for example on straight or curved.
Thanks for share
Hi,
An error occurs.
looking at your code I understand that I can not access this:
pathbits = [
'C:\\Program Files (x86)',
'Python26',
'Lib',
'site-packages'
]
There are a few things that you need to do before you can use the script:
Thanks,
But where I can download Networkx...
Thanks benjamin,
The file is: networkx-1.5-py3.2.egg ?
If all you want to do is get this working, and you don't want to learn to use python outside of Rhino (which is of course what networkx was made for), then you should just try downloading the source: networkx-1.5, unzip it, and then look inside for the folder named 'networkx'. You can move this folder where you want, but be sure to edit the 'pathbits' portion of the script to point to the folder that contains the folder called 'networkx'.
If you want to understand how to use python packages in general, you should do some googling, and install your own version of CPython, then setuptools, and pip. Maybe later I will write a tutorial on this topic.
Sorry,
I've download netwokx and to place to folder :
C:\Program Files\Rhinoceros 4.0\Plug-ins\RhinoDeveloppements\RhinoRoad\Script\Python\networkx-1.5
and i've writen in the code python:
pathbits = [
'C:\\Program Files\\Rhinoceros 4.0\\Plug-ins\\RhinoDeveloppements\\RhinoRoad\\Script\\networkx-1.5\\networkx'
]
importPath = os.path.join(*pathbits)
sys.path.append( importPath )
import networkx
G = networkx.Graph()
G.add_nodes_from(range(mesh.Vertices.Count))
And i've change GH file for read a file in the good folder.
But don't working, runitme error: 1.Solution expetion: EOL while scanning a single line quote string.
Thanks for share it
pathbits = [
'C:\\Program Files',
'Rhinoceros 4.0',
'Plug-ins',
'RhinoDeveloppements',
'RhinoRoad',
'Script',
'networkx-1.5',
'networkx'
]
importPath = os.path.join(pathbits)
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