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.

[SOLVED] How to get current project physical file name by C++

Anonymous
Not applicable
Hi

My goal is to save some information for each physical project.
Is there a way to get current project file name using C++ ?

Thanks in advance.
8 REPLIES 8
Ralph Wessel
Mentor
ggiloyan wrote:
My goal is to save some information for each physical project.
Is there a way to get current project file name using C++ ?
Take a look at APIEnv_GetProjectNotesID. The returned data includes the project name.
Ralph Wessel BArch
Software Engineer Speckle Systems
Anonymous
Not applicable
APIEnv_ProjectID for the file name
Anonymous
Not applicable
Ralph wrote:
ggiloyan wrote:
My goal is to save some information for each physical project.
Is there a way to get current project file name using C++ ?
Take a look at APIEnv_GetProjectNotesID. The returned data includes the project name.
Thank you for the help!
ReignBough
Enthusiast
If you want the file name, you can use APIEnv_ProjectID. It will return the file name of the project at either location or location_team. They are full path, though.
~ReignBough~
ARCHICAD 26 INT (from AC18)
Windows 11 Pro, AMD Ryzen 7, 3.20GHz, 32.0GB RAM, 64-bit OS
Anonymous
Not applicable
I have an Issue connected to this topic.

I am able to get a project name from Teamwork using the mentioned function:

projectInfo.location_team->GetLastLocalName (&projectName);
However the returned string is UTF-8 Coded from UniString, and the result is that special characters (German Umlaut f.e.) are returned like so:
  • " " as "%20"
    "ä" as "%C3%A4"
    "ö" as "%C3%AB"
    "ü" as "%C3%A6"
What is the recommended way to decode this so I get a readable C String?
Ralph Wessel
Mentor
mar_kq wrote:
…the returned string is UTF-8 Coded from UniString. What is the recommended way to decode this?
What do you want to decode it into?
Ralph Wessel BArch
Software Engineer Speckle Systems
Anonymous
Not applicable
Ralph wrote:
mar_kq wrote:
…the returned string is UTF-8 Coded from UniString. What is the recommended way to decode this?
What do you want to decode it into?
Hello Ralph,

I corrected my previous message. What I need is to get a C String with the special characters: ü,... etc. What I get for the moment is %C3%A6 instead.
Is there an API function to do this or do I require other libraries?
Ralph Wessel
Mentor
mar_kq wrote:
What I need is to get a C String with the special characters: ü,... etc. What I get for the moment is %C3%A6 instead.
Is there an API function to do this or do I require other libraries?
C doesn't define an encoding as such. The old C string libraries only typically assume an 8-bit encoding terminated by a null byte.

Text encoding is actually quite a complex subject. I suspect you're looking for an encoding with a maximum of 8 bits per character, e.g. ASCII. The problem with that approach is that you can have no more than 255 unique characters. Consequently, developers have moved to encodings that can cope with all known characters (and leave space for more), primarily Unicode. The most popular are UTF-16 (which uses a fixed 16 bits per character) and UTF-8. UTF-8 is the most popular for the Web and uses variable length characters, i.e. they might be only 1 byte but could be up to 4 (or 6 from older standards). Parsing UTF-8 is consequently more complex and random access into the nth character is much slower, but it has the distinct advantage of not breaking systems designed for 8-bit characters because it reserves the null byte for marking the end of a string.

Unless you are dealing with a legacy system that must have an ASCII encoding, I'd strongly recommend embracing the encoding provided by ARCHICAD. Take a look at the API documentation for text encoding and string handling, and do a bit of reading on Unicode etc. – it's well worth the effort.
Ralph Wessel BArch
Software Engineer Speckle Systems