I have an AC19 GDL code optimization issue I would like to hear a comment on.
The problem is rather simple — a 2D script of any GDL object is fired every time when a 3D view loaded/3D tab accessed. However, it should not. This odd behavior can potentially slow down loading of a 3D view on large projects a lot.
Background:
I am only looking at three scripts in a very simple GDL object at the moment:
Master script, 2D script and 3D script.
As per AC documentation, any code in the Master script is executed before any other script does. This works and I don't have any questions here.
In my particular case, Master script is blank. There is nothing there to execute and I only brought it up to prevent further questions regarding Master script.
2D script.
A bit of a reference from the GDL Guide:
Execution context
The 2D script is executed when a 2D model is generated:
• 2D plan
• 2D editing feedback
• 2D preview in the Object Settings dialog window
• Layout drawing
• Layout drawing feedback
Got it. Fine with me. I am looking at a very simple code in a 2d script of a GDL object:
dim arr[]
for i = 1 to 4000000
arr = i
next i
circle2 0,0,1
All this code does is running a long loop to display a sizable delay (spinning wheel) before drawing a simple circle in 2D.
When I access a plan view of a project containing just this one GDL object with 2D script above, I am experiencing a sizable delay before the circle is drawn. Fine. Works as expected.
However, when I move to 3D view the delay caused by 2D script's loop (spinning wheel) is still there. It should not be. The 3D script of an object in question has only one line:
circle 1
3D should not have any delays, but it does. It has the same delay as in 2D view, because 2D script is fired every time 3D is generated (it should not!)
Now to 3D script:
As per reference:
Execution context
The 3D script is executed each time a 3D model is generated:
• 3D window (wire, hidden line, solid model)
• 2D plan when project2 is used to project the 3D model to 2D
• 2D section - mind the details
• 3D editing feedback - optimize for speed
• Operator for solid operations in 3D - ask the designer for the desired functionality
• Surface and volume calculation for Listing
• 3D preview in the Object Settings dialog window
• Layout drawing when project2 is used to project the 3D model to 2D
• Layout drawing feedback
None of the above seem to apply and nothing warrants a 2D script firing every time before 3D is loaded.
To sum up:
We have a very simple GDL object:
Master Script: none
2D Script: dim arr[]
for i = 1 to 4000000
arr = i
next i
circle2 0,0,1
3D script:
circle 1
Why is there a delay in 3D?
Any comments?
EDIT:
Gets better.
If a "for i" loop is in 2D script, the delay will manifest itself on any 2D or 3D load even if the object is in Embedded Library and not even placed on plan.
On the other hand, if the "for i" loop is inserted into 3D script, it works as it should. I.E. no delay on 2D load and no delay if the object is not placed on plan. The delay will still be there if 3D is opened. So 3D script works correctly.
As it stands now, there are two issues here (the second one is a more generic case of the first one):
1. A 2D script of any GDL object (placed in Embedded Library and placed on plan) will be processed by ARCHICAD (i.e. slow down the model) every time any 3D view is recalled. It shouldn't.
2. Even wider issue: A 2D script of any GDL object (placed in Embedded Library) will be processed by ARCHICAD (i.e. slow down the model) every time any ARCHICAD view at all is recalled. This happens even if the object is not placed on plan.
What's up with 2D script interpretation?