Grasshopper

algorithmic modeling for Rhino

Hi all,

I am currently blocking on something really weird:

I cannot do any

If (not DA.GetDataTree(n, something)) then ...

test with any optional inputs. 

With GetDataList it's working perfectly.

I even tried to switch between 3.5 or 4.0, but nothing is changing.

Example:

(List, working)

Protected Overrides Sub RegisterInputParams(pManager As Grasshopper.Kernel.GH_Component.GH_InputParamManager)
pManager.Register_StringParam("TestString", "TestString", "OPTIONAL // TestString.", GH_ParamAccess.list)
pManager(0).Optional = True
End Sub

Protected Overrides Sub RegisterOutputParams(pManager As Grasshopper.Kernel.GH_Component.GH_OutputParamManager)
pManager.Register_StringParam("Test", "Test", "Test")
End Sub

Protected Overrides Sub SolveInstance(DA As Grasshopper.Kernel.IGH_DataAccess)

Dim TestString As New List(Of String)
Dim Log As New List(Of String)

If (Not DA.GetDataList(0, TestString)) Then
Log.Add("Blop")
DA.SetDataList(0, Log)
End If

End Sub
End Class


(Tree, not working)

Protected Overrides Sub RegisterInputParams(pManager As Grasshopper.Kernel.GH_Component.GH_InputParamManager)
pManager.Register_StringParam("TestString", "TestString", "OPTIONAL // TestString.", GH_ParamAccess.tree)
pManager(0).Optional = True
End Sub

Protected Overrides Sub RegisterOutputParams(pManager As Grasshopper.Kernel.GH_Component.GH_OutputParamManager)
pManager.Register_StringParam("Test", "Test", "Test")
End Sub

Protected Overrides Sub SolveInstance(DA As Grasshopper.Kernel.IGH_DataAccess)

Dim TestString As New Grasshopper.Kernel.Data.GH_Structure(Of Grasshopper.Kernel.Types.GH_String)
Dim Log As New List(Of String)

If (Not DA.GetDataTree(0, TestString)) Then
Log.Add("Blop")
DA.SetDataList(0, Log)
End If

End Sub
End Class



I have been searching an error somewhere all the day, and I really don't get it... it's doing the same thing with any data type...

Any clues? It really drives me crazy...

Views: 715

Replies to This Discussion

GetDataTree does not return false if the parameter is optional. Could that be the source of the confusion?

I tried this (see attached) and it works fine. Just instead of If (Not DA.GetDataTree..... you need to use If (TestString.IsEmpty) Then.....

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Attachments:

GetDataTree does not return false if the parameter is optional. Could that be the source of the confusion?


Ah Ok, yes it was. Thank you David!

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2025   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service