@martinsiegrist It’s all described on the notes in a new C# script (albeit not in Grasshopper :D)
// NOTE:
// - Reference to RhinoCommmod.dll is added by default
// - Use // r "<assembly name>" to reference other assemblies
// e.g. // r "System.Text.Json"
// e.g. // r "path/to/your/Library.dll"
// - Use // r nuget "<package name>==<package version>" to install and reference nuget packages.
// >= and > are also accepted instead of ==
// e.g. // r nuget "RestSharp==106.12.0"
// e.g. // r nuget "RestSharp>=106.10.1"
// - Use #r "nuget: <package name>, <package version>" to install and reference nuget packages.
// e.g. #r "nuget: RestSharp, 106.11.7"
I was able to link to the KangarooSolver.dll file but now it seems I need to link to the Kangaroo2Components.gha file and so far this has failed. Path should be correct.
// r "C:\\Program Files\\Rhino 8 WIP\\Plug-ins\\Grasshopper\\Components\\Kangaroo2Component.gha"
using System;
using System.Collections;
using System.Collections.Generic;
using Rhino;
using Rhino.Geometry;
using Grasshopper;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Data;
using Grasshopper.Kernel.Types;
// using Kangaroo2Component;
/// <summary>
/// This class will be instantiated on demand by the Script component.
/// </summary>
public class Script_Instance : GH_ScriptInstance
{
#region Utility functions
/// <summary>Print a String to the [Out] Parameter of the Script component.</summary>
/// <param name="text">String to print.</param>
private void Print(string text) { /* Implementation hidden. */ }
/// <summary>Print a formatted String to the [Out] Parameter of the Script component.</summary>
/// <param name="format">String format.</param>
/// <param name="args">Formatting parameters.</param>
private void Print(string format, params object[] args) { /* Implementation hidden. */ }
/// <summary>Print useful information about an object instance to the [Out] Parameter of the Script component. </summary>
/// <param name="obj">Object instance to parse.</param>
private void Reflect(object obj) { /* Implementation hidden. */ }
/// <summary>Print the signatures of all the overloads of a specific method to the [Out] Parameter of the Script component. </summary>
/// <param name="obj">Object instance to parse.</param>
private void Reflect(object obj, string method_name) { /* Implementation hidden. */ }
#endregion
#region Members
/// <summary>Gets the current Rhino document.</summary>
private readonly RhinoDoc RhinoDocument;
/// <summary>Gets the Grasshopper document that owns this script.</summary>
private readonly GH_Document GrasshopperDocument;
/// <summary>Gets the Grasshopper script component that owns this script.</summary>
private readonly IGH_Component Component;
/// <summary>
/// Gets the current iteration count. The first call to RunScript() is associated with Iteration==0.
/// Any subsequent call within the same solution will increment the Iteration count.
/// </summary>
private readonly int Iteration;
#endregion
/// <summary>
/// This procedure contains the user code. Input parameters are provided as regular arguments,
/// Output parameters as ref arguments. You don't have to assign output parameters,
/// they will have a default value.
/// </summary>
private void RunScript(GeometryBase Geo, Polyline refPoly, Polyline targetInner, Polyline targetOuter, out object A)
{
SpaceMorph morph = new Kangaroo2Component.UtilityComponents.MorphToMesh.PolyPrism(refPoly, targetInner, targetOuter);
GeometryBase geo2 = Geo.Duplicate();
morph.Morph(geo2);
A = geo2;
}
// <Custom additional code>
// </Custom additional code>
}
It is explained at the top of an empty C# script. Let me know if this is not clear
// NOTE:
// - Reference to RhinoCommmod.dll is added by default
// - Use #r "nuget: <package name>, <package version>" to install and reference nuget packages.
// e.g. #r "nuget: Rhino.Scripting, 0.7.0"
// e.g. #r "nuget: RestSharp, 106.11.7"
// - Use #r "<assembly name>" to reference other assemblies
// e.g. #r "System.Text.Json.dll"
// e.g. #r "path/to/your/Library.dll"
// e.g. #r "path/to/your/Plugin.gha"