Grasshopper

algorithmic modeling for Rhino

Hi,

Does there exist a way to debug rhinocommon scripts for Rhino 5.0?

I found that components in grasshopper can't figure out syntax errors before I hit Ok button, and navigating in grasshopper C# or VB.NET components seemed to be quite inefficient when there are more than one thousand lines of code. VS2010 could give me a pleasant journey when I wring code but seem to be impossible to figure out some non-syntax errors that generated by rhino. Is there a way to run the scripts in Rhino just by hitting the "debug" button on the toolbar of VS2010?

I know there is a hybrid way of writing codes in VS and copying them back to Grasshopper component but this seems to be quite laborious and not all codes can be dealt with in this way since grasshopper component does not accept multiple classes in one single component. 

Meanwhile, writing codes in VS could ensure the possibility of developing it as a Rhino plugin and also have a potential to enjoy those .net 4.0 new features.

Anyway, in one word, is there an easy way to detect and debug all the syntax and non-syntax(errors that generated by rhino) in VS2010? or, even further, to run the scripts in rhino viewport just by hitting the "debug" button and trap errors that generated?

 

Thanks,

Jerome 

Views: 2619

Replies to This Discussion

Hi Jerome,

 

not really. Grasshopper is written in VS 2008 and compiled against .NET 3.5

I do all my debugging in a similar setup. Once Rhino5 is released we'll drop support for Rhino4 and switch over to VS2010 and .NET 4.0

 

I'm looking forward to this as it will both simplify the distribution of Grasshopper and it will give me some additional cool stuff to play with.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Once Rhino5 is released we'll drop support for Rhino4 and switch over to VS2010 and .NET 4.0

What a great incentive to upgrade!

 

Isn't it just...

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Do you have shares in the sale of version 5? :))

RMA is partly employee owned, but unfortunately I'm not an employee, so no.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

:(

Thanks, David.

 

I'm looking forward to the new release and more cool stuffs like Galapagos.

 

:)

 

Thanks,

-Jerome

I'm installing 2012 express now to test.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

It works just fine using Visual Studio Express 2012.

  • Create new project (I used class library C#, .NET 4.0)
  • Add copylocal=false references to GH_IO.dll, Grasshopper.dll and RhinoCommon.dll
  • Add a post-build event to rename your dll to gha.
  • Modify the *.csproj file to have the debug start action specified as VS Express has no UI for this. For instructions, see: http://stewartr.blogspot.sk/2006/09/debugging-nunit-in-visual-studi...
  • Write a basic component.
  • Set a breakpoint.
  • Start debugging, the breakpoint gets hit.

Do be sure to uncheck the Memory Load option in _GrasshopperDeveloperSettings otherwise debugging will never work.

I attached the entire project in case you want to have a look.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Attachments:

I think that you cannot change that: if you hit Debug, VS runs Rhino and GH. When you hit stop, everything is closed. Try to use Pause button, perhaps it could help a little letting you change some code (as far as I remember...I need to go back to coding again ;))

Unless you can get Edit-And-Continue to work (which I have never been able to) you have to close Rhino, rebuild the project, start Rhino again.

I know this is annoying, but on the other hand if you're hitting breakpoints then I find it's usually just a matter of debugging once until you find the problem.

If regular breakpoints get hit too often, you can always put a condition on a breakpoint. That is a very useful feature when you have to debug a line that gets called a lot.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

If you want to start Rhino, start Grasshopper and load a GH file from within Visual Studio then I think you'll need to use Rhino command line arguments. I've never done this before though, no idea if it will work.

You'll probably want to add /nosplash and /runscript

Since the script you're running will involve RhinoScript calls you may want to create an *.rvb file on your desktop (or some other easily accessible location) that does all the loading. Then invoke this script via the command line arguments.

I'll see if I can get something working.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service