Grasshopper

algorithmic modeling for Rhino

I have problems in calling ShortestWalk with ghpythonlib.components, what am I doing wrong?

# how do I reference ShortestWalk with python?
shpath = []
for i in range(len(C)):
   shpath.append(ghcomp.ShortestWalk.ShortestWalk(C[i],lines)[0])


What am I missing?

Example attached.

Best regards 

Kristoffer

Views: 1614

Attachments:

Replies to This Discussion

Hi Kristoffer,

You should iterate through lines list not curves (you always supply all of the curves. It's just the line end which changes - the destination point).
Then, second input for Shortest Walk component is the length of all curves.

In the end, when using Shortest Walk component, your initial curves have to be shattered. Systemiq had a nice solution for this.

Attachments:

Hey djordje

This is exactly what I want to do...  But all from inside the python environment... all I am missing is the ShortestWalk reference but I can't figure out how to do that. I took care of the pre processing of curves and atomized them, shattered them and so on in the python module attached before.

I changed the Shortest Walk function call too.
Have you checked the attached ghpython component from my last post?

Now I see.

I completely missed the Length.(line) part. I am grateful, thank you djordje.

/K

On a side note, if you're implementing graphs in your Python code I would consider using the NetworkX module. I've used it quite extensively on a couple of projects now. Note that versions after 1.5 do not work well with IronPython. /Anders

Very interesting Anders. Thanks for sharing it.

No worries, glad you found it interesting :)

I might do that.

Thanks Anders 

Sorry, can you reference me to a source where I can learn how to use external libraries within grasshopper or write a short example how you use networkX within grasshopper. The projects are really interesting. Furthermore can you try to compare the SpiderWebs components to NetworkX. Thanks Anders

Hallo Dimitar,

I don't know NetworkX but the biggest difference to SpiderWeb is that it is a python library. SpiderWeb is a .Net library. NetworkX seams more complete than SpiderWeb, as it is still under development and this is done by a single person... . So the development is strongly tide to the interest of the developer (me). However with the next release SpiderWeb will be more advanced concerning spectralGraphAnalysis... (if this is of interest of you)....

However there is a basic introduction using SpiderWeb dll's in Grasshopper under:

http://www.gbl.tuwien.ac.at/_docs/GrasshopperScriptum/GrasshopperSc...

Hope that helps. 

A further note: I don't know the ghpythonlib.components but it sounds like you are calling the functionality within grassshopper components not directly but via the interface of the grasshopper component which sounds like a really slow way to do it.

I made a short post about how to import Python modules here. For NetworkX you need to download the 1.5 version and extract the folder simply called "networkx" from the zip file (networkx-1.5.zip\networkx-1.5\networkx). Copy paste this folder to a directory path which is read by Rhino Python and you should be good to go. The NetworkX documentation is pretty solid and has some basic tutorials for getting started. I think Ben Golder also did a post here on the forum a while back demonstrating how to use it. I've not used SpiderWeb, but it sounds like Richard's description is pretty spot on :)

I have a problem,

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