用python写一段计算autocad多段线长度的代码

答:# 请在下面输入代码。import math#获取多段线的点坐标 points = [(1,1), (2,1), (2,2), (3,2)]#计算多段线的长度 length = 0 for i in range(len(points)-1): p1 = points[i] p2 = points[i+1] length += math.sqrt((p1[0]-p2[0])**2 + (p1[1]-p2[1])**2)print("多段线的长度:",length)

猜你喜欢

转载自blog.csdn.net/weixin_42577735/article/details/129506866