I couldn't resist and had to give this a try. Here are some of my results using different settings.

Below is the code used to create them. I didn't bother to create a nice interface and instead, there are some variables you'll need to change the values of to define the size and shape. startLength defines the length of the first line. decay is how much shorter the line gets as each line is drawn. Both of these are in centimeters. numSides is the number of sides in the polygon. The examples above use 8, 8, 3, and 12.
#Author-
#Description-
import adsk.core, adsk.fusion, traceback
import math
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
des: adsk.fusion.Design = app.activeProduct
root = des.rootComponent
# Create a new sketch on the base X-Y construction plane.
sk: adsk.fusion.Sketch = root.sketches.add(root.xYConstructionPlane)
# Define the parameters controlling the shape.
startLength = 100
decay = 1
numSides = 8
# Get the SketchLines collection, which supports the ability to create new lines.
lines = sk.sketchCurves.sketchLines
# Defer the sketch compute. This will improve the performance.
sk.isComputeDeferred = True
sideLength = startLength
lastLine: adsk.fusion.SketchLine = None
lineCount = 0
while sideLength > 0:
# Compute the current angle based on the number of lines drawn so far.
angle = ((math.pi * 2) / numSides) * (lineCount % numSides)
if lastLine is None:
# For the first line, define the starting point at the origin.
startPoint = adsk.core.Point3D.create(0, 0, 0)
startCoord = startPoint
else:
# For subsequent lines, the start point is the end of the last line.
# Using the sketch point of the last line will also connect the lines.
startPoint = lastLine.endSketchPoint
startCoord = startPoint.geometry
# Calculate the end point based on the start point and the current angle.
endPoint = adsk.core.Point3D.create(startCoord.x + (sideLength * math.cos(angle)),
startCoord.y + (sideLength * math.sin(angle)))
# Draw the line and call doEvents to allow Fusion to render the line. Rendering it
# isn't necessary and actually increases the time but it makes it more fun to watch.
lastLine = lines.addByTwoPoints(startPoint, endPoint)
adsk.doEvents()
# Change the side length for the next line and increment the count.
sideLength -= decay
lineCount += 1
# Turn the sketch compute back on.
sk.isComputeDeferred = False
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
---------------------------------------------------------------
Brian EkinsInventor and Fusion 360 API Expert
Website/Blog:
https://EkinsSolutions.com