"semi" global variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2012-06-07
03:29 AM
- last edited on
‎2023-05-24
11:49 AM
by
Rubia Torres
It has proven to be invaluable when numbering parking spaces when there are over 1000 in several stories and the layout keeps changing. Because of the way it was coded, there is a variable that gets calculated inside the 2D script that counts the total number of parking spaces and displays it as text. Back then I used a user_global_variable to be able to read that value and pass it to the parameter script, so I the could use this value in schedules.
It had been working great until I noticed that the global variable value gets carried over to the next object I select. The parameter shows the carried value upon first opening the settings for the object, hit ok or cancel and open it again and it shows the correct value, as the global_variable gets recalculated. I just hadn't picked on that one. Somehow rebuilds took care of this, but now I'm seeing count errors because of this.
So... after a large explanation:
Is there a way to pass a value from the 2D script to the parameter so it can be scheduled without using a global variable? or a "semi" global variable that has a scope of master, 2d, 3d or parameter script but not outside the object?
What I'm really trying to avoid is to rewrite a great deal of code just to put all calculations in the master script (which now I know I should've done) and leave only lines and such in the 2D script. And because of the way it works, I can't find a way to calculate the value in the master_script.
I tried to put the whole thing in the master script and erased the use of the global variable, and works great in 2D, but even though it has no 3D info, there's an error saying I can't delete transformations above TOP when opening the 3D window, so I would need to review the whole thing anyway to check transformations.
I also tried GLOB_CONTEXT to limit the extents to the floor plan and editing window but it just locks the whole thing, and can't be edited anymore.
Any pointers would be appreciated.
Best Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2012-06-07 04:01 PM
It's logical now, but I guess it should be noted in the GDL reference guide that not including EVERY context the object will be working on kinda locks it. I had used GLOB_CONTEXT 2 for the floor plan, but didn't work on the library part editor, so I added GLOB_CONTEXT 1 also; but this didn't solve the locked graphical hotspots, until I added GLOB_CONTEXT 22... graphical editing mode in the floor plan. In the end, the code was:
IF GLOB_CONTEXT=1|GLOB_CONTEXT=2|GLOB_CONTEXT=5|GLOB_CONTEXT=22 THEN GOTO "START" ELSE END ENDIFand then added a label for the beginning of the script. Still gives the transformations DEL error when switching to side view or 3d view in the settings dialog (GLOB_CONTEXT 5)... but I can live with that for now.
Still, any other ideas are welcome.
Cheers!
*will update the object in the depository as soon as I clean up the code a little.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2012-06-07 09:48 PM
So, ADD2 ROT2 and MUL2 are ignored, but DEL are executed, as this command (like PEN and a few more) doesn't have different names for 2D and 3D Scripts.
As a "brute solution" I suggest you to simply add something like this, on top of your Master Script
FOR f=1 TO 50 ADDx 1 ADDx -1 NEXT f
so the 3D transformation stack doesn't run out of data...
--Roberto Corona--
www.archiradar.com
AC18 - ITA full on Win10
_________________
_________________
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2012-06-08 12:41 AM
I did change some of the DEL commands to DEL TOP and those worked, but I would need to review every transformation because in some places it changes the original behavior of the 2Dscript.
In the end, I'm actually thinking of rewriting the whole thing, but just don't have the time right now.
Thanks for the info.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2012-06-08 08:21 AM
ROT2 45 ADD2 1, 0 [commands] ADD2 -1, 0 ROT2 -45 ! instead of DEL 2
OR
use a more complex form, substituting each
DEL
(interpreted as DEL 1) with
DEL (MIN(NTR(),1)
that acts as DEL 0 if the transformation stack is empty... I can't test it now, not sure if it works! IF DEL 0 is not accepted, then an IF...THEN will solve, but this require an heavy job on the already written scripts
--Roberto Corona--
www.archiradar.com
AC18 - ITA full on Win10
_________________
_________________
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2012-06-08 03:53 PM
Thanks a lot for your help.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2012-06-09 09:32 AM
These instructions in the Master Script are "(message) error free"
CIRCLE2 0, 0, 0.2 BLOCK 1, 1, 1 ADD2 1, 0 CIRCLE2 0, 0, 0.2 SPHERE 0.5 DEL MIN(NTR(), 1) ADD2 0, 1 CIRCLE2 0, 0, 0.2 DEL MIN(NTR(), 1) CIRCLE2 0, 0, 0.1 CIRCLE 1
In 2D they are interpreted as
CIRCLE2 0, 0, 0.2 ADD2 1, 0 CIRCLE2 0, 0, 0.2 DEL 1 ADD2 0, 1 CIRCLE2 0, 0, 0.2 DEL 1 CIRCLE2 0, 0, 0.1
resulting in 3 circles with a smaller 4th inside the firs one. And the origin point reset to the default 0,0 position.
In 3D the same are interpreted as
BLOCK 1,1,1 SPHERE 0.5 DEL 0 DEL 0 CIRCLE 1
resulting in a cube with a "saturn" on a corner. No error messages.
--Roberto Corona--
www.archiradar.com
AC18 - ITA full on Win10
_________________
_________________
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2014-04-03 10:06 AM