Grasshopper

algorithmic modeling for Rhino

C# point bewtween lines/Problem converting datatypes?/Looping through two sets of points

Hello world,

today tried dividing 2 Lines connecting the point sets looping through them.

Occured  errors i think it is about convertoing data types/declaring the variables corrctly.

Maybe someone could have a look, got stuck and dont know where to begin.

Thanks!

Views: 1235

Attachments:

Replies to This Discussion

See attached.

Attachments:

Hi Daniel,

may i ask you how to declare this variables underlined in the screenshot?Why is it:

double[] param0? Is it becuase the main output is a double?

Thanks!

gracias eee:)

No se a qué variables te refieres, en la captura del post no hay ninguna subrayada.
Curve.Divide(...) devuelve Double[], no Double. Aunque el tipo de valor es el mismo, te daría error si lo asignas a una variable de tipo Double cuando devuelve una matriz de Double. En caso de sólo interesarte los puntos, podrías prescindir de asignarlo a una variable, y simplemente usar el parámetro opcional de referencia "ref Points" (tu le das una variable a una función como argumento/parámetro de referencia y esa variable te la modifica internamente, en este caso llenándolo de puntos, por lo que en la siguiente línea de código ya tienes los puntos ahí dentro, esto suele hacerse cuando quieres que una función devuelva resultados de distinto tipo), que es lo que ha hecho Peter pero usando una sintaxis poco básica.

Hola Daniel,

perdon, se me olvido subir la imagen, pero aun asi me entendiste bien:)

Exactamente a esto me referia.

Muchas gracias por la explicacion, si vi en el post de Peter, que el puso Point3d en vez de Double[].

 Declarar todas las variables todavia me confunde un poco.

Te agradesco mucho tu ayuda, trato de entenderlo para poder aplicarlo en el futuro!

Que tengas un buen dia y saludos desde el df!

De nada. Poco a poco ;)

Para aclarar, Peter puso:

Point3d[] ptsSet0; crvs[0].DivideByCount(div, true, out ptsSet0);

que es lo mismo que poner:

Point3d[] ptsSet0;

crvs[0].DivideByCount(div, true, out ptsSet0);

Se comió un salto de línea para sintetizar, pero no cambia nada. Por lo que no está asignando el resultado de la función a ninguna variable, sino solamente declarando una variable de tipo Point3d[] y pasándola como argumento de la función, en una misma línea. El punto y coma separa sentencias en C#. 

gracias por aclararlo Daniel!

"Se comió un salto de línea" por eso es del lado oscuro jeje

Hmm ...

Attachments:

And the next step (out of too many)

Attachments:

Nice one,

for me way to advanced to understand maybe the overnext step.Just recently joined the dark side.

greetings!

Attachments:

Thanks for the cookie Peter!

obviously i dont understand exaclty how it happens, thought befor looking at the code you were using some kangaroo, but it just are vectors, nice that!

Read this thread yesterday http://www.grasshopper3d.com/forum/topics/automate-loop-line-drawn-...

Very nice i really like the shortest walk swarm thing.

Speaking about the thread mentioned don't forget to play with the handsome rats (invisible if you open the R file ... since they are instance definitions [blocks]).

Drop a world if you want that "kind of thing" (recursion) being applied to your point case > freaky stuff and the likes. We only need a paranoid "loop" like this (that calls itself):

public void DoThisDoThat (ref DataTree<Curve> crvTree){

  List<Curve> crvList = crvTree.Branch(loops -1).ToList();

  for(int i = 0; i< crvList.Count-1;i++){

    Curve c1 = crvList[i]; Curve c2 = crvList[i+1];

    List<Curve> newCurves = DivideCurves(c1,c2,div,factor, mode);

    crvTree.AddRange(newCurves, new GH_Path(loops);

  }

  loops++;

  if(loops > maxLoops) return; // i.e. Adios Amigos

  DoThisDoThat (ref crvTree);

}

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service