Grasshopper

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;

}

Views: 1230

Replies to This Discussion

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

Strange, Try with GH_Line, that is how lines are actually stored.

Same error. What did I do wrong?

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);
}

}

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service