cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

2024 Technology Preview Program:
Master powerful new features and shape the latest BIM-enabled innovations

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

center text

Anonymous
Not applicable
Hello,

How to center a text according to its length?
I modified the script to add MASTER_BAIE_X01.gsm a text but I can not focus my text window.
Thank you in advance.

code:
DEFINE STYLE "own" "arial", 1.5, 1, 0

IF texopt then
SET STYLE "own"
string = opt
width = STW (string) / 1000 * GLOB_SCALE
TEXT2 width/2,-0.05, string
endif

IF texvitrage then
SET STYLE "own"
string = vitrage
width = STW (string) / 1000 * GLOB_SCALE
TEXT2 width/2,-0.15, string
endif

2 REPLIES 2
rocorona
Booster
You can, but you don't NEED to.

Instead of calculate the text dimension and move it, simply define it as "centered" using the "2" or "5" align-code

DEFINE STYLE "own" "arial", 1.5, 2, 0

then place it at x=0 coordinate.

TEXT2 0,- 0.05, string
_________________

--Roberto Corona--
www.archiradar.com
AC18 - ITA full on Win10
_________________
_________________
Barry Kelly
Moderator
That depends on whether you want left or right justified text but in the centre of the window or if you just want centre justified text.

Centre justified is the easiest - you just have to change the anchor code.

DEFINE STYLE "own" "arial", 1.5, 2, 0

2 will be centre justified with the anchor at the top of the text (height wise).
5 will be centre justified with the anchor in the centre of the text (height wise).
8 will be centre justified with the anchor at the bottom of the text (height wise).

If you want to keep the left or right justification then you will have to find the length of the text string as you have already done.

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