How to extract a group of DataTree Branches in C#?

I am using DataTree to store both Floor and programs information. {A,B}[i], A refs to levels, and B refs to layerIndexes. [i] as breps to represent actual floors.

I am run into problem that I want to extract pathes which have the same value A. Then i can how many B in A? for example, i want to get all [-2,B][i] as a group.

is there easy way in C#?

Assuming that you know the basics of C# (classes, queries (LINQ) etc etc):

Create a custom class with Properties suitable for your scope. Like:

Then create a List < BuildInfo > buildInfo = new List < BuildInfo >();
Then populate the List.

Then is simply a matter of entry level LINQ type of queries (simple or nested).

Notify if you want an indicative random demo.

1 Like

Many thanks. I am new to C#.
I can mostly understand your code. A random demo would be very nice. :slightly_smiling_face:

without c#

separate out all beginning with the same index

1 Like

Good to know the other way ! Thanks Christopher.

However, my model(hospital) has 10 dfferent floors, each floor has 30-40 different programs which will need lots grasshopper components, which I don’t want.

My final goals are to:

  1. extrac each floor’s areas/programs/location data and write into excle;

  2. calculated all some programs accross different floors in the building;
    FAR…share areas, Traffic efficiency…ect…

I find DataTree is pretty hard for me to manipulate data.

After PeterFotiadis told me to use LINQ, I think it would be a nice way for me. I start to learn LINQ now.

Get a start point on that matter: (118.5 KB)


  1. In our trade Geometry is nothing (even kids can do it) while MetaData mining is everything (even pros can’t do it). The MetaData thingy goes far and away from BIM (as the vast majority of Architects understand the term) … and targets the holistic PLM (Project Life Cycle data management).
  2. MetaData without LINQ/PLINQ is a Ducati that is not a red Panigale.
  3. Dealing with MetaData - in the broad aspect of things - without code is a joke.

So the moral of the case is obvious: Master queries and be a happy bunny.

1 Like

Thanks again! Very appreciate! It is helpful.

Tasks for you (after the LINQ part of the story):

  1. Find the most common space type in the building.
  2. Do some rnd adj Matrix (see Tip) and find the most connected space/type per floor (and/or per building).
  3. Include some room/spaces schedule data (i.e. an Array that corelates rooms/spaces with materials, MasterSpec/CIS type of articles and finishes).
  4. Create some rules and approx calculate the lifts required in a tower (regional building regulations required + lift maker specs).
  5. Mastermind a way to build up an indexing/marker system that corelates master drawings (plans, elevations, sections) to master details and details (Note: DO NOT index the details sequentially [use MasterFormat/CIS indexing per article]). If this sounds complex ask a demo from a friend fluent In Microstation CONNECT

Changed a thing or two (and added a tip): (119.3 KB)

Ha! thanks. I need some time to process LINQ first.
It is pitty I dont have friend using Microstation.
I have no idea about rnd adj can it find connected space? Any turorials to get in? i have no idea bout Matrix too.

Suff like this is part of the so called Room Schedules Tables. Owner provides Adj Matrices either in binary (0/1) or in range of values (0/10…100) format. Architects occasionally “modify” slightly these if they have enough experience and owner trusts them and accepts advisory. Adj Matrices are critical if you design a “special” building where space connections are paramount like a Hospital, a Plant, a Research Institute etc etc . If there’s some BID procedure these play a critical role for evaluating/rating the candidate solution.

But just for the challenge of it you can do some random Matrices (see Tip) and query spaces accordingly. So for each space you’ll need a rational (I do hope) “portion” of a similar Matrix (or Matrices): that becomes just another Property of some space/room in the builInfo List.

Added another challenge/Tip as well: (127.0 KB)

Added a 4th Query as well (mostly because some people are afraid to Group first and then Order things). The 5th option is for you when you are ready.

I can understand most task means. But I still not quite understand Matrix. Really not good at Math… Will learn more! Thanks.

Get this: (12.1 KB)

BTW: You live in The Matrix ( but that has nothing to do with a Matrix).

1 Like

Thanks again! I am trying to catch up!

Finally, i got my definition component.

test.3dm (6.0 MB) (23.3 KB)

I am not sure about query code,looks very redudent. how to make conditional Groupby?
How can i get curve GUID inside C#?

There’s light at the end of the tunnel I confess.

BTW: (you had some tol value - invalid for that Method).

BTW: Take a big break and master things that matter the most in our trade (i.e. forget geometry … blah, blah).

After all that the challenge: Do some test class (with cats, dogs and alligators) GroupBy something then OrderBy then GroupBy again and then OrderBy again. Post here the C# (in Lambda and SQL syntax).

Thanks ! :grinning: :grinning: