Angular Dimension / Grasshopper C# ScriptComponent

Hi There,

I am working on a custom component generating dimension and in this case angular dimensions.

note:
The Elefront PlugIn works fine for me so far, but is lacking the extension lines, so is the grasshopper native angular dimension.

I can create the angular dimension fine so far, but it isn´t visible in grasshopper, hence failing the conversion from goo to geometry, see picture.

Thanx for you help.

Udo

test_angularDim_181010.gh (11.0 KB)

The dimension classes that Grasshopper uses (they are completely different from the native Rhino dimensions, although there is sufficient overlap to convert them into each other) are defined in one of the standard GHA assemblies, and thus not readily available from other plug-ins or scripts.

However it sounds like you want to implement your own dimension class, which both displays differently and potentially bakes to a standard Rhino dimension. This is possible, although it can be pretty gruelling to do this in a C# script component. You would typically need to create about four different classes before you can really work with your own data types:

  1. The data type itself. In this case the dimension.
  2. The goo which wraps around that data and makes it Grasshopper friendly.
  3. A parameter type which can handle your goo.
  4. One or more components which generate or consume your data.

Now you can reduce this list to just two, because the goo and the data could be the same class. Also you can use Generic parameters to hold your data.

I’ll come up with an example for C#.

customannotation.gh (8.9 KB)

For some reason the C# editor goes completely bananas over the CastTo<T> method. Baking is not yet handled, but previewing is done now.

Hi David,

thank you very much for the example.

Would it be much of a difference to do it in a custom plugin (.gha) rather than in a script component, or do I have to handle previewing and converting it into “standard Rhino objects” all the same.

Basically if feel quite safe using rhinocommon and other assemblies in a script component, but when it comes to Inheritance and wrapping and unwrapping (Interfaces) I am still lacking the big concept, which gets me stuck once in a while.

I can read your script fine an basically understand what it does, but I am far from “composing” this myself.

Also I am sometimes not clear what grasshopper actually does behind its curtains. For instance I had trimmed surfaces that I was just filtering with a C# ScriptComponent and it untrimmed all surfaces when feeding it as a surface. Feeding it as Brep worked fine, the trimming persisted.

Is there some document (schematic or layout) which shows what grasshopper does and its conversion / communication to standard Rhino, or do I just need to have the right skills to read the Grasshopper SDK properly?

Thanx a lot.

Udo

Yes it’s easier to manage collections of types and functionality in VisualStudio. Also the autocompletion and code analysis is much better than in the script editor.

I wrote it and even I can’t remember half of it.

The SDK documentation provides some info, but it’s incomplete.

If you get stuck and the code comments don’t help, just ask here.

Thanks a lot.

I will ask :upside_down_face: