GetDataTree Problem

Hi all, 

I want to make a custom component which has a Data Tree input and gives a specific item in a list as an output.

It gives me the cast error: Specified cast is not valid.

Can anyone tel me what is the problem?

Thanks a lot!!!!!!!!!!!!!!

Here is my script:

-Protected Overrides Sub RegisterInputParams(ByVal pManager As GH_Component.GH_InputParamManager)
pManager.Register_LineParam("Line", "LT", "my lines",
Grasshopper.Kernel.GH_ParamAccess.tree)

-Protected Overrides Sub RegisterOutputParams(ByVal pManager As GH_Component.GH_OutputParamManager)
pManager.Register_lineParam("point", "P", "my points")

-Protected Overrides Sub SolveInstance(ByVal DA As IGH_DataAccess)


Dim Edge As Rhino.Geometry.Line = Rhino.Geometry.Line.Unset

Dim edgetree As New Data.GH_Structure(Of GH_Line)

If (Not DA.GetDataTree(0, edgetree)) Then Return

Edge = edgetree.Branch(0).Item(0)

DA.GetData(0, Edge)

 

  • up

    David Rutten

    Edge = edgetree.Branch(0).Item(0)

    DA.GetData(0, Edge)

    Edge is of type Line, but the data inside the tree if of type GH_Line. This is your cast error.

    Also, assigning data is doe with the DA.SetData() method, not GetData.

    --

    David Rutten

    david@mcneel.com

    Poprad, Slovakia

     

    5