Adobe Illustrator Scripting VERY slow - C#
Adobe Illustrator Scripting VERY slow - C#
Hello,
i'm developting a small library to access PathObjects in Illustrator (works fine for CS2, CS5) - but i have massive performance problems with CC2019. I am using VS2017.
Code looks like:
Type AIType = Type.GetTypeFromProgID(AIAppName);
dynamic illuApp = Activator.CreateInstance(AIType);
if (illuApp == null)
{
return;
}
if (illuApp.Documents.Count < 1)
{
return;
}
System.Array lll = illuApp.ActiveDocument.selection;
if (lll != null)
{
for (int i = 0; i < lll.Length; i++)
{
dynamic path = lll.GetValue(i);
if (path != null)
{
var lll2 = path.PathPoints;
Application.DoEvents();
int iSelCount = lll2.Count;
if (iSelCount >= 4)
{
string sss = path.typename;
float dH = (float)(path.Height / dScale);
float dW = (float)(path.Width / dScale);
float dL = (float)(path.Left / dScale);
float dT = (float)Math.Abs(path.Top / dScale);
dynamic obCol = path.FillColor;
sss = obCol.typename;
Color col = Color.Black;
if (sss.Contains("CMYK"))
{
var r = (int)(255 * (1 - obCol.Cyan / 100) * (1 - obCol.Black / 100));
var g = (int)(255 * (1 - obCol.Magenta / 100) * (1 - obCol.Black / 100));
var b = (int)(255 * (1 - obCol.Yellow / 100) * (1 - obCol.Black / 100));
col = Color.FromArgb(r, g, b);
}
else if (sss.Contains("RGB"))
{
int r = (int)(obCol.Red);
int g = (int)(obCol.Green);
int b = (int)(obCol.Blue);
col = Color.FromArgb(r, g, b);
}
Data.Add(NewInfo (dL, dT, dW, dH, col);
}
}
}
}
Until CS5, processing 1000 selected rectangles need a couple of seconds, but on newer CC Versions it needs MINUTES.
I use exactly the same code - is there something i am missing?
Mainly accessing "path.PathPoints" (needs ~ 15 msec.) and "path.FillColor" (needs ~ 20 msec.) are time consuming.
Thanks in advance for any hint! I have the performance issues on Win 7 and on Win 10.
Leopold