Hi, everyone! I have a problem that I can’t solve on my own. So, there is my own class as a shell for Rhino.Geometry.NurbsSurface:
public class MySurface {
public Rhino.Geometry.NurbsSurface rhinoSurface;
public double[][] mX = MatrixCreate(6, 6);
public double[][] mY = MatrixCreate(6, 6);
public double[][] mZ = MatrixCreate(6, 6);
public MySurface(Rhino.Geometry.NurbsSurface SurfaceA)
{
this.rhinoSurface = SurfaceA;
for (int u = 0; u < SurfaceA.Points.CountU; u++)
{
for (int v = 0; v < SurfaceA.Points.CountV; v++)
{
mX[u][v] = SurfaceA.Points.GetControlPoint(u, v).X;
mY[u][v] = SurfaceA.Points.GetControlPoint(u, v).Y;
mZ[u][v] = SurfaceA.Points.GetControlPoint(u, v).Z;
}
}
}
//create surface with the array of control vertices
public void CreateSurfaceByCVSet(MySurface surface)
{
const bool is_rational = false;
const int number_of_dimensions = 3;
int maxU = 5;
int maxV = 5;
int u_degree = 5;
int v_degree = 5;
int u_control_point_count = u_degree + 1;
int v_control_point_count = v_degree + 1;
double[][] CVsetX = this.mX;
double[][] CVSetY = this.mY;
double[][] CVSetZ = this.mZ;
var control_points = new Point3d[u_control_point_count, v_control_point_count];
for (int u = 0; u < maxU + 1; u++)
{
for (int v = 0; v < maxV + 1; v++)
{
control_points[u, v] = new Point3d(CVsetX[u][v], CVSetY[u][v], CVSetZ[u][v]);
}
}
var nurbs_surface = NurbsSurface.Create(
number_of_dimensions,
is_rational,
u_degree + 1,
v_degree + 1,
u_control_point_count,
v_control_point_count
);
nurbs_surface.KnotsU.CreateUniformKnots(1);
nurbs_surface.KnotsV.CreateUniformKnots(1);
// add the control points
for (int u = 0; u < nurbs_surface.Points.CountU; u++)
{
for (int v = 0; v < nurbs_surface.Points.CountV; v++)
{
nurbs_surface.Points.SetPoint(u, v, control_points[u, v]);
}
}
if (nurbs_surface.IsValid)
{
doc.Objects.AddSurface(nurbs_surface);
doc.Views.Redraw();
}
}
}
But when I try to use this code within my C# component, I get an error: “Cannon access a non-static member of outer type ‘Script _Instance’ via nested type Script_Instance.MySurface”. So, I understand that I cannot use Rhino’s methods from my own classes. I can’t even use Print function… For ex.,
public class MyClass
{
public void TestFoo()
{
Print("it works!");
}
}
Can you please help me to fix this problem? Thanks.