Grasshopper

algorithmic modeling for Rhino

Hi Guys,

I am trying to incrementally rotate a line using the codes below in c# and Vb.net. The components show no error but they only overlap lines...Any idea what is going wrong? The python attempt just gave the strange message "i" unexpected token "i".

Many thanks,

on C#:

Arthur

private void RunScript(Curve ln, int x, double angle, ref object A)
{

List<Curve> lines = new List<Curve>();
Int16 i = default(Int16);

for(i = 0; i <= x; i++){
ln.Rotate(angle * i, Vector3d.ZAxis, ln.PointAtEnd);
lines.Insert(i, ln);
}

A = lines;

on VB.net:

Private Sub RunScript(ByVal ln As Curve, ByVal x As Integer, ByVal angle As Double, ByRef A As Object)

Dim lns As New List(Of Curve)()
Dim i As Int16

For i = 0 To x
ln.Transform(transform.Rotation(angle * i, vector3d.ZAxis, ln.PointAtEnd))
lns.Insert(i, ln)
Next

A = lns

in python I get the strange error : unexpected token "i"

For i in xrange(0,x):
    rs.RotateObject(angle * i, vector3d.ZAxis, ln.PointAtEnd)
    rs.AddLine(lns)
A = lns

Views: 4979

Replies to This Discussion

Hi Matthew,

  this thread is quite old. Can I ask which variable you are trying to call (usually "calling" means "invoking", or doing this: "variable()" ).

That strange error was due to the fact that "for" was spelled "For" (case sensitivity). In general, you do not need to initiate the loop variable in Python.

Giulio

--

Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service