Grasshopper

generative 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

Tags: c#, python, vb.net

Views: 989

Reply to This

Replies to This Discussion

Hi Arthur,

could you upload what you have so far?

Thanks,

- Giulio
_______________
giulio@mcneel.com

Hi  Giulio,

Thanks for your reply!

Please see attached files.

arthur

Attachments:

Hi Arthur,

there were some minor syntax mistakes but one big issue: you should remember to copy objects if you do not want your changes to be not propagated from one tranformation to the next one.

(I've added a rhinoscriptsyntax and a RhinoCommon version of the Python script. Rhinoscriptsyntax works in degrees).

Thanks,

- Giulio
________________
giulio@mcneel.com

Attachments:

Wow thank you so much Giulio! This is so helpful.

I am adding this screenshot which might also help people to understand some of the difference between languages:

Thanks for sharing! I'm studying C# and Python these days and is a really usefull thing.

came across same problem. thanks for sharing~~~~~

RSS

Translate

Search Grasshopper

Photos

  • Add Photos
  • View All

© 2013   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service