namespace ToolBox { public class MeshPipeComponent : GH_Component { /// /// Initializes a new instance of the MeshPipeComponent class. /// public MeshPipeComponent() : base("Mesh Pipe", "MeshPipe", "Create Mesh Pipe", "ToolBox", "Mesh") { } /// /// Registers all the input parameters for this component. /// protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { pManager.AddCurveParameter("inputCurve", "inCurve", "Curve", GH_ParamAccess.list); pManager.AddNumberParameter("radius", "R", "Radius of Pipe", GH_ParamAccess.item, 1.0); pManager.AddIntegerParameter("segments", "seg", "segments mesh pipe", GH_ParamAccess.item, 10); pManager.AddIntegerParameter("accuracy", "acy", "accuracy", GH_ParamAccess.item, 1); pManager.AddIntegerParameter("capType", "capType", "capType", GH_ParamAccess.item, 0); } /// /// Registers all the output parameters for this component. /// protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) { pManager.AddMeshParameter("outputMeshPipe", "OutMP", "output Mesh Pipe", GH_ParamAccess.list); } /// /// This is the method that actually does the work. /// /// The DA object is used to retrieve from inputs and store in outputs. protected override void SolveInstance(IGH_DataAccess DA) { var inputCurve = new List(); double radius = 5.0; int segments = 10; int accuracy = 1; var capType = 0; var outputMeshPipe = new List(); if (!DA.GetDataList(0, inputCurve)) return; if (!DA.GetData(1, ref radius)) return; if (!DA.GetData(2, ref segments)) return; if (!DA.GetData(3, ref accuracy)) return; if (!DA.GetData(4, ref capType)) return; outputMeshPipe = MeshPipe(inputCurve, radius, segments, accuracy, capType); DA.SetData(0, outputMeshPipe); } private List MeshPipe(List curves, double radius, int segments, int accuracy, int capType) { var pipes = new List(); var cap_style = (MeshPipeCapStyle) capType; var outputMeshPipe = new List(); foreach (var curve in curves) { var mesh_pipe = Mesh.CreateFromCurvePipe(curve, radius, segments, accuracy, cap_style, true); pipes.Add(mesh_pipe); } outputMeshPipe = pipes; return outputMeshPipe; } /// /// Provides an Icon for the component. /// protected override System.Drawing.Bitmap Icon { get { //You can add image files to your project resources and access them like this: // return Resources.IconForThisComponent; return SS_ToolBox.Properties.Resources.Icon1.ToBitmap(); } } /// /// Gets the unique ID for this component. Do not change this ID after release. /// public override Guid ComponentGuid { get { return new Guid("9f4d9e05-fbf7-4689-acec-3b275aaa2c1a"); } } } }