Grasshopper

generative modeling for Rhino

Hey Everyone,

I'm having trouble rotating multiple planes and then outputting them as a list of rotated planes. Rotating just one set to item access works fine:

x.Rotate(y, New Vector3d(0, 0, 1))

a = x

But when I set the access type to list and try to rotate and output the first item in the list nothing seems to happen:

x(0).Rotate(y, New Vector3d(0, 0, 1))

a = x(0)

I've been searching the forums and it sounds like maybe I need to duplicate these planes before rotating them and then add them to a new list. I'm not sure how to duplicate them but here's me trying to add them to a list rather than output X directly:

Dim plnList As New list (Of plane)

For i As Integer = 0 To x.Count - 1
x(i).Rotate(y, New Vector3d(0, 0, 1))
plnList.add(x(i))
Next

a = plnList

But that didn't work either. I also saw that someone used transform(transform.rotation,,,) but that was to rotate a list of curves, and I'm not sure if that works for planes

Any help is appreciated

thanks,

Brian 

Views: 193

Reply to This

Replies to This Discussion

Planes are structs (Value Types, not Reference Types). So when you ask a list of Planes for an element, you get a copy of that element. In effect, this line:

x(0).Rotate(y, New Vector3d(0, 0, 1))


rotates only a copy. You need to so something like:


Dim plane As Plane = x(i)

plane.Rotate(y, Vector3d.ZAxis)

x(i) = plane


I know this split between structs and classes can be annoying, but the performance benefits we get out of it in RhinoCommon are worth it I think.


--

David Rutten

david@mcneel.com

Poprad, Slovakia

Perfect, thanks a lot David.

-Brian

RSS

Translate

Search Grasshopper

Photos

  • Add Photos
  • View All

© 2013   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service