GDL
About building parametric objects with GDL.

Labeling a Hard-coded Property

I would like to have a simple label which calls out a specific hard-coded property. Not a general properties label. For example, we have a property under General called Remarks. Seems like this should be the code, but it does not work:
DIM _propertyValues[][]
rrr = REQUEST("Property_Value_Of_Parent", "Remarks", type, dim1, dim2, _propertyValues)
_str = 'blank' ! default
IF rrr > 0 THEN
	_str = _propertyValues[1][1]
ENDIF

TEXT2 0, 0, _str
This gives the default text, showing the request did not work.

What I am I missing?
James Murray

Archicad 25 • Rill Architects • macOS • OnLand.info
10 REPLIES 10
Barry Kelly
Moderator
I haven't tested this, but you are simply retrieving the value of a property.
So there should be no need to declare a multidimensional array for it - it has one value and that is all you need.

Maybe try this.
rrr = REQUEST("Property_Value_Of_Parent", "Remarks", type, dim1, dim2, _propertyValues)
_str = 'blank' ! default
IF rrr > 0 THEN
	_str = _propertyValues
ENDIF

TEXT2 0, 0, _str

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
runxel
Legend
First of all:
Why no autotext label? With a favorite this just works fine.

The longer story:
The "ID" in the request is NOT the name of the property! But instead the GUID.

Two ways:
You need to program the label so that you can choose in the UI which of the properties should be requested.
There is a special new UI command for that.

Or:
You use the text tool, write the property as autotext into it, save that as an object and open it.
Inside you will find a PARAGRPAH with a string written that looks like this:
"<PROPERTY-9E10C048-4861-5A48-B07A-B2E9BE4DBC9C>"
That is the autotext string.
But we need the GUID to have it requested. For this you only keep the part with the random alphanumerics and put it inside curly braces, like this:
"{9E10C048-4861-5A48-B07A-B2E9BE4DBC9C}"

This is the ID you need for the request.
Happy coding!
Lucas Becker | AC 27 on Mac | Author of Runxel's Archicad Wiki | Editor at SelfGDL | Developer of the GDL plugin for Sublime Text |
«Furthermore, I consider that Carth... yearly releases must be destroyed»
Podolsky
Ace
DIM parentProperties[]
r=REQUEST (‘Properties_Of_Parent’, ‘’, parentProperties)

IF r THEN
propertyID=‘’
FOR i = 4 TO VARDIM1(parentProperties) STEP 4
IF parentProperties = yourPropertyName THEN propertyID = parentProperties[i-3]
NEXT i
propertyValues=‘’
r=REQUEST (‘Property_Value_Of_Parent’, propertyID, type, dim1, dim2, propertyValues)
ENDIF
Podolsky
Ace
Happy copy-pasting
Thank you, I thought it might be an GUID-decryption thing.

Symbol labels need properties too
James Murray

Archicad 25 • Rill Architects • macOS • OnLand.info
runxel
Legend
James wrote:
Thank you, I thought it might be an GUID-decryption thing.

Symbol labels need properties too
You're welcome, James!
True, as soon there are dynamic symbols involved you have to resort to GDL.

It's a bit sad we have to use this workaround to get to the GUID. I am not aware of a simpler method.
The XML export of a property does not hold its GUID. It seems that this will be created at import time.
So in other news: Be aware when you go to a new file which is not based on your template. The GUID will not be the same, so the GDL label with its hardcoded GUID will stop working.
So in the end it might be easier for maintenance to have a selection with UI_CUSTOM_POPUP_INFIELD somewhere in the label.
Lucas Becker | AC 27 on Mac | Author of Runxel's Archicad Wiki | Editor at SelfGDL | Developer of the GDL plugin for Sublime Text |
«Furthermore, I consider that Carth... yearly releases must be destroyed»
Podolsky
Ace
runxel wrote:
James wrote:
Thank you, I thought it might be an GUID-decryption thing.

Symbol labels need properties too
You're welcome, James!
True, as soon there are dynamic symbols involved you have to resort to GDL.

It's a bit sad we have to use this workaround to get to the GUID. I am not aware of a simpler method.
The XML export of a property does not hold its GUID. It seems that this will be created at import time.
So in other news: Be aware when you go to a new file which is not based on your template. The GUID will not be the same, so the GDL label with its hardcoded GUID will stop working.
So in the end it might be easier for maintenance to have a selection with UI_CUSTOM_POPUP_INFIELD somewhere in the label.
This is not a problem. The code I published above get property value by name. Just using three steps.
runxel
Legend
Podolsky wrote:
This is not a problem. The code I published above get property value by name. Just using three steps.
Yes, you are right. This makes the GUID juggling much easier.
The code didn't run at first, but I took a second look and will put the code with the small missing piece here:

myPropToReq = "String of the Property Name"

dim parentProperties[]
r = request("Properties_Of_Parent", "", parentProperties)

if r then
	propertyID = ""
	for i = 4 to vardim1(parentProperties) step 4
		if parentProperties = myPropToReq then
			propertyID = parentProperties[i-3]
		endif
	next i
	propertyValues = ""
	r = request("Property_Value_Of_Parent", propertyID, type, dim1, dim2, propertyValues)
endif

text2 0, 0, propertyValues
Lucas Becker | AC 27 on Mac | Author of Runxel's Archicad Wiki | Editor at SelfGDL | Developer of the GDL plugin for Sublime Text |
«Furthermore, I consider that Carth... yearly releases must be destroyed»
Podolsky
Ace
runxel wrote:
Podolsky wrote:
This is not a problem. The code I published above get property value by name. Just using three steps.
Yes, you are right. This makes the GUID juggling much easier.
The code didn't run at first, but I took a second look and will put the code with the small missing piece here:

myPropToReq = "String of the Property Name"

dim parentProperties[]
r = request("Properties_Of_Parent", "", parentProperties)

if r then
	propertyID = ""
	for i = 4 to vardim1(parentProperties) step 4
		if parentProperties = myPropToReq then
			propertyID = parentProperties[i-3]
		endif
	next i
	propertyValues = ""
	r = request("Property_Value_Of_Parent", propertyID, type, dim1, dim2, propertyValues)
endif

text2 0, 0, propertyValues
Endif not needed before next i