I am trying to create an elif statement to pass values to multiple outputs. But the component just throws errors.
I used this reference from Microsoft website for creating my statement
here is the Code snippet from C#
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;
/// <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(DataTree<Mesh> icModules, DataTree<string> icHomeID, ref object A, ref object B, ref object C, ref object D)
{
DataTree<Mesh> oneBrModules = new DataTree<Mesh>();
DataTree<Mesh> inteLockBrModules = new DataTree<Mesh>();
DataTree<Mesh> twoBrModules = new DataTree<Mesh>();
DataTree<Mesh> threeBrModules = new DataTree<Mesh>();
var inputPath = icModules.BranchCount;
for (int i = 0; i < inputPath; i++)
{
GH_Path icPath = new GH_Path(i);
for (int j = 0; j < icModules.Branch(i).Count; j++)
{
if (icHomeID.Branch(i)[j] == "A")
{
oneBrModules.Add(icModules.Branch(i)[j], icPath);
}
lif(icHomeID.Branch(i)[j] == "B")
{
interLockBrModules.Add(icModules.Branch(i)[j], icPath);
}
elif(icHomeID.Branch(i)[j] == "C")
{
twokBrModules.Add(icModules.Branch(i)[j], icPath);
}
else (icHomeID.Branch(i)[j] == "D")
{
threeBrModules.Add(icModules.Branch(i)[j], icPath);
}
endif
}
}
A = oneBrModules;
B = oneBrModules;
C = oneBrModules;
D = oneBrModules;
}
// <Custom additional code>
public Mesh SelectOneBR(Mesh modules, String homeID)
{
Mesh oneBRmodule = new Mesh();
String homeName = "A";
if (homeID == homeName)
{
oneBRmodule = modules;
return oneBRmodule;
}
else
{
oneBRmodule = null;
}
return oneBRmodule;
}
public Mesh SelectInterLockBR(Mesh modules, String homeID)
{
Mesh interLockBRmodule = new Mesh();
String homeName = "B";
if (homeID == homeName)
{
interLockBRmodule = modules;
return interLockBRmodule;
}
else
{
return null;
}
}
public Mesh SelectTwokBR(Mesh modules, String homeID)
{
Mesh twoBRmodule = new Mesh();
String homeName = "C";
if (homeID == homeName)
{
twoBRmodule = modules;
return twoBRmodule;
}
else
{
return null;
}
}
public Mesh SelectthreeLockBR(Mesh modules, String homeID)
{
Mesh threeBRmodule = new Mesh();
String homeName = "D";
if (homeID == homeName)
{
threeBRmodule = modules;
return threeBRmodule;
}
else
{
return null;
}
}
// </Custom additional code>
}
Also the Script: Elif Test.gh (32.8 KB)
Why is this happening?