Question about - rs.VectorReverse

Hi;
When the distance between the red points and the point decreases, I want to reverse the vectors. The code does not fail but is not working. Can you help me?

import rhinoscriptsyntax as rs

def rotated():
red = rs.coerce3dpointlist(red_)
point=rs.coerce3dpoint(pointID)
distances=rs.Distance(red,point)
if distances < 8.00 : return
vector=rs.coerce3dvector(vector_)
vector2 = rs.VectorReverse([1,0,0])
print vector2

distance = redPt.DistanceTo(pt)
if distance > 8.00:
    vector = -vector
a = vector

ReverseVector.gh (4.5 KB)

2 Likes

Hello,

You define a function but do not call it so it does not execute. The function returns none for short distances and does not return anything otherwise.

The code outside the function can not access variables defined inside it : you have to return the value you are looking for.

Hope this helps

Graham

2 Likes

When I link the code to my model it gives this error. Is it because the points are moving?

Runtime error (MissingMemberException): ‘NoneType’ object has no attribute ‘DistanceTo’

Traceback:
line 1, in scriptFirst implicit Grasshopper cycle.

I guess I couldn’t fully understand what you mean. :frowning:

I ran the code but now there is no change. When I move the red points, the direction of the vectors needs to change. Can I change the direction of the points in the simulation without connecting the vectors?

02.05.2020_Model.gh (25.3 KB) 02.05.2020_sena.3dm (2.2 MB)