Grasshopper

algorithmic modeling for Rhino

I have followed the examples but I get a error using this code 

and since I am a newbie both in c# and in grasshopper I need a hint 

/****************************** code begin *****************/

protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.AddGeometryParameter("Curves", "Curves", "Cables-Truss elements ", GH_ParamAccess.list);
pManager.AddNumberParameter("Q", "Q", "pre-stress value", GH_ParamAccess.item);
pManager.AddIntegerParameter("type", "type", "Type of element (0=cable,1=truss,2=beam)", GH_ParamAccess.item, 0);
}

protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
pManager.AddGeometryParameter("Curves", "Curves", "Cables-Truss elements ", GH_ParamAccess.list);
}

protected override void SolveInstance(IGH_DataAccess DA)
{
List<IGH_GeometricGoo> geometry = new List<IGH_GeometricGoo>();
if ((!DA.GetDataList(0, geometry)))
return;


double Qval =double.NaN;
if (!DA.GetData(1, ref Qval))
return;

int type = 0;
if (!DA.GetData(2, ref type))
return;

for (Int32 i = 0; i <= geometry.Count - 1; i++)
{
if ((geometry[i] == null))
continue;


GeometryBase gobj=null;
if (geometry[i].CastTo<GeometryBase>(out gobj))
{
gobj.UserDictionary.Set("ixq_", Qval);
gobj.UserDictionary.Set("ixt_", type);
}

}
 

//grasshopper rasies a exception on the next line 

DA.SetData(0, geometry);
}

gerry

Views: 1368

Replies to This Discussion

Forget this request I found my error 

DA.SetDataList instead of SetData 

gerry

You don't output items but a list of items..

DA.SetDataList(0, geometry); 

best,

M.

Didn't make it on time..

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service