How to make a DLL with Visual Studio and using it in Grasshopper C# script [Solved]


(Laurent Delrieu) #1

Hello,
Most of the time I use C# components of my own, but I want now to insert lot of function inside a single C# instead of copying the codes each time I want to make a DLL that will contains all my classes, static function … Does I have to use


.NetCore (1.0 1.1 2.0)
. NetStandard (which one 1.0 1.1 … 2.0)
I found and I used template for Rhino and Grasshopper. Is there an example for a DLL ?

I tried .NetStandard/.NetCore with no compilation error and I get an error message in Grasshopper. What I miss ?

An example I used (Thanks for the new function in RhinoCommon)
using Rhino.Geometry;

namespace TestClassLibrary1
{
    public static class Class1
    {
        public static Mesh Catmull(Mesh mesh, int level, int creasedEdge)
        {


            Rhino.Geometry.MeshRefinements.RefinementSettings rr = new Rhino.Geometry.MeshRefinements.RefinementSettings();

            rr.Level = level;

            Rhino.PrivateMeshCommands.MeshTypes.CreaseEdges ce = Rhino.PrivateMeshCommands.MeshTypes.CreaseEdges.Auto;

            switch (creasedEdge)
            {
                case 0:
                    ce = Rhino.PrivateMeshCommands.MeshTypes.CreaseEdges.NakedFixed; break;
                case 1:
                    ce = Rhino.PrivateMeshCommands.MeshTypes.CreaseEdges.NakedSmooth; break;
                case 2:
                    ce = Rhino.PrivateMeshCommands.MeshTypes.CreaseEdges.CornerFixedOtherCreased; break;
                case 3:
                    ce = Rhino.PrivateMeshCommands.MeshTypes.CreaseEdges.Auto; break;
            }
            rr.NakedEdgeMode = ce;
            return  Mesh.CreateRefinedCatmullClarkMesh(mesh, rr);
        }
    }
}

(Laurent Delrieu) #2

I manage to get it work using a Grasshopper Template and changing gha extension to dll. Not very clean, I continue my tests !!!


C# Class library built into .dll failed to load in grasshopper