10 Replies Latest reply on May 30, 2014 5:47 AM by Harald61

    How can I improve the script performance?

    Harald61

      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

        • 1. Re: How can I improve the script performance?
          CarlosCanto Adobe Community Professional & MVP

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

          • 2. Re: How can I improve the script performance?
            ThinkingThings Level 1

            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

            • 3. Re: How can I improve the script performance?
              Harald61 Level 1

              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[i].strokeWidth = mmToPoints(layerDefinition.strokeWidth);

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

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

               

              Greetings Harald

              • 4. Re: How can I improve the script performance?
                ThinkingThings Level 1

                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

                • 5. Re: How can I improve the script performance?
                  Harald61 Level 1

                  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

                  • 6. Re: Re: How can I improve the script performance?
                    CarlosCanto Adobe Community Professional & MVP

                    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[i]; // 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[i], 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

                    • 7. Re: How can I improve the script performance?
                      Harald61 Level 1

                      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

                      • 8. Re: How can I improve the script performance?
                        ThinkingThings Level 1

                        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

                        • 9. Re: How can I improve the script performance?
                          CarlosCanto Adobe Community Professional & MVP

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

                          • 10. Re: How can I improve the script performance?
                            Harald61 Level 1

                            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