Karamba.Factories.FactoryPart.MeshToShell() for variable thickness shells

Hi team Karamba.

i have been trying to make shells elements with variable thickness using c#.
i have understood how i can make a buildershell using the factorypart, and can get a basic shell element that assembles and gets rendered in the shellview component.
what i am struggling with is how to generate a variable thickness crossSection.
When i try to make a crosssection with variable thickness i get an error from Karamba.Utilities.Utils.blowUp[T](List`1 l, DataTreeStructure tree)
could you give me a hint on how to proceed?

my code snippet is as follows:
the PolylinesToMesh script creates a mesh which goes through the vertices of the polylines, and has an equal number of vertices as the total vertices in all the polylines.

  List<Polyline> divMidPolylines = new List<Polyline>();
  _thicknesses = new List<double>();
  _eccentricities = new List<double>();

  for (int i = 0; i < MidPolylines.Count; i++)
  {
    double x = (double) i / (double) MidPolylines.Count;
    Polyline midPoly = MidPolylines[i];
    Polyline divPoly = Toolbox.DividePolyline(midPoly, _resolution, true);
    
    divMidPolylines.Add(divPoly);
    
    //calculate thicknesses
    for (int j = 0; j < divPoly.Count; j++)
    {
      double height1 = BridgeToolbox.CalcVariableDim(x, _heights1);
      double height2 = BridgeToolbox.CalcVariableDim(x, _heights2);
      double thickness = (double) j / (double) divPoly.Count;
      _thicknesses.Add(thickness);
      _eccentricities.Add(0.0);
    }//end loop along poly vertices

  }//end loop along polylines

  rhinoMesh = Toolbox.PolylinesToMesh(divMidPolylines);

  //make Karamba Mesh3
  Mesh3 karambaMesh3 = RhinoMeshToMesh3(ref rhinoMesh);
  
  //make cross section
  var materials = new List<FemMaterial>();
  
  var crossSec = new CroSec_Shell("family", "name", "country", null, materials,_eccentricities , _thicknesses);
 
  var factory = new Karamba.Factories.FactoryPart();
  var karLogger = new Karamba.Utilities.MessageLogger();
  var karambaMeshes = new List<Mesh3>(){karambaMesh3};
  var identifiers = new List<string>(){"ident1"};
  var crossSections = new List<Karamba.CrossSections.CroSec>(){crossSec};
  bool bendingToggle = true;
  var messageLogger = new Karamba.Utilities.MessageLogger();
  double limitDist = 0.005;
  List<Point3> resultingNodes;
  
  List<BuilderShell> builderShells = factory.MeshToShell(karambaMeshes, identifiers, crossSections, bendingToggle, messageLogger, out resultingNodes, limitDist);
  ShellElement = new Karamba.GHopper.Elements.GH_Element(builderShells[0]);

i hope you can help, thanks in advance.

and for completeness, the error stacktrace:

  1. Exception: Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index Trace: at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
    at Karamba.Utilities.Utils.blowUp[T](List1 l, DataTreeStructure tree) at Karamba.CrossSections.CroSec_Shell..ctor(String _family, String _name, String _country, Nullable1 _color, List1 _materials, List1 _ecce_z, List1 _elem_heights) at Script_Instance.ZJAslab.MakeMesh() in c:\Users\JorisVeermanZJANL\AppData\Local\Temp\ccj2blp0.0.cs:line 198 at Script_Instance.ZJAslab..ctor(List1 transPolies, List1 SAplanes, List1 heights1, List1 heights2, Int32 vertAlignment, Double resolution, Script_Instance ghScript) in c:\Users\JorisVeermanZJANL\AppData\Local\Temp\ccj2blp0.0.cs:line 150 at Script_Instance.RunScript(List1 PLNS, List`1 PLS, Polyline PL, Line L1, Line L2, Object& A, Object& B, Object& C, Object& D, Object& E, Object& F) in c:\Users\JorisVeermanZJANL\AppData\Local\Temp\ccj2blp0.0.cs:line 80 (line: 93)

Sorry for this messy question: I have solved part of the problem.
i forgot to define materials, the list was empty, that is where the index out of range came from.

the problem i have now is that the thicknesses are not what i am expecting.
are the thicknesses defined per face or per vertex?

thanks.

Hi, for meshes, you need to define the thickness per face.

Hi Matthew,

thanks for your swift response.
It works great with your tip for meshes with only triangles, but not for meshes with quads.
I searched the topics for that and found out that quads are automatically converted to triangles.
So problem solved, thanks again!