algorithmic modeling for Rhino
Like this?
In Main:
List<Grasshopper.Kernel.Parameters.Param_GenericObject> objects
= FindObjectsInCurrentGroup<Grasshopper.Kernel.Parameters.Param_GenericObject>();
Function:
private List<T> FindObjectsInCurrentGroup<T>() where T : Grasshopper.Kernel.IGH_DocumentObject
{
List<Grasshopper.Kernel.Special.GH_Group> groups = GrasshopperDocument
.Objects
.OfType<Grasshopper.Kernel.Special.GH_Group>()
.Where(gr => gr.ObjectIDs.Contains(Component.InstanceGuid))
.ToList<Grasshopper.Kernel.Special.GH_Group>();
Print("{0}", groups.Count);
List<T> output = groups.Aggregate(new List<T>(), (list, item) =>
{
list.AddRange(
GrasshopperDocument.Objects.OfType<T>()
.Where(obj => item.ObjectIDs.Contains(obj.InstanceGuid))
);
return list;
}).Distinct().ToList();
return output;
}
Why Grasshopper.Kernel.Parameters.Param_GenericObject ? That will not find the Panel as Panel doesn't derive from Param_GenericObject.
Oops my bad. Accept my apologies.
Until a proper demo is ready get this.
Here we are (again: accept my apologies).
Moral of all these: Buy a proper Ducati, what else? (see def)
And the trad update
Hi guys!
Sorry for late reply, my dsl at home is offline this week.
Thanks a lot peter! uber stuff as always...
I'll take my time to metabolize it and then i'll post here what i'm working on.
Thanks again.
Hmm ... I suspect that you want to find all groups in the document otherwise it doesn't make much sense ... or maybe it does who knows? he he.
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