Grasshopper

algorithmic modeling for Rhino

Hi,

I am doing some multi-threaded intersections(brep&surface) using C# in grasshopper  following the example in http://www.nzarchitecture.com/blog/index.php/2011/05/07/threading-g...

I am now testing on very simple geometries and wish to apply the component to hundreds of geometries later on. The problem is every time I start making intersections(set the boolean toggle linked with "Go" to true), Rhino crashes after two or three seconds of no response. 

Ignore those displaypipeline things which mean to visualize the offset cutting plane.

 

Thanks,

-Jerome

Views: 815

Attachments:

Replies to This Discussion

Are you doing this in Rhino4 or Rhino5?

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Hi, David

I'm doing this in Latest build of Rhino 5(2011/09/27) and with grasshopper 0.8.0052.

 

Thanks,

-Jerome

Hi Jerome,

 

sorry, there's way too much code there to debug. I've never used the ThreadPool before so this is as new to me as it would be to anyone else.

 

I'm no fan of static variables in conjunction with threads though, that's just asking for problems. 

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Thanks, Daivid

 

Yes, I don't like these ThreadPool things either. The .Parallel namespace in .net 4.0 really helps a lot in the parallel programming and let me abandon ThreadPool things, but that namespace is not referenced and cannot be used in C# component in grasshopper. Seems that I have to use VS2010 to do this.

Thanks!

 

-Jerome

Just some minor changes and it works.

It turns out that script was throwing a NullReferenceException on a ThreadPool thread because the "result" list was not instantiated. There is a bunch of stuff you should be careful with while using threading. I am not even 100% positive I handled all cases here (also, I do not think that registering so many delegates is the best idea). Definitely it did not crash Rhino after a couple attempts.

I hope it helps getting started with multithreading a process with breps,

- Giulio
_____________
giulio@mcneel.com
McNeel Europe

Attachments:

Thanks, Giulio

I've read your code and felt it is quite important to handle exceptions and use atomic operations where necessary. I learned a lot from your code and it turned out that the threaded code runs 90% faster on my old intel Centrino Duo Core laptop.

Thanks!

-Jerome

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service