compas icon indicating copy to clipboard operation
compas copied to clipboard

Polyline & Polygon length bug

Open nmaslarinos opened this issue 2 years ago • 1 comments

Describe the bug When modifying a Polyline's or Polygon's points attribute by adding or removings items from the list, the length attribute is not updated. This problem also occurs when using methods, such as shorten, which directly perform modifications to the list.

To Reproduce Steps to reproduce the behavior:

  1. Environment: VS Code
  2. Sample code:
pl = Polyline([(0,0), (1,0)])
print(pl.length)
pl.points.append(Point(2,0))
print(pl.length)
  1. The results are: 1.0 and 1.0

Expected behavior It would be normal that modifying the points would result in the recalculation of the polyline's length (and on this note, the lines as well)

Desktop (please complete the following information):

  • OS: Windows 11
  • Python version [e.g. 3.10.8]
  • conda

nmaslarinos avatar Jun 13 '23 08:06 nmaslarinos

One idea for a fix would be to create append, extend, insert, del, and pop methods to complement the existing __get__ and __set__ methods. Also, turning the points into a read-only attribute would make the above bud impossible to reproduce, but it could break certain codes.

nmaslarinos avatar Jun 13 '23 11:06 nmaslarinos