Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

Global Variable incorrect?

derekjackson
Expert
Hi folks,
bit of a random one here.

I've adapted Daniel Lindahl's position marker object to create an object with the following code in 2D:
sz=sz/1000
GLOB_SCALE=A_
MUL2 A_,A_  

pX = (X~ + 0.0)
pY = (Y~ + 0.0)

PARAMETERS pX=pX, pY=pY

IF coord=ac1 THEN 
    pX = (pX + defx)
    pY = (pY + defy)
ENDIF

HOTSPOT2 0,0
PEN pen_colour
CIRCLE2 0,0, sz/2
LINE2 -sz,0,sz,0
LINE2 0,-sz,0,sz

!LINE2 0,0,pX,pY

DEFINE STYLE "pmx" font, tht, 7, 0
SET STYLE "pmx"
IF dimen=dim0 THEN
    TEXT2 sz,0, xtext + ": " + STR("%m",pX)
ELSE
    TEXT2 sz,0, xtext + ": " + STR("%.0mm",pX)
ENDIF

DEFINE STYLE "pmy" font, tht, 1, 0
SET STYLE "pmy"
IF dimen=dim0 THEN
    TEXT2 sz,0, ytext + ": " + STR("%m",pY)
ELSE
    TEXT2 sz,0, ytext + ": " + STR("%.0mm",pY)
ENDIF
It seems to work fine - you place the object and it displays its coordinates in the scene.

However, we had an issue yesterday where we placed the object in a file, had the correct reading, saved the file, closed ArchiCAD, opened it again, loaded the file, and the output displayed from the object was completely different (and wrong). It was completely random as well - not a scale issue as far as I can see.

Any ideas? Is it likely to be the object, or something dodgy in the main ArchiCAD file doing strange things to global variables?

We're completely stumped (and quite concerned, as we've been using this object a lot!)

Any suggestions appreciated...

Derek
http://www.lsiarchitects.co.uk
http://derekjackson.artstation.com
AC19 / 21 / 23 / 27
Windows 7 Intel Xeon 18Gb
8 REPLIES 8
Barry Kelly
Moderator
At a glance I can't see anything wrong with the script although I can't see a need for the line ... GLOB_SCALE=A_

Are you hotlinking your file by any chance?

Barry.
One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
derekjackson
Expert
Right, I've made a much simpler version of the object, tried it in a new file (no hotlinks), and we still have the issue - thing is, seems to only be a problem once the object is placed over a certain distance from 0,0.

Here's my code:
pX = X~
pY = Y~

! Marker
HOTSPOT2 0,0
PEN 1
CIRCLE2 0,0, 0.05
LINE2 -0.1,0,0.1,0
LINE2 0,-0.1,0,0.1


DEFINE STYLE "txt" font, 3, 7, 0
SET STYLE "txt"

TEXT2 sz,0.5, "X: " + STR("%m",pX)
TEXT2 sz,0, "Y: " + STR("%m",pY)
When placed close the origin, it remembers it's position absolutely fine.

If you try placing it a huge distance away (we tried X= 613,556,292mm, Y = 202,345,505mm), save the file, close and reopen, the output is completely wrong. If you then close and open it again, the number varies yet again.

Any ideas? Could it be an upper limit on whatever number type the Global Position variables use? Is there a maximum limit on distance from project 0,0 to safely work? Looking through the forum suggests people have had issues - anyone know what the 'safe' limit is?

This has completely stumped us - any help appreciated!

Thanks,

Derek
http://www.lsiarchitects.co.uk
http://derekjackson.artstation.com
AC19 / 21 / 23 / 27
Windows 7 Intel Xeon 18Gb
Frank Beister
Moderator
Have you tried GLOB_WORLD_ORIGO_OFFSET_X and GLOB_WORLD_ORIGO_OFFSET_Y?

What happens, if you reload the library again?
bim author since 1994 | bim manager since 2018 | author of selfGDL.de | openGDL | skewed archicad user hall of fame | author of bim-all-doors.gsm
Gergely Feher
Graphisoft
Graphisoft
To keep numeric precision at optimum, ArchiCAD may reallocate the inner calculation origin which may move it away from the visible project origin. This is typically done when the whole model is far away from the project origin but this strategy can change over time. This was added in AC9 and this offset is recalculated when the project opens. That's why your SYMB_POS_X and SYMB_POS_Y global variables (X~ and Y~) changed after reopening your plan.

You should use this for px and py:
pX = SYMB_POS_X + GLOB_WORLD_ORIGO_OFFSET_X
pY = SYMB_POS_Y + GLOB_WORLD_ORIGO_OFFSET_Y
There is an example for this in GDL reference guide pdf, just after the list of global variables.

HTH,
__________________________________
Gergely Fehér
ArchiCAD Development - Library Team
_________________
Gergely Fehér
Team Leader, Library Team
GRAPHISOFT SE
derekjackson
Expert
Cheers - that seems to have done it!

So - is there a known point after which this variable comes in to play? I assume there's a realistic maximum distance from origin from which it's safe to work...

The reason we're so far out is that we've aligned our survey data to actual world coordinates - the site is roughly 500km from '0,0' so that's where we've placed it. Unfortunately this seems to lead to issues with ArchiCAD's stability.

What does everyone else do? Move every project to 0,0? What about when the project has to be at a fixed position away from 0,0?
http://www.lsiarchitects.co.uk
http://derekjackson.artstation.com
AC19 / 21 / 23 / 27
Windows 7 Intel Xeon 18Gb
Frank Beister
Moderator
Move every project to 0,0?
Absolutely: Yes. ArchiCAD has to handle too big numbers for too precise calculations.

The effect does not aacure, if you place at least one element at 0/0, but I wouldn't do it.

If you have to position coordinate points into your plan, I would modify a object to use two offset parameters.
bim author since 1994 | bim manager since 2018 | author of selfGDL.de | openGDL | skewed archicad user hall of fame | author of bim-all-doors.gsm
alemanda
Advocate
I have the same problem but even using the GLOB_WORLD_ORIGO_OFFSET_X (& Y) I don't get any good result. In particular I get zero value for both the offset (but, of course, in the project there's an offset of the user origin from the fixed origin) ...
any help?
AC27 latest hotfix

Win 10 Pro 64bit

Double XEON 14 CORES (tot 28 physical cores)

32GB RAM - SSD 256GB - Nvidia Quadro K620

Display DELL 25'' 2560x1440

www.almadw.it
ztaskai
Graphisoft Alumni
Graphisoft Alumni
alemanda,

It's ok. Gergely's earlier post tells about the reasons behind the working you're experiencing.

Regs,
Zsolt Táskai
ArchiCAD Development - GDL Team
AC13, AC14 and upwards...