Archicad Python API
About automating tasks in Archicad using the Python API.
SOLVED!

Accessing and modifying strings using the Python interface?

Eve
Participant

Hi

 

We had a look at the Python interface https://pypi.org/project/Archicad/ (25.3000) using AC25 3002. At first glance, "Texts" and "Labels" of the "Documenting Tool" do not seem to be exposed in the API.

 

We are trialing Archicad to see if we could automate the localization of the drawings prepared in Archicad, in this case from Finnish to English.  If we could export strings to Excel, translate the strings, and import back to Archicad, that would enable us to do own job, and become customers of Archicad.

 

Having the translator to go and look for translatable string inside the drawings is no go, due to the high probability of missing some strings.  And if the source drawings are modified, then tracking the modifications and updating once translated drawings becomes way too tedious.

 

If Python does not expose such string API, could you please tell if it is on the roadmap?  If not, should we have a look at the C++ interface?

 

Best regards,

Eve

1 ACCEPTED SOLUTION

Accepted Solutions
Solution
poco2013
Mentor

The short answer is NO to Python & Yes to a C++ AddOn. However, this a complicated question and there are several ways to approach this depending on your plan configuration and the types of labels used, what they are displaying and where they get their information.

 

Python can not access label info since they are actually a hybrid element in Archicad i.e. a label with a library object sub-type. There are 20 different label types in Archicad and access would depend on which one is used. The actual text info for labels is contained in another associated structure of "Element_Memo", which is not accessible at all by Python (at this time).

 

However, if you are gathering your label text through custom properties, all that info is accessible in Python and to Excel. A easy script to develop. I doubt that this is the case.

 

A Python script,however, can gather info from a AddOn via the ExecuteCommand function. This may be your best approach to develop a C++ AddOm to gather the label info and transfer it to the Python script for processing,  as Python has a direct interface to Excel and the Web translators. Than transfer the info back to the C++ AddOn for processing.  All this is very dependent on the complexity of your labels --- so nothing is definite.

 

As to the future development of Python,i doubt that much will be done in the near future. But Graphisoft will have to speak to that.

Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27

View solution in original post

2 REPLIES 2
Solution
poco2013
Mentor

The short answer is NO to Python & Yes to a C++ AddOn. However, this a complicated question and there are several ways to approach this depending on your plan configuration and the types of labels used, what they are displaying and where they get their information.

 

Python can not access label info since they are actually a hybrid element in Archicad i.e. a label with a library object sub-type. There are 20 different label types in Archicad and access would depend on which one is used. The actual text info for labels is contained in another associated structure of "Element_Memo", which is not accessible at all by Python (at this time).

 

However, if you are gathering your label text through custom properties, all that info is accessible in Python and to Excel. A easy script to develop. I doubt that this is the case.

 

A Python script,however, can gather info from a AddOn via the ExecuteCommand function. This may be your best approach to develop a C++ AddOm to gather the label info and transfer it to the Python script for processing,  as Python has a direct interface to Excel and the Web translators. Than transfer the info back to the C++ AddOn for processing.  All this is very dependent on the complexity of your labels --- so nothing is definite.

 

As to the future development of Python,i doubt that much will be done in the near future. But Graphisoft will have to speak to that.

Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27
Eve
Participant

Thank you Gerry (@poco2013) for the prompt answer.  That is what I feared.

 

Since I am a sole trader in the translation business, the required cost and effort has to be carefully considered to develop C++ interfaces to Archicad.  So far, the demand for translating drawings prepared in Archicad is rather low.

 

Note that I am not looking for Web translation, but tooling to aid in high-quality human translation.

 

Would be nice to hear from Graphisoft on their plans how the Python interface will develop in the near future.

 

Best regards

Eve