void DrawData(Grasshopper.Kernel.Data.IGH_Structure volatileData, IGH_DocumentObject docObject) { if (docObject is IGH_PreviewObject preview) { if (preview.Hidden) { return; } } if (!volatileData.IsEmpty) { foreach (var value in volatileData.AllData(true)) { if (value is IGH_PreviewData) { bool isSelected = docObject.Attributes.Selected; if (ActiveDefinition.PreviewFilter == GH_PreviewFilter.Selected && !isSelected) { continue; } var geometries = new List <Rhino.Geometry.GeometryBase>(); ExtractGeometry(value, ref geometries); if (geometries.Count != 0) { geometries.ForEach(geometryBase => AddDrawable(geometryBase, isSelected)); docObject.ObjectChanged += ObjectChanged; } } } } }
void DrawData(Grasshopper.Kernel.Data.IGH_Structure volatileData, IGH_DocumentObject docObject) { if (!volatileData.IsEmpty) { foreach (var value in volatileData.AllData(true)) { // First check for IGH_PreviewData to discard no graphic elements like strings, doubles, vectors... if (value is IGH_PreviewData) { switch (value.ScriptVariable()) { case Rhino.Geometry.Point3d point: primitives.Add(new ParamPrimitive(docObject, new Rhino.Geometry.Point(point))); break; case Rhino.Geometry.Line line: primitives.Add(new ParamPrimitive(docObject, new Rhino.Geometry.LineCurve(line))); break; case Rhino.Geometry.Rectangle3d rect: primitives.Add(new ParamPrimitive(docObject, rect.ToNurbsCurve())); break; case Rhino.Geometry.Arc arc: primitives.Add(new ParamPrimitive(docObject, new Rhino.Geometry.ArcCurve(arc))); break; case Rhino.Geometry.Circle circle: primitives.Add(new ParamPrimitive(docObject, new Rhino.Geometry.ArcCurve(circle))); break; case Rhino.Geometry.Ellipse ellipse: primitives.Add(new ParamPrimitive(docObject, ellipse.ToNurbsCurve())); break; case Rhino.Geometry.Curve curve: primitives.Add(new ParamPrimitive(docObject, curve)); break; case Rhino.Geometry.Mesh mesh: primitives.Add(new ParamPrimitive(docObject, mesh)); break; case Rhino.Geometry.Box box: { var boxMeshes = Rhino.Geometry.Mesh.CreateFromBox(box, 1, 1, 1); if (boxMeshes != null) { primitives.Add(new ParamPrimitive(docObject, boxMeshes)); } } break; case Rhino.Geometry.Brep brep: { var brepMeshes = Rhino.Geometry.Mesh.CreateFromBrep(brep, activeDefinition.PreviewCurrentMeshParameters()); if (brepMeshes != null) { var previewMesh = new Rhino.Geometry.Mesh(); previewMesh.Append(brepMeshes); primitives.Add(new ParamPrimitive(docObject, previewMesh)); } } break; } } } } }
private static void ExtractGeometry(Grasshopper.Kernel.Data.IGH_Structure volatileData, ref List <Rhino.Geometry.GeometryBase> resGeom, bool isRenderMode, Rhino.Geometry.MeshingParameters meshParams) { foreach (var value in volatileData.AllData(true)) { if (value is IGH_PreviewData) { ExtractGeometry(value, ref resGeom, isRenderMode, meshParams); } } }
public bool SetDataTree(int paramIndex, Grasshopper.Kernel.Data.IGH_Structure tree) { throw new NotImplementedException(); }
public bool AddVolatileDataTree(Grasshopper.Kernel.Data.IGH_Structure tree) { throw new NotImplementedException(); }