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?
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’.