Home/ Reference/ Layer & Shapes

layer.CreateCurve(...) / layer.CreateFreehandCurve(...)

Builds a curve from an array of points. Used for procedural artwork (flowers, map outlines). The parameter format is fussy.

Signature

layer.CreateCurve(...) / layer.CreateFreehandCurve(...)

Notes

Builds a curve from an array of points. Used for procedural artwork (flowers, map outlines). The parameter format is fussy.

Python example (runnable)

Requires pywin32. The example assumes app / doc / page / layer are already connected. See Connection & Init
Python
import pythoncom
import win32com.client
from win32com.client import VARIANT

layer = doc.ActivePage.ActiveLayer

# build a curve from points: x1,y1,x2,y2,x3,y3... in document units
pts = VARIANT(pythoncom.VT_ARRAY | pythoncom.VT_R8,
              [0.0, 0.0, 2.0, 3.0, 4.0, 0.0])   # units are inches here: about (0,0)-(50,76)-(101,0) mm

try:
    curve = layer.CreateCurve(pts)          # curve : the resulting curve shape
    print("Curve created, nodes: ", curve.Curve.Nodes.Count)
except Exception as e:
    # some versions are picky about point arrays; importing SVG is the sturdier route
    print("CreateCurve failed: ", e)
    layer.Import("D:/images/path.svg", 0, None)

About this section: Layer & Shapes

Layer & Shapes — layers and shape creation.

Other entries in this section