algorithmic modeling for Rhino
I know I'm missing something obvious, but I can't find a solution for this.
My input is a DataTree<Point3d> and I'm declaring it with:
pManager.AddPointParameter("Points", "P", "Tree of Points", GH_ParamAccess.tree );
Then to retrive data I tried using:
if (!DA.GetDataTree<Point3d>(0, out pnt)) return;
but it doesn't work, so I tried using:
Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_Point> pnt = new Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_Point>();
if (!DA.GetDataTree(0, out pnt)) return;
It works, but then how can I convert the GH_point to Point3d? Actually to DataTree<Point3d>?
:(
Tags:
Hi Lorenzo,
While doing whatever is your doing with your point_3D you have to cast them back to GH_points in order to be capable of being streamed out of the GH component.
You can use the GH_convert function for that.
Best,
M.
Hi Marios thanks for your help!
I'm trying but it doesn't work.. can you give me an example?
EDIT:
I'm also trying to output a list<Point3d> but with no success. GH returns me an error saying it couldn't convert data of type GH_Point :/
Your output has to be a GH_structure<GH Point> or similarly.
and your conversion line should be something like
bool (a boolean to see whether the conversion was successful or not) = GH_Convert.ToGHPoint("yourpoint3d", GH_Conversion.Both, "YourNewGHPoint")
Not tested, but if I remember correctly it's like this.
Best,
M.
Sorry, maybe I don't get it. I have this situation, why isn't it working?
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
pManager.AddMeshParameter("Mesh", "M", "Mesh", GH_ParamAccess.item);
}
protected override void SolveInstance(IGH_DataAccess DA)
{
DataTree<Point3d> pnts = new DataTree<Point3d>();
Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_Point> GH_pnts = new Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_Point>();
if (!DA.GetDataTree(0, out GH_pnts)) return;
bool myBool = GH_Convert.ToGHPoint(GH_pnts, GH_Conversion.Both, pnts);
// the following doesn't work either
// bool gno = GH_Convert.ToPoint3d(GH_pnts, pnts, GH_Conversion.Both);
....
}
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by