Grasshopper

algorithmic modeling for Rhino

C#_Error while iterating over Vector3d list"Cannot convert from double to Vector3d"

Hi all,

these days i tried to reproduce a really simple version of the Rectangle component

I just want to test if the Polyline consists of 4 segments, then get the direction of each segment and calculate the angles between each.


My script so far isThe error occurs in line 90+91 I dont know why this is happening they should all be vectors since they are stored in a Vector3d list.

So if anybody could enlighten would be really appreciated.

Thanks and nice monday!

Views: 458

Attachments:

Replies to This Discussion



In line 90:
    Vector3d v2 = list[index] + integer, 

when I think what you wanted to do is:
    Vector3d v2 = list[index + integer] 

//////////////////////////////////////////////////////////////////////////////////////////////////////////

private void RunScript(Curve Crv, ref object A)
{

Rectangle3d rec = new Rectangle3d();
if(GH_Convert.ToRectangle3d(Crv, ref rec, GH_Conversion.Both)){
A = rec;
}
}

Hi Daniel!

thanks for your reply but the error still exists after the change.

Gracias por tu respuesta, pero el error sigue appareciendo despues del cambio.

The code you posted is a GH function, right? Probably the simplest way to do this.

El codigo que subiste es una funcion de GH, verdad? Prbablemente lo mas facil hacerlo asi.

For the Future would you mind to help me get the thing above to work?

Para futuros ocassiones podiras ser tan amable y ayudarme a arreglar como empeze?

Igual para poder applicarlo en otros scripts.

Muchas gracias, como siempre tu ayuda es muy agradecido!

Acabo de fijarme, vecDir no es una colección sino un elemento (vector3d), por lo que al indizarlo estás accediendo a sus coordenadas (y de ahí surge el double). La lista es dirList, por lo que reemaplaza vecDir por dirList en lineas 89 y 90.

///////////////////////////////////////////////////////////////////////////////////////////

private void RunScript(Polyline pln, object y, ref object A)
{

if(pln == null) return;

double tol = 0.001;
double pi2 = Math.PI * 0.5;

if(pln.SegmentCount == 4){
for(int i = 0;i < 4;i++){
int i0 = GH_MathUtil.WrapInteger(i - 1, 4);
int i1 = GH_MathUtil.WrapInteger(i + 1, 4);
Vector3d v0 = new Vector3d(pln[i0] - pln[i]);
Vector3d v1 = new Vector3d(pln[i1] - pln[i]);
double ang = Vector3d.VectorAngle(v0, v1);
if(Math.Abs(ang - pi2) > tol){
return;
}
}
Plane plne = new Plane();
Plane.FitPlaneToPoints(pln.ToArray(), out plne);
A = new Rectangle3d(plne, pln[0], pln[2]);
}
}

Perfecto Daniel!

muchas gracias me salvaste el día, jeje!

Muy agradecido!

Saludos!

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service