algorithmic modeling for Rhino
I'm studying the cellular automaton model. And first to Create custom grid of point. I took a vb code as a reference. But the c# code i made was error with the message that "Rhino.Geometry.Plane doesn't contain a definition for xaxis/yaxis/original".
There is also some wrong in the code of making the generation cellular.
Here is the code and the ghx file. Are there some can give a help. Thanks.
***********code****************
private void RunScript(Plane Plane, int XNum, int YNum, double Dis, ref object PointsGrid)
{
//Create 2 dimentional list of points
List<Point3d> Points = new List<Point3d>();
Vector3d x_dir = new Vector3d(Plane.xaxis);
x_dir = x_dir * Dis;
Vector3d y_dir = new Vector3d(Plane.yaxis);
y_dir = y_dir * Dis;
Point3d Base = new Point3d(Plane.origin);
int i = 0;
int j = 0;
for (i = 0; i <= XNum; i++) {
for (j = 0; j <= YNum; j++) {
Point3d newPt = new Point3d(Base);
Vector3d V1 = new Vector3d(x_dir);
V1 = V1 * i;
Vector3d V2 = new Vector3d(y_dir);
V2 = V2 * j;
newPt = newPt + V1 + V2;
Points.Add(newPt);
}
***********code****************
Tags:
private void RunScript(Plane Plane, int XNum, int YNum, double Dis, ref object PointsGrid)
{
//Create 2 dimentional list of points
List<Point3d> Points = new List<Point3d>();
Vector3d x_dir = new Vector3d(Plane.XAxis);
x_dir = x_dir * Dis;
Vector3d y_dir = new Vector3d(Plane.YAxis);y_dir = y_dir * Dis;
Point3d Base = new Point3d(Plane.Origin);int i = 0;
int j = 0;
for (i = 0; i <= XNum; i++) {for (j = 0; j <= YNum; j++) {
Point3d newPt = new Point3d(Base);
Vector3d V1 = new Vector3d(x_dir);
V1 = V1 * i;
Vector3d V2 = new Vector3d(y_dir);
V2 = V2 * j;
newPt = newPt + V1 + V2;
Points.Add(newPt);
}
C# is case-sensitive
xaxis -> XAxis
yaxis -> YAxis
origin -> Origin
Hi, ZWB and Taehyuk,
I've changed a bit the code, removing copy constructors.
if (!plane.IsValid)
plane = Plane.WorldXY;
//Create 2 dimentional list of points
List<Point3d> points = new List<Point3d>();
Vector3d x_dir = plane.XAxis;
/* Vector3d is a stuct, which means its value
is copied (not the reference to it),
so we do not need to copy it manually
or call a constructor to copy.
Structs are an addition to Java. */
x_dir = x_dir * dis;
Vector3d y_dir = plane.YAxis;
y_dir = y_dir * dis;
Point3d basePoint = plane.Origin;
for (int i = 0; i <= xNum; i++)
{
for (int j = 0; j <= yNum; j++)
{
Vector3d V1 = x_dir * i;
Vector3d V2 = y_dir * j;
Point3d newPt = basePoint + V1 + V2;
points.Add(newPt);
}
}
pointsGrid = points;
- Giulio
_______________
giulio@mcneel.com
McNeel Europe
Thanks for you two to give the solution.
I wondered where you can get the information about C# explanation or help specific for grasshopper.
I got it from the file "RhinoDotNetDocs.chm". In that file, the OnPlane(openNURBS) Property is xaxis/yaxis which i s lower-case (OnPlane::xaxis ).
I often confuse about the library/function/class/definition used in grasshopper. Where can I get these ?
And another, after the grid, I coded the mechanism of cellular automaton by a reference from vb code.
But it didn't work and showed four Errors as followed:
1.Cannot implicitly convert type 'Rhino.Geometry.Point3d' to 'Rhino.Geometry.Point3d[*,*]'
2.'Grid' is a 'variable' but is used like a 'method'
3.'System.Collection.Generic.List<Rhino.Geometry.Point3d>.Count' is a 'property' but is used like a 'method'
4.System.Collection.Generic.List<intd>.Count' is a 'property' but is used like a 'method'
I am a new learner, i don't know how to solve and correct this error.
I appreciate you help. Thank a lot.
The ghx file is attached.
hi,
i've changed the code
you can get the rhinocommon documents in here
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
© 2024 Created by Scott Davidson. Powered by