Determine scale in the master script.
![Barry Kelly Barry Kelly](https://community.graphisoft.com/legacyfs/online/avatars/actalk/a27517d178c246abb0dd17b6f4f6758a_153.jpg)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2021-01-12
09:20 AM
- last edited on
‎2021-09-14
01:30 PM
by
Noemi Balogh
Since version 20 it will always default to a value of 100.
The issue I have is I have created a label that reads text values from objects.
The text is stretchy and will adjust with the label text box width - so I can have multi-line text if needed.
All works really well.
The default width of the label is fine for lengthy text.
But when the text is very short, the text box default is really too wide and is a bit annoying.
I can manually stretch the box but that is not the issue - I am trying to avoid that.
I can determine the length of the text and can set the text box width accordingly, but because it is a parameter (A), it must be set in the Parameter or Master scripts.
I need to label my objects at different scales - which it where the problem arises.
The text box width needs to change automatically based on the scale of the object.
At 1:100 the width might be 2000mm, at 1:50 it would only need to be 1000mm wide and at 1:200 it would need to be 4000mm wide.
But because I can not determine the scale in the master script, there is no way I can determine a multiplication factor to use for that scale.
I could add a manual option into the object for the user to choose the scale, but I really don't want to do that.
I have tested and proved that I can automatically set the text box width based on the maximum length of the text string.
I just need to be able to determine the scale now.
So how can I determine the current scale from the master script?
Barry.
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
- Labels:
-
Library (GDL)
![Kristian Bursell Kristian Bursell](https://community.graphisoft.com/legacyfs/online/avatars/actalk/a27517d178c246abb0dd17b6f4f6758a_76711.jpg)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2021-01-12 10:36 AM
The GLOB_SCALE global variable which returns the scale was deprecated in version 20 for the parameter and master script. However you can still use it in the 2D, 3D and interface scripts.
So the flaw in your logic is that you are trying to assign the text box size to a parameter.
The solution is to forget your "A" value for the text box size and simply do all the text box size determination in the 2D script, where you can still reference the scale with the GLOB_SCALE variable.
![Kristian Bursell Kristian Bursell](https://community.graphisoft.com/legacyfs/online/avatars/actalk/a27517d178c246abb0dd17b6f4f6758a_76711.jpg)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2021-01-12 10:38 AM
STW (string_expression)
Returns the (real) width of the string in millimeters displayed in the current style. The width in meters, at current scale, is STW(string_expression)/1000*GLOB_SCALE
![Barry Kelly Barry Kelly](https://community.graphisoft.com/legacyfs/online/avatars/actalk/a27517d178c246abb0dd17b6f4f6758a_153.jpg)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2021-01-13 01:54 AM
Kristian wrote:
So the flaw in your logic is that you are trying to assign the text box size to a parameter.
Thanks Kristian,
I understand how it works in 2D.
The problem is exactly that I want to control the width parameter for the text box.
My labels will only ever be placed at one scale, I have separate annotation layers for each scale so the text can appear in different locations or even say completely different things.
I can stretch the box and of course the width parameter will adjust to suit.
I want it to get the width of the text string and adjust the text box width parameter automatically to reduce it if the box is wider than the actual text.
It can be done - I just can't set the parameter automatically.
I can stretch the box, or I can set up a favourite with a reduced width or I could possibly even add a manual option where the user set the scale.
But I would rather it all be automatic.
I can do it all without using the text box width parameter, but using the label it is a bit difficult to explain to users that with all other labels, you can adjust the width in the info box, but with this label they can not.
Maybe that is just what I will have to do - it is stretchy after all so easy to adjust.
Barry.
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
![Kristian Bursell Kristian Bursell](https://community.graphisoft.com/legacyfs/online/avatars/actalk/a27517d178c246abb0dd17b6f4f6758a_76711.jpg)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2021-01-13 02:49 AM
I understand how it works in 2D.I thought so.
I even commented to my wife when I saw this post last night, that a very experienced and knowledgeable Archicad and GDL user has asked a question I would expect from a novice.
![Kristian Bursell Kristian Bursell](https://community.graphisoft.com/legacyfs/online/avatars/actalk/a27517d178c246abb0dd17b6f4f6758a_76711.jpg)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2021-01-13 02:52 AM
however I no longer use this part as i think it was a clumsy result. It required two width parameters, one that was for the use of the dynamic hotspot which would alter the value of the width multiplication, otherwise the multiplication would jump to 2x after moving 2 meters. Very messy logic, but may work if you get the math between the STW, dynamic hotspot parameter, & width multiplying parameter correct... maybe.
![Barry Kelly Barry Kelly](https://community.graphisoft.com/legacyfs/online/avatars/actalk/a27517d178c246abb0dd17b6f4f6758a_153.jpg)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2021-01-13 03:10 AM
Kristian wrote:This is partly just a fishing exercise to see if anyone has any clever solutions (I'm not expecting they will).
I understand how it works in 2D.I thought so.
I even commented to my wife when I saw this post last night, that a very experienced and knowledgeable Archicad and GDL user has asked a question I would expect from a novice.
And partly to bring it to the attention of Graphisoft - I know this is not an official channel to them but they do read here.
I lost track of the number of times I had discussions with GS when they made the change in 19/20 that the Globals won't work in the parameter script any more.
I am a member of their development forum.
Start rant.
Yes I know that I can have the same instance of an object (label) displaying at different scales and that is why GLOB_SCALE can not be used as it will constantly have conflicting information as the scale is changed.
It also had something to do with teamwork if I remember correctly from the discussions, as different members can be looking at the same object with different settings/views/scale at the same time and sending the results will create conflict.
But what frustrates me is that it used to work just fine in 18 and below when it was allowed.
And I don't use teamwork.
So just let the user be aware there could be a problem and let them decide if they want to take the risk.
My rant is over.
Barry.
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
![Kristian Bursell Kristian Bursell](https://community.graphisoft.com/legacyfs/online/avatars/actalk/a27517d178c246abb0dd17b6f4f6758a_76711.jpg)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2021-01-13 03:15 AM
Maybe they could make them conditional, or we GDL coders could add in conditions so they don't cause issues in teamwork projects.
![Peter Baksa Peter Baksa](https://community.graphisoft.com/legacyfs/online/avatars/actalk/a27517d178c246abb0dd17b6f4f6758a_107013.png)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2021-01-19 02:39 PM
based on your specification specification:
I think if you don't change the scale, you can work with an absolute width. Set the parameter default to 0, and draw an editable hotspot at the calculated text width if the parameter is zero, at the parameter otherwise. As long as the user doesn't touch the hotspot, the width will be automatic, and fixed-width after.
- My labels will only ever be placed at one scale, I have separate annotation layers for each scale so the text can appear in different locations or even say completely different things.
[list=]I need to label my objects at different scales - which it where the problem arises. The text box width needs to change automatically based on the scale of the object.
Software Engineer, Library
Graphisoft SE, Budapest
![Barry Kelly Barry Kelly](https://community.graphisoft.com/legacyfs/online/avatars/actalk/a27517d178c246abb0dd17b6f4f6758a_153.jpg)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2021-01-25 02:08 AM
Just set it to suit the scale the label is being used in.
Barry.
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