We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

Archicad C++ API
About Archicad add-on development using the C++ API.

Changing value of label via API

Eshanta
Contributor

I am currently trying to create a zone label in which the values are updated programmatically via the API.

 

I've tried the following so far without any success:

 

1) Tried setting the parameter value of the label's display text using the API. While this worked for other GDL object types, it did not work for labels.

 

2)Tried ACAPI_Element_GetPropertyDefinitions to get the property definitions first, so that I can somehow set the value later. However, I get null value in property definitions for labels. It works fine for other objects like walls.

Is it possible to update text in labels programmatically  ?

 

Thanks.

11 REPLIES 11
Barry Kelly
Moderator

I don't have a solution for you.

But just for clarity.

Are you trying to update text settings such as font, colour, size, justification, etc.?

Or are you trying to adjust the values of what the text is actually displaying?

Apart from choosing what property or parameter you want to display, labels get the actual values from the associated element.

 

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
kuvbur
Enthusiast

Create label that read property of zone (or use standart) and change zone property via API.

Structural engineer, developer of free addon for sync GDL param and properties

Labels in the C++ API can more complicated. Zones, as of 25, can use either the "zone stamp" which is a label that uses a library object or a standard associated label. Do you just want to change text or a AutoText property. If a property, you must have the property key. Do want to change an exiting label or create and attach one, if so, how do you want to select and attach?? Sounds like, the better choice would be to just use the AutoText feature in 25?.

To set or modify existing labels, you may want to check out using the Python AddOn described below your post.

Else, check out the example functions in the Element_test example in the C++ Development Kit. An example of a associated label is given there.

Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27

Hi Barry

 

Thank you very much for your response.

 

I am actually trying to do the latter.

I tried creating a label GDL that is supposed to get the properties from the associated element. However, it did not work for zones. The same script works without any problem for slabs.

Since, getting properties directly from the zone did not work, I am trying to create an empty label and then get the properties and display it in the label via the API. However, this does not seem to work for zones as well.

 

Eshanta

Hi kuvbur, poco2013,

 

Thank you for your reply.

 

I have a label GDL with blank fields. I tried getting it's properties from the associated zone using GDL script. However, I was not able to get the property values for cases when the element type is zone.

 

Hence, I thought an alternative might be to create a blank label GDL, define parameters inside it and then change the values of those parameters via API. If it is not a GDL of type Label, I can change it's parameters via the API without any problem. But for labels, although it does not return any errors, the parameter is not updated in the Label GDL. 

 

In any case I will check out the ELement_test example from the API development kit.

 

Eshanta

 

You may not be interested,  but I made a short video which demos the ease of doing what you described in Python. All we need is some increased cooperation from Graphisoft to make several issues like this viable.

I would be interested in any comments?

 

AutoText Zone Label with Multiple Variables 

Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27

Hi Gerry,

 

Thank you very much for the demo.

 

The solution seems interesting.  I have to use the API in C++ and the Archicad version needs to be 24.

 

However, the potential with python does look promising.

 

Eshanta

Eshanta
Contributor

Just in case it might be useful to someone, I achieved this by getting the element memo using ACAPI_Element_GetMemo and then I extracted the value of the parameters from the element memo.

 

I changed the parameter values in the program and then used ACAPI_Element_Change to write back the changed parameters to the element.

By doing this, I was able to change the parameter values of the label.

Heelo, did you manage to retrieve all of the zone stamp parameters with ACAPI_Element_GetMemo? I'm trying something similar on AC25, but it is only returning the first one for whatever reason.