algorithmic 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?
i.e.
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
try
Ctype(ghobject, Grasshopper.Kernel.IGH_Component)
catch
etc etc etc
cheers
Tags:
If (TypeOf ghObject Is IGH_Component) Then
...
End If
or
Dim ghComponent As IGH_Component = TryCast(ghObject, IGH_Component)
If (ghComponent IsNot Nothing) Then
...
End If
Don't use CType() by the way. If you're casting to types you're better of using TryCast() and DirectCast().
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Ah, thank you very much Mr Rutten
Steve
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by