Read cross-section list as CroSec_Beam

Hi Karamba team,
I have been trying to read Karamba cross-section list as List<CroSec_Beam> in c# by using pManager.
My code is as following but it has an error “Invalid cast: CrossSection » CroSec_Beam”.
How can I read the list by pManager?

protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
pManager.AddParameter(new Param_CrossSection(), “CroSecsList”, “CroSecsList”, “”, GH_ParamAccess.list);
protected override void SolveInstance(IGH_DataAccess DA)
var CroSecsList = new List<CroSec_Beam>();
DA.GetDataList(0, CroSecsList);

Thank you in advance,

Hi @Tsato,
reading in the list of cross sections can be done like this:

List<GH_CrossSection> in_gh_crosec = new List<GH_CrossSection>();
if (!DA.GetDataList<GH_CrossSection>(0, in_gh_crosec))
// nothing could be read
List <CroSec> crosecs = FromGH.Values(in_gh_crosec);

‘FromGH’ resides in Karamba.GHopper.Utilities. Alternatively one can get the cross section object from the wrapper via in_gh_crosec[…].Value.

You then need to cast from ‘CroSec’ to ‘CroSecBeam’.

– Clemens

Thank you Clemens! I was able to read the list.