Grasshopper

algorithmic modeling for Rhino

VB.net scripting crashes (and legacy doesn't) with recursive algorithm


Hi all,

 

this is a strange issue I have noticed revamping an old script I did in VB.net some time ago (the Peter De Joong attractor); in fact so long ago that the component I wrote it into now belongs to the legacy.

 

As an exercise, I wanted to rewrite the same script on the new VB.net component (and eventually in C# as well); when the old legacy VB.net can go up to 5000 points without problems, the new VB.net makes Grasshopper and Rhino crash at once (without even letting me send a report).

 

EDIT: the crash in the new VB net happens far before reaching 5000 points (around 1000 or so). Sorry, forgot to specify this.

 

Since the old legacy VB.net will be dismissed in the future, I would like to find what causes the issue (and eventually get it fixed). See attached definition.

 

Thank you all in advance.

 

Alessio

Views: 805

Attachments:

Replies to This Discussion

I think you're just running out of stack space on your recursion. This algorithm is better suited for an iterative approach I'd say.

 

Eventually recursion always runs out of stack space which always results in an immediate and message-less crash. If your recursion goes deeper than a few hundred levels, it's time to re-evaluate your approach.

 

(80,000 points)

 

Attached an iterative version of this algorithm.

 

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Attachments:

Thank you David, that helped me a lot!

I was just trying to implement some recursive algorithm and I found attractors a good exercise, but I didn't think about the stack issue.

 

A question just out of curiosity: is the difference in the crashing point between actual VB and legacy in my algorithm due to a difference in the class structure of On3dpoints and Point3D, or is it something else?

 

Thank you again for the immediate help!

 

Alessio

It's a good question. I wish I knew.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

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