algorithmic modeling for Rhino
Hi,
How can I solve this error when inputing lines to custom component?
I get following error:
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddLineParameter("Lines", "L", "Line List", GH_ParamAccess.list);
}
protected override void SolveInstance(IGH_DataAccess DA)
{
List<Line> lines = new List<Line>();
if (!DA.GetDataList<Line>(0, lines)) return;
}
Tags:
Hi,
It is Rhino.Geometry.Line.
It is very strange. I have components that I made before and they worked.
For instance I have the same problem with Mesh input.
I have compiled component with mesh input, and I get the same error: Invalid cast Mesh>>Mesh.
One week ago it worked, now it does not. And this another component, was not even touched/changed/recompiled in visual studio.
Stange...
I would suggest to use GH_Structure(of T) when working on custom components.
Its should work fine if you cast your line to GH_line type. There are available methods for this in the GH SDK. All geomtery has to wrap around the IGH_goo class.
Ta,
M
Yes, tried to generate new guid several times. And I also do not get error if there are two components with the same id.
Also tried to create a new project in visual studio.
Same error.
There's a GH_Line in GH_IO.Types, that's not the one you want. Try specifically using
List<Grasshopper.Kernel.Types.GH_Line>
and/or
List<Rhino.Geometry.Line>
This one works:
List<Grasshopper.Kernel.Types.GH_Line> lines = new List<Grasshopper.Kernel.Types.GH_Line>();
if (!DA.GetDataList<Grasshopper.Kernel.Types.GH_Line>(0, lines)) return;
This one does not:
List<Rhino.Geometry.Line> lines = new List<Rhino.Geometry.Line>();
if (!DA.GetDataList<Rhino.Geometry.Line>(0, lines)) return;
Thank you:)
How can I cast GH_Line to Line to access function such as line.from line.to ?
Or is it possible to access those functions from GH_Line?
Found . value
Have you tried to ask for more information about the problem?
protected override void SolveInstance(IGH_DataAccess DA)
{
try {
List<Line> lines = new List<Line>();
if (!DA.GetDataList<Line>(0, lines)) return;
} catch (exception ex) {
rhinoapp.WriteLine(ex.ToString);
}
}
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
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by