generative modeling for Rhino
I am iteratign through all document objects on the canvas.
I only want to interrogate objects which are compoennts i.e. they inherit the IGH_Component interface. For insatnce I dont wnat to interrogate string panels or color swatches
Is there a quick way of determining is this is true other than iterating throught teh collection and doing a try catch for each object when trying to convert to the interface?
Dim ghObjects As New List(Of Grasshopper.Kernel.IGH_DocumentObject)
Dim ghDocument As Grasshopper.Kernel.GH_Document = GH_InstanceServer.ActiveCanvas.Document
ghObjects = ghDocument.Objects
For each ghObject in ghobjects
etc etc etc
If (TypeOf ghObject Is IGH_Component) Then
Dim ghComponent As IGH_Component = TryCast(ghObject, IGH_Component)
If (ghComponent IsNot Nothing) Then
Don't use CType() by the way. If you're casting to types you're better of using TryCast() and DirectCast().
Ah, thank you very much Mr Rutten