Grasshopper

algorithmic modeling for Rhino

How to get one branch out of a tree and store it in a list? in C#

Hi all,

till now i've got this code:

 

protected override void SolveInstance(IGH_DataAccess DA)

{

GH_Structure<IGH_Goo> tree = new GH_Structure<IGH_Goo>();

 

DA.GetDataTree(0, out tree);

 

tree.get_Branch(0);

 

and just for a test I did it in the output and it works

DA.SetDataList(0,tree.get_Branch(0));

}

 

But I want to take several branches with a for loop and store them all seperately as lists called for example branch 1 to i, which I can use later for further evaluations.

Would be the same like in Grashopper the explode tree component.

But in C# there is no explode method or something like that.

 

Can somebody help me please? Didn't find anything till now in the other discussions.

Views: 2431

Replies to This Discussion

Ok, attaching files seems not to work at the moment, one more try

Attachments:

Well ... as I said I run an AEC practice so it's rather obvious that I know what Sofistik is, he he.

Good news: Armed with a dose of software aids (notably cigars, espresso and ... Vodka [ as Plan Z ]) I'll try to write some lines with regard that problem of yours.

Better news: Speaking about PSO stuff (in the broad sense)  get this V1 PSO-demo thingy (V3 is under way: it does A LOT of things more: viz the particles, work with physical surfaces/breps AND/OR equivalent equations etc etc).

best, Peter

Attachments:

Haha okay sorry couldn't imagine what AEC is.

 

Wow sounds great!!

 

Good News and Better News haha like christmas and easter in one day

Thank you Peter you made my day :-)

If you need anything like cigars, espresso, beer or Wodka, how can I supply you :D

 

Just had a short look on this V1-PSO Demo but has some nice features and is close to my approach. I'll immediatly have a closer look at it:-)

V3-demo sounds really interesting let me know, when it works:-) 

 

Wow you helped me already so much.

Now I see a small light in the Tunnel of my Master Thesis :D

Well ... shedding light on (Note: the dark option - obviously) is my specialty, he he.

BTW: Although "remotely" relevant (if at all) not to mention that there's NO C# stuff around (therefor the def is off-topic in this Forum) ... get this classic as well (Anemone plug-in required).

BTW: Recommended Anemone loop(s) soundtrack: https://www.youtube.com/watch?v=ZgdufzXvjqw

more soon, best, Lord of Darkness

Attachments:

And that (attaching more than one thing appears impossible)

Attachments:

Ok, thanks for the examples and the ideas..

Sorry couldn't here the Song the whole time, was my alarm clock every morning for some years--> bad experiences:D

 

So you recommend not to do everything with C# and instead doing it with GH and Anemone?

Bacause loops and taking a value from GH in C# is also possible.

BTW:  I WOULD strongly recommend (at any cost, he he) to do everything with C#. Too many reasons for that to list them here.

Examples with Anemone posted just for the record.

Ah ok, well I'll try to do so;)

Maybe I'll first try a mix of little things in C# and the loop of anemone.

Thanks for your help!

Maybe one more question:

Why does this Code give out B?

double[] array = new double[List.Count()];

List.CopyTo(array);

double x_0 = array[0];

B = x_0;

And this one not?

double[] array = new double[List.Count()];    

List.CopyTo(array);

for (int i = 0; i < array.Length; i++)    

     {      

          double x_i = array[i];      

          return;    <--- doesn't work if left or not

     }

B = x_0; --> Error: x_0 isn't given in the context.

    List<double> dList = new List<double>(){3.4,5.6,7.8,9.0};

    double[] listToArray = dList.ToArray();

    double x_0 = listToArray[0];   // this makes x_0 == 3.4
    double x_i;
   

    for (int i = 0; i < listToArray.Length; i++){
       // this assigns 4 values to that x_i thingy (the art of pointless)

        // making (finally) x_i == 9.0 (from NY to DC via LA, that is)

       x_i = listToArray[i];    
    }

BTW: Old dogs, new dogs : http://www.codeproject.com/Tips/1023426/Whats-New-in-Csharp

Thanks for your example, but this doesn't work in GH C#

 

I mean it works just until the outout, but when I want to give out x_3 for example:

 

A=x_3;

it doesn't work?

In Visual Studio this works with Array, for, Console.Writeline etc.

 

But doesn't matter, I found a better solution, where I don't need this step.

...Doesn't work...

Well ... you've misinterpret what x_i is: is NOT an indexed thingy it's just a stupid name: it could be x_variable_ending_with_i or x_stupid_name_y or whatever ... meaning ... that ... er ... hmm ... I would strongly suggest Plan B:

How to get the gist of C# in just 123 (+1) easy steps (I've already posted that 3-4 times if memory serves well):

Step 0: get rid of the computer (press the OFF button), buy some cigars:

Step 1: get the cookies

The bible PlanA: C# In depth (Jon Skeet).

The bible PlanB: C# Step by step (John Sharp).

The bible PlanC: C# 5.0/6.0 (J/B Albahari) > my favorite

The reference: C# Language specs  ECMA-334

The candidates:

C# Fundamentals (Nakov/Kolev & Co)

C# Head First (Stellman/Greene)

C# Language (Jones)

Step 2: read the cookies (computer OFF)

Step 3: re-read the cookies (computer OFF)

...

Step 120: re-read the cookies (computer OFF)

Step 121: tun ON computer

Step 122: do something

Step 123: shut down computer permanently,  forget all that

May The Force (the Dark Option) be with you.

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