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 & InitPython
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.
- This section has 14 entries; this is one of them.
- See the full section index: Layer & Shapes
Other entries in this section
- layer.CreateRectangle2(x, y, w, h)Draws a rectangle. (x, y) is the bottom-left corner; w and h are width
- layer.CreateRectangle(l, t, r, b)Rectangle from four edges. t (top) must be a larger number than b (bot
- layer.CreateEllipse2(x, y, w, h)Ellipse from bottom-left corner plus size. w == h gives a circle.
- layer.CreateEllipse(l, t, r, b)Ellipse from four edges.
- layer.CreateArtisticText(left, top, text, lang, charset, font, size, bold, italic, underline, align)Creates artistic text (a single-line heading). size is in points, not
- layer.CreateParagraphText(left, top, right, bottom, text, lang, charset, font, size, bold, italic, underline, align)Creates paragraph text that wraps inside a box. Requirement: top > bot
- layer.Import(path, filter, options)Imports an image, SVG or other external file. 0 means auto-detect the
- layer.Activate()Makes this the active layer.