Grasshopper

algorithmic 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: 1033

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

I've got quite a tricky issue.

I need all of the planes shown to all face the same direction. However I have two variables that add lines in the x and y direction. And for some reason whenever I do so, there are a few rogue planes that randomly rotate. I do know how to rotate them back into place, however the issue is that some planes rotate at complete random as far as I can tell. If there were a pattern it would be an easy fix but I don't believe there is. 

I've highlighted the planes that have randomly rotated.

Attachments:

Without the file I cannot reproduce this or inspect the data. 

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service