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

Referencing Text Anchor

Lingwisyer
Guru
Hi all,

Is there a way to reference a text anchor?

eg. I have variable length text anchored on point 7 and I want to put something defined by a (sub)routine after it based on where the text ended, anchor 9.

eg2. I have a editable text box that I want to offset a square from.


Ling.

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win10 | R5 2600 | 16GB | GTX1660
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Barry Kelly
Moderator
If it is a text block then you can request width and height after you have defined the textblock.
REQUEST ("TEXTBLOCK_INFO", textblock_name, width, height)
If it is just text then you can use STRLEN to get the length.
STRLEN (string_expression)
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

View solution in original post

7 REPLIES 7
Solution
Barry Kelly
Moderator
If it is a text block then you can request width and height after you have defined the textblock.
REQUEST ("TEXTBLOCK_INFO", textblock_name, width, height)
If it is just text then you can use STRLEN to get the length.
STRLEN (string_expression)
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
Lingwisyer
Guru
I seem to only be able to get a return of "2" from:
TEXTBLOCK "papersize" 0, 7, 0, 1, 1, 0, "Hello"
x2 = REQUEST ("TEXTBLOCK_INFO", "papersize", width)
Regardless of the text defined by "papersize". Both width and height return "2".


Ling.

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win10 | R5 2600 | 16GB | GTX1660
Barry Kelly
Moderator
The command is not for either width or height.
You must request both at the same time.

x2 = REQUEST ("TEXTBLOCK_INFO", "papersize", width, height)

Does that make any difference?

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
Lingwisyer
Guru
I get "4" instead

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win10 | R5 2600 | 16GB | GTX1660
Barry Kelly
Moderator
Ah - it is not the "X2" value that you want to use.
The sizes are actually put in the height and width variables.
So it is those that you need to use.

You may need to convert to mm or m depending on how you set up your textblock.
I use a fixed_height parameter of '1' in my textblock and I do this when I use height and width to convert them to a usable dimension to suit the current scale.

height*(A_/1000)
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
Lingwisyer
Guru
Ah. Was wondering how it worked since it returns multiple variables. All good now.

So why is there a need to use it as a definition? In this case, "x2" becomes a dead variable...

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win10 | R5 2600 | 16GB | GTX1660
Barry Kelly
Moderator
'X2' (or the 'return value') just contains a value to say if the request is successful or not.
0 means not successful.
It will return a number of successful results - depending on the request itself.
Not sure why this gives 4 - I would have thought 2.
I don't think it is explained well in the GDL guide that you need to use this return value when using a REQUEST command.
Anyway it doesn't really matter as it is the actual requested values that you want.

Quite often you will see ...
Dummy=Request(.......)

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