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

Adjustable Hotspot for Textblock width

JGoode
Expert
Hi,

Is it possible to add a 2D adjustable hotspot to adjust the width of my textbox?

My text scales with the global scale which is what is causing the issue.

Is there a way to get around this?

Example code for reference:
	HSID=1 
	hotspot2 0, 0,HSID, widthx, 1+128     !base 
	HSID = HSID+1 
	hotspot2 -1, 0, HSID, widthx, 3      !reference 
	HSID = HSID+1 
	hotspot2 widthx, 0, HSID, widthx, 2   !moveable 
Thanks
ArchiCAD 23

Windows 10
10 REPLIES 10
Lingwisyer
Guru
There is no need to do this. If you instead use the Textblock command, you can then use the request to find the width of the Textblock.

GDL wrote:
Use the REQUEST ("TEXTBLOCK_INFO", ...) function to obtain information on the calculated width and height of a textblock.

You can then use this value to set your text box.

TEXTBLOCK "papersize1" 0, 7, 0, 1, 1, 0, Label_Length
dummy = REQUEST ("TEXTBLOCK_INFO", "papersize1", width)
text_offset = width / (1000 / GLOB_SCALE)

That is a segment from one of my objects. In this case, text_offset would be the value for your text box width.



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
JGoode
Expert
The issue with this is that I want to be able to set the width of the textbox in plan for text wrapping purposes.
ArchiCAD 23

Windows 10
Barry Kelly
Moderator
Try this.
I just pulled it from one of my stretchy notes.

You will need a 'length' parameter called "box_wid" and set a default value of say 4000.
And a 'real number' parameter called "text_hgt" with a default value of say 2.0

HOTSPOT2     0.0,     0.0

DEFINE STYLE "AC_STYLE_1" "Arial",text_hgt,1,0



IF symb_mirrored = 1 THEN
	MUL2 -1, 1
	ADD2 -box_wid,0
ENDIF


tab_1 = 0
left_indent = 1

stringval_1 = "Add your note here. You can type what ever you like"

PEN 1


IF symb_mirrored = 0 THEN
	justification = 1
ELSE
	justification = 3
ENDIF

!Define a paragraph
	paragraph "note_1" justification,
		0, left_indent, 0,
		1,
		tab_1

	SET STYLE "AC_STYLE_1"
		"\t" + stringval_1
	endParagraph

!Include the paragraph in a text block

!!TEXTBLOCK name width, anchor, angle, width_factor, charspace_factor, fixed_height,
!!'string_expr1' [, 'string_expr2', ...]

	textBlock "text_block_1" (box_wid*1000/A_),
		7, 0,
		1, 1, 1,
		"note_1"

	rrr = REQUEST("Textblock_Info", "text_block_1", textblockwidth, textblockheight)
	box_hgt = box_hgt + textblockheight*(A_/1000)

!Place the block using the richtext2 command
	richText2 0, 0, "text_block_1"


!stretchy hotspot - note width
	!stretchy hotspot - note width
	hsid=hsid+1 !base
	HOTSPOT2 0,0,hsid,box_wid,1+128
	hsid=hsid+1 !moving
	HOTSPOT2 box_wid,0,hsid,box_wid,2
	hsid=hsid+1 !reference
	HOTSPOT2 -0.0001,0,hsid,box_wid,3

	hsid=hsid+1 !base
	HOTSPOT2 0,box_hgt,hsid,box_wid,1+128
	hsid=hsid+1 !moving
	HOTSPOT2 box_wid,box_hgt,hsid,box_wid,2
	hsid=hsid+1 !reference
	HOTSPOT2 -0.0001,box_hgt,hsid,box_wid,3
	


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
JGoode
Expert
This definitely works and I had tried it but is there any way to make the text maintain the same shape when scale is changed?

Thanks
ArchiCAD 23

Windows 10
Lingwisyer
Guru
JGoode wrote:
This definitely works and I had tried it but is there any way to make the text maintain the same shape when scale is changed?

Thanks

As in link it to GLOB_SCALE?

DEFINE STYLE "AC_STYLE_1" "Arial",	text_hgt * GLOB_SCALE / 1000,	1,	0



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
JGoode wrote:
This definitely works and I had tried it but is there any way to make the text maintain the same shape when scale is changed?

Thanks
As I understand it, you want the width of the text block to change depending on the scale.
The problem there is you are stretching it to a certain width - say 4000mm at a scale of 1:100.
When you change the scale to 1:50 to actually want the width you are stretching to become 2000mm.
So you need to change the value of the stretchy parameter (box_wid) when the scale changes.

This poses a problem because you could just add something like this to the master or parameter script (I have used 'A_' instead of 'GLOB_SCALE').
box_wid = box_wid*A_/100
PARAMETERS box_wid = box_wid
But this won't work as GLOB_SCALE no longer works in the parameter or master script.

You can do the conversion (box_wid = box_wid*A_/100) in the 2D script, but you can not set the parameter value there.

So you are a bit stuck because you can't alter the width parameter based on the scale.

I will have to have a bit of a think about this one.

P.S. 'A_/100' will simply give a value of 1 (100/100) so that at 1:100 scale the object appears exactly the width you want.
The idea then is that as you change the scale the box_wid is altered (50/100) i.e. box_wid / 0.5


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
Could you just display a print width for the textbox width instead with this variable being one that is defined in the 2D script and references your box_wid variable? Or does the displayParam need to be in your parameters list?



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
I don't think the problem is the display value for the hotspot.
It is that JGoode wants the object to physically change size based on the scale.

When you change the scale, all other elements still measure their original value even though they appear bigger or smaller.
Which is what my original note does - it stays the same with, but because the text scales (stays the same printable size), you can fit more characters in the same width box - the height will adjust automatically based o the width of the text.

JGoode wants (I believe) the width of the text block to reduce with the scale to effectively keep the text box looking as it was before - i.e all the line returns in the same place.


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
Barry Kelly
Moderator
As with standard text, I would not display the same text at different scales.
I always have separate annotation layers to suit text at different scales.
It may say the same thing but its position and size will change according to the scale - so I will always duplicate the note for each scale so they can be adjusted separately.

I would do the same with the note object in this case.
Separate notes for each scale.
Not ideal I know if you need to change the content of the note.

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