• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How can I improve the script performance?

New Here ,
May 27, 2014 May 27, 2014

Copy link to clipboard

Copied

Hi,

I wrote an application in VB.NET. This application is using Illustrator to import a drawing in DWG format. Then I change some colors and lines in different layers. Everything works fine! But it is very slow!

I use VB.NET language. For a test I wrote a small program to compare VB.NET with JavaScript. JavaScript is much faster!

VB.NET: 60 seconds
JavaScript: 5 secondes

Is there any solution to make my application faster?

Thumbnails in layers panel are removed.

Is it possible to switch off all screen refreshes in Illustrator?

Harald

TOPICS
Scripting

Views

1.1K

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
Adobe
Community Expert ,
May 27, 2014 May 27, 2014

Copy link to clipboard

Copied

hard to tell without looking at the code, show us a sample.

Votes

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
Engaged ,
May 27, 2014 May 27, 2014

Copy link to clipboard

Copied

Hi Harald,

Nice to see someone "else" is writing in VB.NET. 🙂  Not many of us...

To your question, I typically see the VB.NET code run slower, although I've never benchmarked it. I am a little surprised to see that much of a difference. I continue to use VB.NET because most of my scripting is integrated with other applications.

When you benchmarked your VB.NET test code, did you compile it or are you running in debug mode? The former should give you much better performance.

-TT

Votes

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
New Here ,
May 28, 2014 May 28, 2014

Copy link to clipboard

Copied

Hi TT,

yes, we like VB.NET!

Thank you for your hint. I checked it. There is no time difference between debug and release version.

I think the reason for the slow VB.NET (via COM Interface) performance is, that Illustrator is updating always the screen and did listen to all events.

Can we switch off all Illustrator screen refreshes? Running like a Server.

@CarlosCanto: Here is a code example. We parse items on layers:


function parseGroupItem(groupItem, layerDefinition) {
    for (var i = 0; i < groupItem.pathItems.length; i++) {
        groupItem.pathItems.strokeWidth = mmToPoints(layerDefinition.strokeWidth);

        if (layerDefinition.fillColor != null) {
            groupItem.pathItems.fillColor = layerDefinition.fillColor;
        }
    }

    for (var i = 0; i < groupItem.groupItems.length; i++) {
        parseGroupItem(groupItem.groupItems, layerDefinition);
    }
}

Greetings Harald

Votes

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
Engaged ,
May 28, 2014 May 28, 2014

Copy link to clipboard

Copied

I've tried things like "app.ScriptPreferences.EnableRedraw = False" but there must be something else that kicks the redraw back in because it doesn't seem to work. I've had better performance success with changing "DisplayPerformancePreference" to "Typical" from "High Quality".

Hope this helps.   -TT

Votes

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
New Here ,
May 28, 2014 May 28, 2014

Copy link to clipboard

Copied

Hi TT,

thank you for your help!

But these Settings are not available in Illustrator CS6.

I have checked, these settings are available in InDesign CS6.

But I think this is the correct direction.

How can I run Illustrator in background?

Harald

Votes

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
Community Expert ,
May 28, 2014 May 28, 2014

Copy link to clipboard

Copied

if redrawing is the issue, try turning all layers preview mode off, that might help. I don't have huge files to try.

on the code, repeated calls might add up when multiple items are parsed, this might help a little bit, needs to be timed to see if there's any gain performance

function parseGroupItem(groupItem, layerDefinition)

    var pitems = groupItem.pathItems; // added

    var pcount = pitems.length; // added

    for (var i = 0; i < pcount; i++) { // edited

        var pi = pitems; // added

        pi.strokeWidth = mmToPoints(layerDefinition.strokeWidth); // edited

        if (layerDefinition.fillColor != null) {

            pi.fillColor = layerDefinition.fillColor; // edited

        }

    }

    for (var i = 0; i < groupItem.groupItems.length; i++) {

        parseGroupItem(groupItem.groupItems, layerDefinition);

    }

}

also, is your code running ok? don't you have issues having those two for..loops using the same variable (var i), if you do, change that to var j or some other character

Votes

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
New Here ,
May 28, 2014 May 28, 2014

Copy link to clipboard

Copied

Hi CarlosCanto,

you are right. There is a mistake in the loop. Reason: I have copied from VB.NET.

Regarding the performance problem: Thumbnails are removed in the layers panel -> No difference.

I need to disable all redrawing and refreshing. But how can I do this?

Harald

Votes

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
Community Expert ,
May 28, 2014 May 28, 2014

Copy link to clipboard

Copied

Hi Harald, I meant "preview" mode off (as when you do Ctrl+Y)

Votes

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
New Here ,
May 30, 2014 May 30, 2014

Copy link to clipboard

Copied

LATEST

Hi CarlosCanto,

it makes no difference in preview mode. Unfortunately!

What surprises me: Nobody has problems with the performance. That means all the people are working with JavaScript.

Because this performance problems are only in VB.NET. Is there any statement from Adobe?

Harald

Votes

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
Engaged ,
May 28, 2014 May 28, 2014

Copy link to clipboard

Copied

Harald61 wrote:

Hi TT,

thank you for your help!

But these Settings are not available in Illustrator CS6.

I have checked, these settings are available in InDesign CS6.

But I think this is the correct direction.

How can I run Illustrator in background?

Harald

Oops -- sorry Harald. You are correct -- my mistake - happens when ID is what I've had my head in for the last week or so...  I'll review and get back to you on some other thoughts...  -TT

Votes

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