Grasshopper

algorithmic modeling for Rhino

Hi everyone!

I had an attempt at inputting excel data into grasshopper using this tutorial:

Each time I chucked it into the VBscript component, it goes red.

I'm just trying to get a grid out of longitudes and latitudes and my own heights.

Also, do I just open microsoft excel and it should work directly?

Attached is my sad attempt:

Would be really grateful if someone could help me!

Cheers,
Ra

Views: 490

Replies to This Discussion

Ra,

It will work if excel is already open (ie. is an acitveobject that you can get). You could also just do:

dim excel as Object
excel = CreateObject("Excel.Application")
excel.Visible = True

Then you need to create a workbook (excel.workbooks.add or open) and worksheet (workb.ActiveSheet). To grab / send data I like to create a 1D array, set a range (workS.range("A1","A4")) of the same length and go inRange.Value2 = inputArray. [or you could go the other way too]

When you are finished you should set excel = Nothing. Go to your task manager (Ctrl+Alt+Del, then task manager>processes tab) to check if Excel.Exe is still running after your component is finished.
Hope that gets you started!

Ben

(I posted an example file in the Samples and Examples group that uses excel, maybe it could be useful to you?)
You really DO NOT want to go about connecting to Excel in this way. Essentially with that code you will be opening up and creating a new instance of Excel every single time a GH solution is recalculated, which has the potential to open up a couple dozen instances of Excel. Setting Excel to Visible allows you to at least see those instances instead of having them running with no UI, but the overhead for opening up an instance of Excel with UI is significantly more than running it without UI so that will slow things down.

This is main reason why I figured out the hoop jumping with the interop/marshalling stuff. That way you only have one instance running and the component itself doesn't actually create the instance. After you have that instance of Excel, you can still deal with it the same as if you created it yourself.
You might want to check out gHowl (http://www.grasshopper3d.com/forum/topics/ghowl-interoperability) as there's a spreadsheet component built in that may get you where you want to go. Just email gHowl[at]gmail[dot]com and we'll get you setup. At the moment gHowl uses OpenOffice for its spreadsheet support, so you might want to download that if you don't have it installed on your computer already. Its free and you can get it at www.openoffice.org

That tutorial is just about connecting to Excel, so if you're not familiar with actually getting data out of Excel, then there's still a lot more work to do.

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