Home/ Reference/ Pattern / Texture Fill

shape.Fill.ApplyPatternFill(patternType, filePath)

Tiles one of your own images. The path needs forward slashes or doubled backslashes, or Python eats it as escapes. Make the image square and seamless.

Name

shape.Fill.ApplyPatternFill(patternType, filePath)

Notes

Tiles one of your own images. The path needs forward slashes or doubled backslashes, or Python eats it as escapes. Make the image square and seamless.

Python example (runnable)

Requires pywin32. The example assumes app / doc / page / layer are already connected. See Connection & Init
Python
shape = app.ActiveSelectionRange(1)

try:
    pf = shape.Fill.ApplyPatternFill(
        2,                                          # 2 = bitmap pattern
        "D:/images/texture.png",                          # your image, forward slashes
        1,                                          # PatternCanvasIndex, usually 1
        None,                                       # foreground colour, unused in bitmap mode
        None,                                       # background colour
        True)                                       # TransformWithShape: scales along with the shape
    print("Bitmap pattern applied")
except Exception as e:
    print("Apply failed, check the image path: ", e)

About this section: Pattern / Texture Fill

Pattern / Texture Fill — pattern, texture and PostScript fills.

Other entries in this section