Hello, I have noticed an unusual grafting behavior in a custom component I wrote. I stripped the code down and realized the problem is with using an input param of list access along with a second of item access. This issue is fixed if the second param is changed to list.
The image below shows how the data gets restructured
This “grafting” only occurs if a datatree has similar paths, {0} and {0;0} for example. However, the issue is fixed if the paths are renamed (using entwine)
I’m sharing below the whole code of the component seen in these images.
public class MyComponent : GH_Component
{
public MyComponent()
: base("DataTest", "DataTest",
"Description",
"Test", "Test")
{
}
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.AddGeometryParameter("Geometry", "G", "", GH_ParamAccess.list);
pManager.AddGenericParameter("Generic", "R", "", GH_ParamAccess.item);
pManager[1].Optional = true;
}
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
pManager.AddGeometryParameter("Geometry", "G", "", GH_ParamAccess.list);
}
protected override void SolveInstance(IGH_DataAccess DA)
{
List<IGH_GeometricGoo> g = new List<IGH_GeometricGoo>();
DA.GetDataList(0, g);
DA.SetDataList(0, g);
}
protected override System.Drawing.Bitmap Icon
{
get
{
return null;
}
}
public override Guid ComponentGuid
{
get { return new Guid("da2bd586-6920-4195-b3c8-eb4899f54b4a"); }
}
}