BIM Coordinator Program (INT) April 22, 2024

Find the next step in your career as a Graphisoft Certified BIM Coordinator!

GDL
About building parametric objects with GDL.

Scale dependent label

Anonymous
Not applicable
I'm trying to create a label object that will display different text depending on the scale of the plan. So for example when I attach a label to a cooktop object at 1:100 scale, the label displays "ct" while at 1:20 it displays "COOKTOP".

So far, I've managed to get the label to display "ct" by setting the Object ID as "ct". For that part I have the following 2D script:
IF TXT = "Object ID" THEN
TXT = GLOB_ID
ENDIF

followed by the text block stuff.

Then comes the clumsy bit. To set text to display at 1:20 scale, I have to manually type in "COOKTOP" into a parameter I've created in the "symbol label custom setting". Not terribly efficient - might as well just use a piece of text on a different layer for each drawing.

What I'd like to do is have the two different pieces of text for labels that I can set using properties within the object and then get the label to display the text based on the scale of the drawing. So for example use "object id" for one (as above) and another property for the other label. Or create two custom properties "little text" & "big text" and then get my label to display one or the other based on the scale of the drawing.

The problem is, I don't know how to get the label object to call up those properties and display them like I have done for GLOB_ID.

I realise that this is possible within some objects that have a label setting, but not all objects have that so I think it would be better to have a label that does that. I've also played around with the "Classification and Properties" label in AC24, which is close, but doesn't respond to scale.

Any ideas welcome. I feel like I may be reinventing the wheel here and that this should be fairly simple, but for the life of me cannot work it out!
15 REPLIES 15
Podolsky
Ace
To call properties you need to use :
n = REQUEST ("Property_Value_Of_Parent", "id", type, dim1, dim2, propertyValues)
Please see the GDL user manual for details.

In your case, I would recommend using more automatic features in the GDL script - make it more "smart". For example, a label can detect the type of object by its name and choose the right code for it. To receive the name of the object use:
n = REQUEST ("ASSOCLP_NAME", "", objectName)

After you can match library part names and needed code:
IF objectName = "Cooktop Built In 23" THEN 
    objectCode = "CT"
    objectFullName = "COOKTOP"
ENDIF
For better results you can use String functions to cut off 23 at the end - then your label will be version independent. Plus of it - you don't need to set additional parameters manually. Also you keep ID - for real ID, if you will need in the future to use unique ID for scheduling.
Barry Kelly
Moderator
If you are scripting your own label object, then I would try something like this.
Off the top of my head ...

Something like...

Create your properties for "big_text" & "little_text" and make sure they associate with your object.
Then in the label ...

if GLOB_SCALE <= 20 then
rrr=REQUEST ("Property_Value_Of_Parent", "big_text", type, dim1, dim2, propertyValues)
else
rrr=REQUEST ("Property_Value_Of_Parent", "little_text", type, dim1, dim2, propertyValues)
endif
You now use the 'propertyValues' variable in your text command.
This must be done in the 2D script, otherwise the label will not recognise the scale.


Or you could add parameters to your cook top object if you are happy to modify it.
Similar to above but ...

Create 2 parameters in your object - "little_text" & "big_text".
You can hard code the values of these parameters in your object, or you can allow the user to change them.

Now in your label you request either of these based on the scale.

Something like...

if GLOB_SCALE <= 20 then
rrr=REQUEST ("ASSOCLP_PARVALUE", "big_text", name_or_index, type, flags, dim1, dim2, p_values)
else
rrr=REQUEST ("ASSOCLP_PARVALUE", "little_text", name_or_index, type, flags, dim1, dim2, p_values)
endif

You now use the p_values variable in your text command.


I think either of those should work.

Barry.
One of the forum moderators.
Versions 6.5 to 27
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Anonymous
Not applicable
Barry your suggestions make sense to me...sort of.

