Grasshopper

algorithmic modeling for Rhino

I'm trying to write my first GH component which will link to an analysis software(SAP2000).

The documentation of that program has an example in both VBA and c#. When I copy the example in VBA in a VB script, it works fine, however if I copy the example in c# into a c# script, it doesn't recognize the methods. The help files outlines additional steps when coding in c#:

""1. Create a new Visual C# 2005 Console Application project.

2. Add a reference (COM) in the project to the Sap2000.exe.

3. Paste the following code inside function Main():

//dimension variables

Sap2000v15.SapObject mySapObject;

Sap2000.cSapModel mySapModel;

int ret;

int i;""

Is there a way to still script inside a grasshopper component in c# or should I switch to using VBA?

Views: 3948

Replies to This Discussion

VBA is not the same as VB.NET, which is what Grasshopper uses. VBA is based on VB6 which was a pre-.NET language.

References in Grasshopper are typically to *.dll files, not *.exe files. Something as advanced as this may require you to use Visual Studio (Express) instead of the standard scripting components.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

I'm sorry I meant VB .NET rather than VBA. The API also provides a *.dll file. How do I reference to it inside a c# script?

Same way you reference it for a VB script. Script component menu, Manage Assemblies. Then click on add and select your dll.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Thanks a lot. That did the trick :)

Hi Antony,

You can script into SAP from Grasshopper, although it will take some work to do so.

Are you aware of the plugins I develop that allow generation of a SAP model from Grasshopper components?

http://geometrygym.blogspot.com/search/label/SAP2000

This includes various data structures to permit node collapsing and similar model smarts.

You'll find a good independent reference for the tools here:

http://www.thorntontomasetti.com/blog/post/30-We-%3C3-the-Geometry-...

If you wish to try it out, get in touch and I'll be glad to oblige.  Of course I'm not discouraging your from developing your own (others have), it might save you a lot of work.  As some starting advice, I wouldn't script from components (if you decide you need to make changes later on, you're left with work and problems to manage this).  Creating custom components from visual studio (or similar) is a much better idea.

Cheers,

Jon

Hi Jon,
Have you got any example of scripting using SAP2000 API?
I found a video where you used something with IFC but it wasn't helpful for me.

Hi Marco,

Have you checked the sap2000 help documentation?

Check for file C:\Program Files (x86)\Computers and Structures\SAP2000 17\CSi_OAPI_Documentation.chm  

If has some samples. There are some other discussions if you search the grasshopper and rhino forums.

http://discourse.mcneel.com/t/stuck-adding-a-net-dll-reference-in-g...

Of course Grasshopper is really a graphical programming environment.  If you want to use my plugin as a rhinocommon wrapper to the SAP2000 api, it's not documented or particularly user friendly but I can tell you the methods to use from the Geometry Gym dll.  If you wanted to start with some pseudo code demonstrating what you would like to do, I can help with this.

Cheers,

Jon

Hi Jon,

I already checked the sap2000 OAPI documentation and it will be helpful.

Geometrygym add-on was very helpful in my "normal" scholarship project but for my last project, I need to create a loop with Genetic Algorithm that they are going to optimize the shape and the stress on tendon around a torus.

You could create a Tendon element inside GeometryGym but I think it's time to go inside programming and using of API.

By the way.

I attached a file of an early studio of this project.

The rhino woolbar say" Unable to extract results for elemement ggGHfrm..."

Cheers,

Marco

Attachments:

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service