Labeling and Dimension using C# study

Hello everybody!

I am currently studying C# programming and trying to understand how connecting Rhino identifiers works using rhinocommon. From my file, polylines are being read in certain layers. So, I can generate a specific nomenclature for each type of area continuously, for example A3_0, A3_1, A3_2 and so on.
I’m new to vanilla C #, so I still don’t fully understand the logic; however, I was able to select the content of each entry (layers), generate index and nomenclature lists for each area. All in 3 C# components on grasshopper.

C# components:

In component 1 Rhino geometry collected, write nomenclature and its indexes in lists;
In component 2 get area of ​​each element;
In component 3 write nomenclature in the Rhino viewport using the centroid of each geometry.

The next step for me would be to identify the vertices of each polyline and generate a dimension in the Rhino viewport and rename similar areas with the same label, using the condition that they must have vertices of the same length in 2 decimal places rounding,

#1 Component C#:

#2 Component C#:


#3 Component C#:

Note: I highlighted in red the height control of the texts. Bad control :confused:

Unfortunately I am facing so touble so I would like to know if someone could help me better understand how to achieve these results.

One of my questions is why can’t I complite all C# components in only one? My #1 component output in A a polyline list of curves. In #2 component I collect by geo input the curves for working fine, but if I place #2 inside #1, the AreaMassProperties amp = AreaMassProperties.Compute(geo); fail to collect in geo = ghobjs;. Can anyone help to understand this issue? ghobjs must be converted in somehow like into Curve()?!

I built the definition using the regular components in the grasshopper, following the logic I tried to translate it into C#, I hope it helps to understand what I’m looking for here.

Grasshopper definition:

Follow result in viewport. With text came from gh definition + dimension, back text came from C# definition.

Thank you so much for any help!

Test C#.3dm (77.4 KB)
Test (19.4 KB)

Hi @falbuquerquep,

ghobjs in your first component is a list of geometry objects. you can’t just put a list into AreaMassProperties.compute(), you need to feed them in one at a time. See the attached script on how I do it.

The if block can be replaced with switch case statement for easy reading.

If you use the same looping method to generate area, it is possible to then write the text tag. Hope this helps you get to your next step.

Test (19.4 KB)

1 Like