Help for Groups geometry in C# &python?
group.gh (14.1 KB)
Python
import ghpythonlib.components as ghc
a=ghc.Group(x)
import Rhino.DocObjects.Tables.GroupTable as rdg
a=rdg.AddToGroup(x)
C#
A = Rhino.DocObjects.Group(x);
Each of these methods was associated with an error
group.gh (14.1 KB)
Hi
You can try this code.
using System.Linq;
var gh_Geos = geos.Select(g => GH_Convert.ToGeometricGoo(g)).ToList();
var ghGroup = new GH_GeometryGroup();
ghGroup.Objects.AddRange(gh_Geos);
A = ghGroup;
1 Like
Thanks Can you tell how it is in Python
?
And the UnGroup, how ?in C #, Python
@603419608
@Mahdiyar
python:
from Grasshopper.Kernel.Types import GH_GeometryGroup
from Grasshopper.Kernel import GH_Convert
gh_Geos = [GH_Convert.ToGeometricGoo(g) for g in geos]
ghGroup = GH_GeometryGroup()
ghGroup.Objects.AddRange(gh_Geos)
a = ghGroup
group.gh (14.4 KB)
2 Likes
private void RunScript(List<GeometryBase> geos, ref object A)
{
var geoGoos = new List<IGH_GeometricGoo>();
foreach(var geo in geos)
geoGoos.Add(GH_Convert.ToGeometricGoo(geo));
var ghGroup = new GH_GeometryGroup();
ghGroup.Objects.AddRange(geoGoos);
A = ghGroup;
}
Group.gh (8.0 KB)
1 Like