Grasshopper C#

Also, I’ve covered the maths primer and I’m almost ok with all the Delaunay this and Voronoi that. But I still sit stuck for hours on seemingly basic geometric problems. I feel like there’s a missing tome of knowledge in the black art of 3D that I don’t know about. This must have all been done to death by some maths nurds somewhere; I feel like I’m having to do the equivalent of rediscovering cosines every time I get a new problem. I’ve looked up something called computational geometry and a further specialism of this called geometric modelling and it looks like it might be it. Is this going too deep to early or just getting a good grounding in mathematical techniques?

No because we don’t know in advance what is it you want to do. Are you dealing with files? Modifying the 3dm document? Creating your own commands? Adding UI to Rhino? Dealing with custom object data? Performing geometrical operations? Visualisation? Rendering? Project versioning?

It can be quite deep. Ideally high-school would have given you the skills for dealing with basic trigonometry (sines and cosines). Of course that knowledge atrophies after disuse, but hopefully hasn’t sunk too low below the surface.

Vector mathematics (dot-products, cross-products, matrix-transforms) is also a very useful skill to have, and one that high-school maths tends to omit.

Quite often vector maths can solve a problem with fewer lines of code and fewer instructions than trig can, although in my experience either approach will work for most issues, so if you feel more at home with cosines than vector-multiplication, stick to cosines.

Can you describe a typical problem you run into? What level of complexity are we talking about?

Hi David,

I’ve confused things by adding cosines into the mix. Forget I mentioned cosines, I’ll draft something clearer asap.

It’s the rhinocommon.geometry namespace I was referring to, not the rest

Hi David

To get back to the basics I can see how vector mathematics is used for points, curves etc but once one gets to more complex composite types like breps (yes I know people use brep erroneously) I think I’d have trouble without some sort of algorithm library to help me.

Please correct me if I am mistaken in that assumption.

To me, for breps, I’d have thought I’d need something akin to CGAL, but I may be completely wrong here.

Breps are really complicated entities. I typically use only the static methods on them. You’re not really supposed to create them from scratch yourself, getting the associations between faces, edges, loops, trims, vertices, 2D and 3D curves all set up correctly requires a PhD in OpenNurbs studies.

If you want to measure the area or volumes of breps, there’s helper methods for that. If you want to mesh them, there’s helper methods for that. Same with intersections, transformations, closest-points, etc.

We don’t have an in depth explanation on ‘everything brep’ because so few people would ever need to do the really low-level stuff that we may as well help them out individually. So what is it you want to do with breps?

Well the work I’m expected to do in the new year involves dealing with façades for large office blocks and the like. I should imagine it will involve the standard transformations one would do on a 3d form but these are complex forms and I made the presumption that polysurface equals breps equals headache. So not only must I brush up on vector maths I must also wrestle the breps beast. Faced with this I thought I’d go back to the basics; cover the geometry chapter of the rhinopython primer, translate it to the geometry namespace of rhinocommon and lastly, find enough out about munging complex shapes around (the façade designs) to be able to give a reasonable answer to my employer as to what can and cannot be done when it gets to the façades. Nothing would please me more than staying within the realms of matrices and vectors, believe me. I do need to find out where it’s ceiling is though. If you say there be dragons when I talk of performing, albeit static, operations on breps then that’s good enough for me.

But I can’t be more specific about what will actually need to be done because I don’t know. All I want to do is spend the next 2 months increasing my competency in key areas such rhinocommon geometry and vector math and I found the ‘rhinocommon.geometry’ documentation a bit lacking hence the questions. As far as breps go it looks terrifying. Given that the remit is to add some programmatic experience to the grasshopper users I’m struggling to see where I will add value given that grasshopper seems to handle everything bar loops and recursion. I know there’s extra juiciness contained in the c++ libs compared to rhinocommon but I really didn’t want to go there. So far, Long Nguyen’s videos have been the lifesaver for rhinocommon but they only go so far.

I m trying to study C# in GH. :grinning:

FYI – > from Scripting and Code Tutorials - Grasshopper

Hello , @kazujoestar
I can’t download the c# examples on this page ,could you post it?
Examples on this site https://petrasvestartas.com/C-for-Grasshopper
just this:
image
Thanks!