Now it is time to add the input- and output-plugs to the new component. This is the listing of the first few lines of “TensionElimComponent.cs” which implements this functionality:
usingSystem;usingSystem.Collections.Generic;usingGrasshopper.Kernel;usingKaramba.Models;usingKaramba.GHopper.Models;namespaceTensionElim {publicclassTensionElimComponent:GH_Component {publicTensionElimComponent(): base("TensionElim","TenElim ","."," Karamba "," E x t r a " ) { }protectedoverridevoidRegisterInputParams(GH_Component.GH_InputParamManager pManager) {pManager.AddParameter(newParam_Model(),"Model_in","Model_in","Model to be manipulated",GH_ParamAccess.item); }protectedoverridevoidRegisterOutputParams(GH_Component.GH_OutputParamManager pManager) {pManager.RegisterParam(newParam_Model(),"Model_out","Model_out","Model after eliminating all tension elements");pManager.Register_BooleanParam("isActive","isActive","List of boolean values corresponding to each element in the model."+"True if the element is active.");pManager.Register_NumberParam("maximum displacement","maxDisp"," Maximum displacement [m] of the model after eliminationprocess."); } ... }
Line 1 to 4 get automatically created by the GH-wizard. Lines 6 and 7 are important: they make the classes available (i.e. Model, Param_Model, GH_Model, Element, ...) which reside in the namespaces “Karamba.Models” and “Karamba.GHopper.Models”. This allows to define the component input in lines 20 and 21. Objects that are used as component input or output need to be wrapped so that GH can handle them. In Karamba3D these wrapper classes are named after the class they wrap preceded by “Param_” and “GH_”. Lines 26 to 32 specify the output plugs. Supplement “TensionElim- Component.cs” with the above lines, compile the project and copy the resulting “TensionElim.gha” as before. Restart Rhino.
Fig. 3.4.1 shows the component with input and output-plugs.