Due to a scheduled maintenance, a maximum 20 minutes license delivery outage may be expected on July 6 2024 (Saturday) between 6PM to 8PM (CEST).
Archicad C++ API
About Archicad add-on development using the C++ API.

Create a new text type label

yahavsa
Contributor

Hello
I am trying to create a new Text type label. I want it to be of Text type regardless of whether the default label is of Text or Symbol type. When I use the ACAPI_Element_GetDefaults function to get the default data of the default label, I didn't find a way to modify the default to be Text type label when the default label is of Symbol. If there is another way to create a Text type label whether the default label is of Text or Symbol type I would love to hear about.
I would appreciate any help, thanks

3 REPLIES 3

Hi Yahavsa!

It's a bit tedious to get all the details right when converting a symbol to a text label (or the other way).
I've done the other way around for one of my Add-Ons, but unfortunately I don't have a working example for the direction you need.
Still I think I can give you some starting points of what to look at.

1. You have to change the following members of the retrieved default element:

 

 

labelElem.label.labelClass;
labelElem.label.u.head.typeID = API_TextID;
labelElem.label.u.text // Set the members of this! Might help to initialize it first to zero with `= API_TextType{};` 

 

 


2. You also have to allocate and fill the following memo members (Take a look at the API_LabelID entry for ACAPI_Element_GetMemo)

 

 

(char **) textContent
(short **) textLineStarts
(API_ParagraphType **) paragraphs

 

 

You find some hints for how to allocate these in the example Element_Test. Especially in the file Element_Basics.cpp.

I think textLineStarts is not necessary for very simple texts.

Hope that gets you started!

Bernd Schwarzenbacher - Archicad Add-On Developer - Get Add-Ons & Archicad Tips on my Website: Archi-XT.com

Hello
I appreciate your quick and detailed reply!
I'll definitely try out the solution you suggested, I'm just wondering if there isn't a simpler way to access the text/autotext label shown in the label object's settings...
Thanks again!


text-autotext label.png

I don't think there's a general easy way to set it up.

If your situation allows it though, you could setup a favorite for the text label and get the basic setup then from that with ACAPI_Favorite_Get.
You might also find ACAPI_Favorite_Import and ACAPI_Favorite_Export helpful. Then you could store the favorite as a file and distribute it alongside your Add-On.

Bernd Schwarzenbacher - Archicad Add-On Developer - Get Add-Ons & Archicad Tips on my Website: Archi-XT.com