Creating Custom Label Frame

Please note, that the contents of this article apply for versions ending with ARCHICAD 21 only. From ARCHICAD 22, the text-framing logic stays the same in labels, but most of the related global variables are replaced by new fix named optional parameters for text handling and for label specials.

 Example object for this post

In Label objects when the Pointer and the Frame are both turned ON in the settings, ARCHICAD automatically draws a rectangle frame around the 2D symbol of the Label.

TipsAndTricks_CustomLabelFrame_Ex1

From ARCHICAD 20 it is possible to disable the automatic rectangular frame drawn by ARCHICAD allowing the GDL developer to create a custom shaped frame by setting the ac_bDisableLabelFrameDisplay fix named optional parameter to ON.

The connection of the built-in Pointer to the Label 2D Symbol can be also customized by setting the ac_bCustomPointerConnection fix named optional parameter and implementing hotspots with fix unique IDs to define the possible connection points for the Pointer. In case you want to use your custom shaped label head with the built-in pointer, this option will work for you.

The coordinates of the hotspots have to be symmetrical to the vertical axis of the Label Symbol to support left-right snapping of pointer in case the label head is moved.
The unique IDs indicate the following connection points:
TipsAndTricks_CustomLabelFrame_Ex2

 

  • 1: Left Top
  • 2: Right Top
  • 3: Left Middle
  • 4: Right Middle
  • 5: Left Bottom
  • 6: Right Bottom

The fix named parameters read by ARCHICAD should be added to the parameter list of the label and set ON for the customization. Always make the parameters unique and hidden from the user.

TipsAndTricks_CustomLabelFrame_Ex3

The following example presents a Label Symbol with dimensions depending on the displayed text, its font family and font size.

! ------------------------------------------------------------------------------
! Input parameters controlled by the user:
! ------------------------------------------------------------------------------
! fontType 		- (String) font family of the displayed text
! sampleSize 		- (RealNum) indicates the height of the font from the
! 		 	  baseline to the cap height, given in Paper size - mm
! sampleText		- (String) the displayed text

! ------------------------------------------------------------------------------
! 2D script
! ------------------------------------------------------------------------------
! Set Style depending on parameters set by the user
define style "NormalStyle" fontType, sampleSize, 5, 0	! Middle, Normal
style "NormalStyle"

! Get the Height and Width of the displayed Text, convert it to model size
r = request("Height_of_style", "NormalStyle", _heightOfText_mm)

_height	= _heightOfText_mm * GLOB_SCALE / 1000
_width 	= stw(sampleText) * GLOB_SCALE / 1000

! Display the Label Text
text2 0, 0, sampleText

If the ac_bDisableLabelFrameDisplay parameter is set ON, a custom Frame can be drawn acting according the Frame checkbox in the Label Tool. The current value of the Frame checkbox can be accessed through the LABEL_FRAME_ON Global Variable. This way the custom scripted Frame will appear only, while the automatic rectangular frame will be hidden, even if the Pointer is turned on.

In this example the sides of the label symbol frame has semicircles instead of the two vertical lines. The center of the circles are set to the ends of the displayed text.

if LABEL_FRAME_ON then
	line2 -_width/2, -_height/2, _width/2, -_height/2
	line2 -_width/2, _height/2, _width/2,	_height/2
	arc2 -_width/2, 0, _height/2, 90, -90
	arc2 _width/2, 0, _height/2, -90, 90
endif

TipsAndTricks_CustomLabelFrame_Ex4

If the ac_bCustomPointerConnection parameter is set, hotspots can be set up to indicate the possible connection points of the built-in Pointer.
Setting these hotspots defines positions for all the 4 types of connections. To hide these hotspots when the Pointer is not set in the Label Tool, the LABEL_CUSTOM_ARROW Global Variable can be used.

In this example the Pointer in the upper and lower position cases will connect to the custom Frame. The hotspots are only displayed when the Pointer is set:

if not(LABEL_CUSTOM_ARROW) then
	hotspot2 -_width/2,		_height/2, 	1
	hotspot2 _width/2,  		_height/2, 	2
	hotspot2 -_width/2 - _height/2,	0, 		3
	hotspot2 _width/2 + _height/2, 	0, 		4
	hotspot2 -_width/2, 		-_height/2,	5
	hotspot2 _width/2, 		-_height/2,	6
endif

Make sure to avoid hotspot IDs in case of any non-pointer-related hotspots if the ac_bCustomPointerConnection is set up and used in the object.
TipsAndTricks_CustomLabelFrame_Ex5