Use python to write a code to calculate the length of autocad polyline

Answer: # Please enter the code below. import math#Get the point coordinates of the polyline points = [(1,1), (2,1), (2,2), (3,2)]#Calculate the length of the polyline 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("The length of the polyline:",length)

Guess you like

Origin blog.csdn.net/weixin_42577735/article/details/129506866