-
-
Save goswinr/10f1c5b8e4e78ed7c63b2ad57224a70f to your computer and use it in GitHub Desktop.
F# sample component for testing on Mac Rhino Grasshopper (v6, aka WIP)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace GhFsharpTest | |
open Grasshopper.Kernel | |
open Grasshopper.Kernel.Types | |
type Priority() = | |
inherit GH_AssemblyPriority() | |
override u.PriorityLoad() = | |
GH_LoadingInstruction.Proceed | |
type Info() = | |
inherit GH_AssemblyInfo() | |
override u.Name = "GhFsharpTest" | |
override u.Description = "Quick F# test, NOP component. Sets output to whatever is in the input." | |
override u.Id = new System.Guid("43472a26-58ad-44a8-9948-137a7eaf3ada") // DON'T USE THIS PARTICULAR GUID | |
override u.AuthorName = "Nathan 'jesterKing' Letwory" | |
override u.AuthorContact = "[email protected]" | |
type NopTest() = | |
inherit GH_Component("F#Ex", "F#Ex", "Example Component in F#", "Test", "F#") | |
let mutable inpidx = 0 | |
let mutable outpidx = 0 | |
override u.RegisterInputParams(mgr: GH_Component.GH_InputParamManager) = | |
inpidx <- mgr.AddGenericParameter("I","I","Generic Input",GH_ParamAccess.item) | |
u.Params.Input.[inpidx].Optional <- true | |
override u.RegisterOutputParams(mgr: GH_Component.GH_OutputParamManager) = | |
outpidx <- mgr.AddGenericParameter("O", "O", "Generic Output", GH_ParamAccess.item) | |
override u.SolveInstance(DA: IGH_DataAccess) = | |
match u.Params.Input.[inpidx].SourceCount > 0 with | |
| true -> | |
let mutable (qc:IGH_Goo) = null | |
let r = DA.GetData(inpidx, &qc) | |
if r then | |
DA.SetData(outpidx, qc) |> ignore | |
() | |
| _ -> () | |
override u.ComponentGuid = new System.Guid("94b16908-64a8-4562-a634-c9227582e99d") // DON'T USE THIS PARTICULAR GUID | |
() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment