Grasshopper

algorithmic modeling for Rhino

Hello there,

I am trying to split a brep, take one splitted part, transform it. Then, collect the transfromed part in a list and apply same rules to collected breps as splitting, transforming and collecting. So, I have written a piece of c# code in Grasshopper which I thought it might work, but it gives me the error saying "the collection has been changed". 

Is there anyone who might know where is the problem? I have attached the Rhino and grasshopper files. 

Thanks in advance, 

Irem 

Views: 823

Attachments:

Replies to This Discussion

When you use a foreach loop to iterate over all the items in a collection, you are not allowed to modify that collection within the loop. 

If you want to operate on a collection of objects and each iteration may append more objects to that collection, I recommend creating a Queue<T>, and popping items off the top from within an infinite do loop. Exit the loop once the queue is empty.

As David said.

But ... well ... if I got it correctly(?) this is a classic recursive task

See attached.

Try to use the DO NOT use Method as well (only for the brave):

Attachments:

Anyway ... added this %$@%$ Method as an option for the brave (but why it fails? who knows? and who cares?).

Attachments:

Thank you for replies :) I have solved it with a function just returnes the splitted brep output to be used as input in a while loop. And the rest I arranged with array lists. 

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service