Add "using System.Numerics" in Grasshopper C# Script

Good Evening friends,

I need to add “using System.Numerics;” under the ‘using section’ in C# Script.
However the ‘using section’ is marked as grey and can not editable.

To use Math.Net Symbolics, I could add required DLLs but it was not enough…
Is there any way that I can add my own code line there?
or does any one knows, how I can use Symolics Library in Grasshopper C# Script?

Regards,

You can manage the referenced assemblies from the script component menu. You’ll need to locate the appropriate System.Numerics.dll (or whatever the actual filename is) and drag it into the referenced area. Do note that if the dll you’re referencing is too new it will not load.

ps. once an assembly is successfully loaded, all the namespaces will be automatically imported. This can be annoying (especially if there’s lots of them) but at least makes it easy to see whether or not it works.

Is it possible somehow to make a namespace aliases in script code to shorten long namespace paths?

// Rolf

Nope, adding aliases requires being able to edit the using section.

is there any update on this, or should the full namespace paths still be called always?

I was calling a function that has a very long path such as “Accord.Statistics.Distributions.Multivariate.MultivariateNormalDistribution”,
and was hoping I don’t have to copy this everywhere every time it’s called…thanks!

Recent versions of Grasshopper for Rhino6 have editable using blocks.

3 Likes

Great, just tried it out on GH 1.0.0007 and works.
Thank you!

Hi guys! How did you edit the using block? I’m using GH 1.0.0007 but can’t seem to find how to change using. I’m only trying to add Rhino.Geometry.Intersect.
Thanks in advance

Just start typing on the first white line under the existing uses clauses, like so:

// Rolf

1 Like

Thank you Rolf. I was trying to add lines to the grey section :stuck_out_tongue:

I’m trying to import the Accord.Statistics.Distributions.Univariate namespace but I get an error doing so.
I checked for typos, nothing there.

error: Could not load file or assembly ‘Accord, Version=3.8.2.0, Culture=neutral, PublicKeyToken=fa1a88e29555ccf7’ or one of its dependencies. The system cannot find the file specified. (line: 72)

I did add the assembly Accord.Statistics.dll to the component, so I don’t see why it is not recognizing it.
The Accord.Statistics namespace however does work.

Any suggestions?