I've created new properties in Archicad for "Big Scale Label" and "Small Scale Label" that are available for the object to use. Then I copy and pasted your first script into the Properties script section of my label object. Then in the 2D script, I wrote:
 TXT = propertyValues

	define style{2}    "AC_STYLE_1" LABEL_FONT_NAME, LABEL_TEXT_SIZE, LABEL_FONT_STYLE2	
	paragraph		"AC_PRG_2"      2, 0, 0, 0, 0.8
		pen          TxtPen
		set style "AC_STYLE_1"
			"" + TXT
	endparagraph

	textblock		"AC_TEXTBLOCK_2" 0, 5, tr, 1, 1, 1, 
			"AC_PRG_2"
	richtext2		0, 0, "AC_TEXTBLOCK_2"
I get an error message in the "" + TXT line for "incompatible types in expression". I'm sure that I'm missing a step somewhere. Have tried the GDL guide but frankly that is like trying to understand a foreign language! Its hard to know what you're looking for when you don't know what you're looking for!

I have never used properties or requests before, so apologies if my mistake is obvious to you!
Barry Kelly
Moderator
I think that is because your propertyValues is a number and you are trying to use it as a string (text) in your paragraph.
Try converting the TXT number to a string.
Use this in the paragraph ...

"" + STR(TXT, 1, 0)

Barry.
One of the forum moderators.
Versions 6.5 to 27
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Podolsky
Ace
Guys, you went somewhere in wrong direction. Why property value is a number, when it suppose to be a string, because it shall say CT or COOKTOP?

Make it simpler. I think to use additional properties for such a small task - is too much. Then every time, when you will need it - you need to check - are these properties correct etc.

Do it better with recognition of object name and set text, without any properties requests. Simple and most important - it will work in any cases.
Barry Kelly
Moderator
Podolsky wrote:
Guys, you went somewhere in wrong direction. Why property value is a number, when it suppose to be a string, because it shall say CT or COOKTOP?

Yes, sorry, I was thinking the propertyValues was for the scale (which it isn't) - it should already be a text value.
Make sure it is set as a 'String' data type in the properties.

Barry.
One of the forum moderators.
Versions 6.5 to 27
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Anonymous
Not applicable
Podolsky wrote:
Guys, you went somewhere in wrong direction. Why property value is a number, when it suppose to be a string, because it shall say CT or COOKTOP?

Make it simpler. I think to use additional properties for such a small task - is too much. Then every time, when you will need it - you need to check - are these properties correct etc.

Do it better with recognition of object name and set text, without any properties requests. Simple and most important - it will work in any cases.
The problem I see with that method is I would have to enter the name of every object I want to use the label for into the label code wouldn't I? I want to be able to use the label for kitchen appliances, bathroom fittings etc. I think it would be better set a global property that can be set in any object then save the objects used most often as favourites with the label text already pre-set.
Podolsky
Ace
It's much easier to enter the names of library parts and label text once in one place (i.e. in the script) then mess around with properties again and again.
Well, both methods work, but the second one will work lighting fast - as soon as you complete GDL script - you don't need to do nothing - just click on the object.
With properties you need to be sure again and again, that this property attached in each new project with each new element. Finally speed of project delivery is important.
Barry Kelly
Moderator
If you use properties, then you have to ensure they have the correct value for every object you place.
This is basically the same as typing your own text.

Maybe you can create expressions in the properties so ...
if cooktop object then little text = CT.
if dishwasher, then little text = DW.
if refridgerator, little text = FR.
etc.

But that would be very cumbersome and easy to mess up.

You could set up favourites to fill in the correct info for you, but then you have to ensure you use the favourites every time you place an object and that you have a favourite for every object.


The best way (I think) is to edit the library parts and add the parameters you want for big & little text.
You can leave them blank and let the user type what they want - no advantage in this.
Or you can set default values for each object (with the option for custom text if the user wants to alter it for some reason).
Then the label can read those parameters and it is all very automatic.

The problem with this though, is you are then editing the library objects.
If you are using the Graphisoft libraries, you will not be able to update in future, without editing the objects again.
Not a problem though if you have your own custom objects, as you are in control of those objects.

I have my own custom library of object and I add my own parameters if I need them, so maybe that is why I think this method is best.


Barry.
One of the forum moderators.
Versions 6.5 to 27
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Learn and get certified!