algorithmic modeling for Rhino
I don't understand why this is not allowed :S
This is the general situation:
Dim vSpeed As New List (Of Vector3d)
For statement...
vSpeed(j).Z = -vSpeed(j).Z
Next...
Error: Expression is a value and therefore cannot be the target of an assignment.
I've solved it with this:
Dim vZ As Vector3d
Dim vSpeed As New List (Of Vector3d)
For statement...
dZ = vSpeed(j)
dZ.Z = -dZ.Z
vSpeed(j) = dZNext
Anyone knows why this happens?
Tags:
It happens because Vector3d is a Value Type ('Structure' in VB).
When you get a structure out of a list using vSpeed(i) you get a copy of the actual vector stored inside the list. When you then access the Z of this vector, you are only modifying the copy. Since this copy is not stored anywhere the compiler sees that you are performing a meaningless operation and thus warns you about it.
Your solution of getting the vector, modifying it, then putting it back is the correct approach.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Hey!, thanks for the reply David. I always like to understand things from the foundations :)
What a turn around for something really simple...¬.¬
Best Regards.
I believe if you use an array instead of a list (meaning you have to know how many items you have in advance) you won't have this problem :)
Mmmm...changing to arrays for some task then.
Thanks!
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by