That's the error I get when I try to load a custom component where I want to operate over a surface.
I have tried to load the surface as Surface, NurbsSurface and BrepFace.
Code goes this way:
protected override void SolveInstance(IGH_DataAccess DA) {
Brep myBrep= null;
if (DA.GetData<Brep>(0, ref myBrep))
{
int U = 0;
int V = 0;
if (!DA.GetData(1, ref U)) { return; }
if (!DA.GetData(2, ref V)) { return; }
Point3d[,] colec = new Point3d[U + 1, V + 1];
double paramU = 0.0;
double paramV = 0.0;
BrepFace mySrf = myBrep.Faces[0];
mySrf.SetDomain(0, new Interval(0.0,1.0));
mySrf.SetDomain(1, new Interval(0.0,1.0));
for (int j = 0; j <= U; j++){
paramU = j * (1.0 / U);
for (int k = 0; k <= V; k++) {
paramV = k * (1.0 / V);
colec[j, k] = new Point3d((mySrf.PointAt(paramU, paramV).X), (mySrf.PointAt(paramU, paramV).Y), (mySrf.PointAt(paramU, paramV).Z)); }
}
.....
I have been able to reproduce this inside a C# Script component without problems. Any clue?
Thank you!
David Rutten
Hi Roberto,
GH_Surface wraps around Breps, no Surfaces or NurbsSurfaces or BrepFaces. It only allows Breps with a single face, but it's a full brep none-the-less.
However, GH_Surface defines data casts to both Rhino.Geometry.Surface, Rhino.Geometry.Brep and Rhino.Geometry.BrepFace, so if you ask a Surface parameter for any of these types, it should give you what you ask for (NurbsSurface won't work).
I just tested this with GH_Surface, Surface, Brep and BrepFace and they all work.
However the error message seems to indicate you've got a piece of data which is not a GH_Surface. This error is now thrown inside the SolveInstance method, but rather when the Parameter collects data from it's sources. It should also tell you what types of data failed to convert, but you didn't include that in your post.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Jun 29, 2011