angle=rs.Angle2( points[0] , points[1] , points[-1] , points[-2])
#should work even if the polyline is not closed, but probably doesn't make much sense in that case
Probably means this object references something that you either deleted or doesn’t exist anymore because of some some operation - for example joining two objects results in a new single object id, but the original two ids are then gone.
The modulus is a pretty simple concept, just don’t overthink it and you’ll remember!
It simply returns the remainder of the division of the first number to the second.
For example:
2 % 2 = 0, because 2 fits entirely into 2, and thus 0 remains
2 % 3 = 1, because 2 fits once into 3, and thus 1 remains
6 % 4 = 2, because 4 fits once into 4, and 2 remains
Other than for simply finding the remainder and/or for the case that @Dancergraham already explained, it can for instance be used to deduce if a number is odd or even, meaning divisible by 2 with a remainder of 0:
for i in range(10):
if i % 2 == 0:
print i, "-> even" # remainder is 0
else:
print i, "-> odd" # remainder is 1 or greater
Similar to the example above, it can also be used to create “cyclical” iterations, which will reset once they achieve a certain index:
i = 0 # initial index
while True:
i = (i + 1) % 6 # update the index and resets when i = 5, because (5 + 1) % 6 = 0
These are the most common uses I’ve seen, but there are many others.