Grasshopper

algorithmic modeling for Rhino

Hello


I am learning VB, and I have a small problem In the "primer" manual page 111 :

new_line.rotate(angle, OnUtil.On_zaxis,Line_From)

the rotate function is called, but I have an error that this function does not exist

And I have an error also for "OnUtil.On_zaxis" :

'rotate' is not a member of 'rhino.geometry.line'

'Onutil is not declared'

Do you know where the problem comes from?

Views: 1180

Replies to This Discussion


Which programming language is the easiest to learn among VB python C#? (The one most used and possibly with the most documentation)

Andrew Heumann wrote a terrific breakdown of the three scripting languages available through Grasshopper. If I were to add anything I would explicitly specify that we're talking about IronPython (the .NET version of Python, written in C#) and also start by pointing out the difference between dynamically typed (Python/IronPython) and statically typed (C#/VB) languages. While it's not exactly that cut and dry, the primary point is that in the latter you declare types and can compile your code (which is great if you're developing a plugin or a large codebase etc.) and the former tends to be terser (which is great for writing code on the fly and quickly testing algorithms etc.).

ok 

Thank you for your answer, I think I will program in C#

Are there tutorials (as in the "primer" for VB) written for grasshopper in c# ?

great ! it 's work !

Thank you very much

I have diplomas of computer programmers but it has been more than 10 years that I did not do so I must relearn softly ...

Hello,

I have a little question, Here is my code

private void RunScript(Curve x, double t, ref object P, ref object T)

{
Point3d pt = new Point3d();
pt = x.PointAtNormalizedLength(t);

Vector3d vec ;
vec = x.TangentAt(t);
P = pt;
T = vec;

}

Why  I don't have the same thing as the component "evaluate curve"?

Tangent at is applied on curve parameter not normalized
http://developer.rhino3d.com/api/RhinoCommonWin/html/M_Rhino_Geomet...
You can surely use that to convert t
http://developer.rhino3d.com/api/RhinoCommonWin/html/M_Rhino_Geomet...
And you get the interval on the curve with domain
http://developer.rhino3d.com/api/RhinoCommonWin/html/P_Rhino_Geomet...

PointAtNormalizedLength() is not the same as PointAt() on a curve with a normalised domain.

In order to replicate the behaviour of the Evaluate Curve component, your code needs to look like:

private void RunScript(Curve x, double t, ref object P, ref object T)
{
  Interval domain = x.Domain;
  double parameter = domain.ParameterAt(t);
  Point3d pt = x.PointAt(parameter);
  Vector3d tan = x.TangentAt(parameter);
  P = pt;
  T = tan;
}

Thank you !!


I found when David replied ;-) 

Point3d pt = new Point3d();
Vector3d vec ;
Double t1;

t1 = x.Domain.ParameterAt(t);
pt = x.PointAt(t1);
vec = x.TangentAt(t1);


P = pt;
T = vec;


I have the same results as the component "evaluate curve" :D

By cons how can you have the length of a curve? Because the value of the domain does not give me the length.

"domain.T1" gives 27 and my length's curve is 24



I also have other small questions:

- Is it normal that the "run script" button does not work?  

List <Curve> c = new List <Curve> ();     

I declare a list and when I type "c." The drop-down list of available functions does not appear, is this normal? 

Where can I find the functions available for these lists?




By cons how can you have the length of a curve? Because the value of the domain does not give me the length.

"domain.T1" gives 27 and my length's curve is 24

The domain is not synonymous with length. Not only does the 'length' of the domain not necessarily correspond to the length of the curve, equal steps through the domain do not result in equally long steps along the curve.

The domain is a direct representation of the underlying mathematical equations of the curve. Length on the other hand must often be approximated iteratively. This is much slower than domain/parameter access, which is why almost all algorithms use domains. Human beings of course prefer to approach curves from a length-based perspective.

If you want to find which parameter corresponds with a specific length along the curve, you must use the Curve.NormalizedLengthParameter() method.

private void RunScript(Curve C, double L, ref object Pt, ref object Tn)
{
  double t;

  C.NormalizedLengthParameter(L, out t);
  Pt = C.PointAt(t);
  Tn = C.TangentAt(t);
}


Another small question (sorry):

Does a "flip" function for the curves (like the grasshopper component) exist in c# ? I didn't find

Reverse
See the c# on your other discussion

Thank you for your answer.

But in fact I would like to have the length of the curve as the component 'length" in grasshopper. 
Does this function exist in c#?

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service