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 & InitPython
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.
- This section has 10 entries; this is one of them.
- See the full section index: Color
Other entries in this section
- app.CreateRGBColor(Red, Green, Blue)Builds an RGB color, each component 0-255. Screen work, web images, so
- app.CreateCMYKColor(Cyan, Magenta, Yellow, Black)Builds a CMYK color, each component 0-100. If the job ends up on press
- app.CreateGrayColor(Value) / CreateHLSColor(H, L, S) / CreateHSBColor(H, S, B)Three more ways to build a color: gray (0-255), HLS, HSB. For lighter
- color.RGBAssign(R, G, B) / color.CMYKAssign(C, M, Y, K)Changes the components of an existing color in place. No new object —
- color.HLSAssign(H, L, S) / color.HSBAssign(H, S, B) / color.GrayAssign(V)In-place recolor via HLS, HSB or gray. To generate a scale of one hue
- color.ConvertToCMYK() / ConvertToRGB() / ConvertToGray() / ConvertToHLS()Explicit color model conversion. It mutates the object rather than ret
- color.HexValue / color.RGBValueHexValue is a #RRGGBB string you can match against the swatch in the d
- color.BlendWith(OtherColor, Weight)Mixes two colors into an in-between shade. Automatic palettes and tona