2023-01-30 03:10 PM - last edited on 2023-01-31 07:01 PM by Laszlo Nagy
Hello everyone,
I'm trying to edit the names of layouts and I encountered some strange behaviour.
I copied the code from https://archicadapi.graphisoft.com/documentation/apidb_modifydatabaseid and I get the following error:
It is the exact same code (initiliazing and zeroing lines are not in the screenshot).
I wanted to use CHcopyC to change the values of dbInfo.ref and dbInfo.name, but it doesnt work.
So I tried a work around:
std::string nm{ "Nachname" };
GS::UniString orgnm{ dbi.name };
for (GS::USize i = 0; i < orgnm.GetLength(); i++)
{
dbi.name[i] = NULL;
}
for (int i = 0; i < nm.length(); i++)
{
dbi.name[i] = nm[i];
}
Which works for name, but if I do the same with ref:
std::string vm{ "Vorname" };
GS::UniString orgvm{ dbi.ref };
for (GS::USize i = 0; i < orgvm.GetLength(); i++)
{
dbi.ref[i] = NULL;
}
for (int i = 0; i < vm.length(); i++)
{
dbi.ref[i] = vm[i];
}
it doesn't work (to be precise: i can use DG::InformationAlert to get dbi.ref after I edit it, which gives me the value i put it ("Vorname"), but when I use ACAPI_Database(APIDb_ModifyDatabaseID, &dbi, nullptr); it keeps its old name in ArchiCAD).
So
1) How do I get CHopyC running?
2) What am I doing wrong when editing ref?From https://archicadapi.graphisoft.com/documentation/api_windowinfo I should be able to edit ref.
Thanks and Kind Regards
Dayiz
2023-01-30 09:03 PM - edited 2023-01-30 09:09 PM
The documentation is outdated, use ucscpy instead of CHCopyC.
GS::ucscpy (dbInfo.name, L("My Cool Database Name"));
2023-01-31 11:36 AM
Thank you again for your help!
I tried it out and it works for dbInfo.name, but not for dbInfo.ref
And since the doc is outdatet, how am I supposed to find out that CHcopyC is depracted and that I should use GS::ucscpy instead?
2023-02-01 12:26 PM
It's the same data type, so it's probably not about the string copy function, but something else. About the outdated documentation: I usually find samples in the Example Add-Ons provided in the DevKit, they are always compiling.