2025-07-24
02:16 PM
- last edited on
2025-07-24
03:10 PM
by
Laszlo Nagy
Hello!
I'm trying to script a 2D object with parametric text.
Problem is, when object is stretched smaller than text size - there is no possible to regain stretching option in plan view, because bounding box hotspots are outside object itself hotspots.
Here is the 2D code for example object -
============================================
RECT2 0, 0, A, B
! Hotspots for stretching
HOTSPOT 0, 0, 1
HOTSPOT A, 0, 2
HOTSPOT A, B, 3
HOTSPOT 0, B, 4
! Text style
DEFINE STYLE "NoStretch" "Arial", 1, 5, 0
SET STYLE "NoStretch"
! Text placement
TEXT2 A/2, B/2, label
Operating system used: Windows
Solved! Go to Solution.
2025-07-25 07:49 AM - edited 2025-07-25 07:57 AM
We're in the wrong sub...
By the sounds of it, the text is the annotation, not the frame, for the shape, so custom hotspots would be the way to go. Toggling edittable base hotspots will allow you to use a single set of hotspots (edittable hotspots require 3 actual hotspots) to control the axis of two adjactent corners. Or you could just script two sets for say the top right corner and have that as your size adjustment. Also, you should be using HOTSPOT2, hence why you are getting bounding box hotspots instread of the ones you are scripting.
Ling.
AC22-28 AUS 3110 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win11 | R5 2600 | 16GB | GTX1660 |
2025-07-24 03:47 PM - edited 2025-07-24 03:47 PM
I have not done this in GDL before but I think you can use the following request the get the exact width of a Text Block:
n = REQUEST ("TEXTBLOCK_INFO", textblock_name, width, height)
Returns in the given variables the sizes in x and y direction of a text block previously defined via the TEXTBLOCK command.
The sizes are in mm or in m in model space depending on the fixed_height parameter value of TEXTBLOCK
(millimeters if 1, meters in model space if 0 ). If width was 0, the request returns the calculated width and height,
if width was specified in the text block definition, returns the calculated height corresponding to that width.
Expression returns 0 and contains dummy return values (emtpy string or 0) if used in parameter script, causing additional warning.
If you know the width of the Text Block then my guess is that after each change, you can make sure that the bounding box of the Library Part is always the same size as the Text Block?
Someone please correct me if I am wrong about this.
2025-07-25 06:38 AM
You will need to script adjustable or 'graphical editing' hospots for the corners of the box.
Have a look in the GDL manual for 'graphical editing using hotspots'.
Barry.
2025-07-25 07:49 AM - edited 2025-07-25 07:57 AM
We're in the wrong sub...
By the sounds of it, the text is the annotation, not the frame, for the shape, so custom hotspots would be the way to go. Toggling edittable base hotspots will allow you to use a single set of hotspots (edittable hotspots require 3 actual hotspots) to control the axis of two adjactent corners. Or you could just script two sets for say the top right corner and have that as your size adjustment. Also, you should be using HOTSPOT2, hence why you are getting bounding box hotspots instread of the ones you are scripting.
Ling.
AC22-28 AUS 3110 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win11 | R5 2600 | 16GB | GTX1660 |
2025-07-25 12:56 PM
Hi!
Thank's, Ling!
Problem was so obvious and simple! I just forgot to use HOTSPOT2 instead of HOTSPOT, haaha.
Now it is possible to stretch my rectangle even if it is smaller than annotation text.
PS
I'm still curious how to use TEXTBLOCK , PARAGRAPH and RICHTEXT, commands. Have not seen working simple example code on net so far .
Kaspars.
2025-07-25 05:40 PM
You can use TEXTBLOCK , PARAGRAPH and RICHTEXT to get Texts with linebreaks, while you are strechting the textbox.
See download for a simple example object.
On the Graphisoft GDL Website you can find other examples: https://gdl.graphisoft.com/tips-and-tricks/