Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Andre_b_b on August 03, 2023, 06:26:47 pm
-
Hello guys, i have written a code in VBScript inside Enterprise Architect and it is working but it is taking so long to execute it. Is there any command in VBScript such as "Application.ScreenUpdating = False" in VBA, so my code does not last 3 minutes to execute?
-
What is your script doing? It would be easier to help if you tell us a little more. There might be faster ways to do what you are doing.
For example, if you are using pure API access to get at the contexts of your model you will likely find that using SQL to read will be *much* faster. You'll still want to use API access to write any changes. I've reduced script runtimes from minutes to seconds once I realised this.
STeve.
-
In addition to using SQL to find objects, I find that Jscript is faster than VBscript (there's also the option of Javascript but I've rarely used that).
-
You can use Repository.EnableUIUpdates
Works great if you are doing a lot of additions/deletes that cause the GUI to be updated.
Geert
-
Thanks for your help guys. In fact, the main problem is that my script is reading the same worksheet Excel 3 times and the worksheet contains 800 lines, so, event with Geert's Suggestion, the code takes long to be executed. I must change my code to optimise or i should evaluate the possibility of changing the language.
-
Thanks for your help guys. In fact, the main problem is that my script is reading the same worksheet Excel 3 times and the worksheet contains 800 lines, so, event with Geert's Suggestion, the code takes long to be executed. I must change my code to optimise or i should evaluate the possibility of changing the language.
Only a poor craftsman blames his tools.
It's not the language that is the problem, it's probably the way you read your input from Excel. Reading excel can be very slow, if you don't do it efficiently.
Make sure you get all 800 lines at once using something like sheet.UsedRange.Value2
This will get everything into a two dimensional array.
Afterwards you can loop the array as much as you want.
Looping 800 records in an array will take no longer that a few miliseconds in any language.
Geert