Grasshopper

algorithmic modeling for Rhino

In VB, does anyone know how to check whether a particular path in a data tree exists?

I've been calling up items using the following syntax:

x.Branch(i).Item(j)

where x is coming into the VB component as a data tree.  Is there a way to check whether a particular i and j combination exists?

Thanks,

Jon

Views: 506

Replies to This Discussion

There is a PathExists(GH_Path path) function. It seems to fit your needs rather neatly.

I just added an ItemExists(GH_Path path, int index) function which tests for both path and item index existence. Will be available in the next version.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Thanks, David.

Sorry for the novice question, but what is the syntax for a GH_Path path? (e.g. {0;1;2} ?)

Thanks.

-Jon
Hi Jon,

the PathExists function has two overloads. One of them works simply on a bunch of integers, the other one requires an instance of GH_Path:

If (x.PathExists(0, 1, 2)) Then ...
If (x.PathExists(New GH_Path(0, 1, 2)) Then ...

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Got it. I was missing the "New" before "GH_Path". Thanks David.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service