Using Interop.Illustrator In C# .netCore 3.1, Swatch.Color returns a System.__ComObject

Community Beginner ,
May 18, 2022 May 18, 2022

Copy link to clipboard

Copied

For our app, we're trying to iterate through the Swatches that are added to the document when we add other artwork files (AI) to our template. I can loop over the swatches to get the names, but the color property returns a "System.__ComObject" type instead of a color class.

var swatchEnum = (document.Swatches as IEnumerable).GetEnumerator();
while (swatchEnum.MoveNext() {
     Swatch swatch = (Swatch)swatchEnum.Current;
     var name = swatch.Name; //ISACORD 1904 - PMS 186
     var color = swatch.Color; //System.__ComObject;
}

I tried to cast it as an Illustrator.CMYKColor, but that threw an exception. How can I access the color value so I can use that to create a new rectangle with a fillColor to display the colors used in our templates?

TOPICS
How to , Scripting , SDK

Views

23

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation