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.

API_Favorite_Get() fails

dushyant
Enthusiast
Hello,

I am trying to load a favourite by API_Favorite_Get() using an API_Favorite made with favorite’s name as string. It fails. Whereas if I pass the name out of the array names[0], it works. Why is this happening? Code snippet pasted below.

Thanks, Dushyant.

   GSErrCode                    err = NoError;
   GS::UniString                favName;
   short                        count = 0;
   GS::Array<GS::UniString>     names;

   err = ACAPI_Favorite_GetNum (API_ColumnID,
                                APIVarId_Generic,
                                &count,
                                nullptr,
                                &names);

   favName = "Column - Rectangular”;
   //favName = names[0]; // this actually is ‘Column - Rectangular'

   API_Favorite    favorite (favName);
   ACAPI_WriteReport("API_Favorite - name: %s", false, favorite.name.ToCStr().Get());
   favorite.memo.New ();

   err = ACAPI_Favorite_Get (&favorite);
   if (err != NoError) {
       ACAPI_WriteReport ("ACAPI_Favorite_Get failed (Name: %s)", false, favName.ToCStr().Get());
       ACAPI_WriteReport ("err: %d", false, err);
       ACAPI_DisposeElemMemoHdls (&favorite.memo.Get ());
       return;
   }
1 REPLY 1
dushyant
Enthusiast
The error was:
Name of the column had a space at the end, so it should be: "Column - Rectangular ", for reference of others.