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.

Getting Error with CHCopyC

Dayiz
Booster

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:

CHcopyC error.png

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

3 REPLIES 3
kovacsv
Booster

The documentation is outdated, use ucscpy instead of CHCopyC.

 

GS::ucscpy (dbInfo.name, L("My Cool Database Name"));

 

 

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?

 

kovacsv
Booster

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.