Home/ Reference/ Color

color.CopyAssign(SourceColor) / color.IsSame(OtherColor)

Copies one color's values onto another (without changing object references), or tests whether two colors match. In batch recoloring, check first, then write — it sav

Signature

color.CopyAssign(SourceColor) / color.IsSame(OtherColor)

Notes

Copies one color's values onto another (without changing object references), or tests whether two colors match. In batch recoloring, check first, then write — it saves a lot of dead ends.

Python example (runnable)

Requires pywin32. The example assumes app / doc / page / layer are already connected. See Connection & Init
Python
shapes = app.ActiveSelectionRange
target = shapes.Item(1).Fill.UniformColor           # the first one is the reference colour

for i in range(2, shapes.Count + 1):
    c = shapes.Item(i).Fill.UniformColor
    if not c.IsSame(target):
        c.CopyAssign(target)                        # set them all to the reference colour
        print("#", i, " unified")

print("All unified")

About this section: Color

Color — RGB, CMYK and hex color values.

Other entries in this section