Browsed by
Tag: line

Calculating Length of Polylines

Calculating Length of Polylines

Compatible with WizoScript versions: 1.42

This example adds up the total lengths of all lines in a sketch in a part that is already open.

# Calculates the total length of all lines in a sketch
# This script assumes a part called 'Polyline' is already open
# and contains a single sketch called 'Sketch<1>' which has the lines
# to measure
 
Units.Current = UnitTypes.Millimeters
 
# get already opened part and then get sketch on part
P = Part("Polyline", False)
S = P.GetSketch("Sketch<1>")
 
# get total length of all lines in the sketch
TotalLength = 0
for Figure in S.Figures:
  if Figure.IsReference == False:
    TotalLength = TotalLength + Figure.Length
 
print "Total length of polyline = %.3f mm" % TotalLength