Archicad C++ API
About Archicad add-on development using the C++ API.

Guid of Favorite, and set default classification

dushyant
Enthusiast
Hello,

I got the default element guid like this:

GS::Array<GS::Pair<API_Guid, API_Guid>> systemItemPairs;
ACAPI_Element_GetClassificationItemsDefault(typeID, variationID, systemItemPairs);
for (auto i = systemItemPairs.Begin(); i != systemItemPairs.End(); ++i) {
system.guid = i->first;
item.guid = i->second;
ACAPI_WriteReport("\nsystem guid: %d\n item guid: %d\n", false, system.guid, item.guid);
}

Not able to get the guid of a favorite. Trying like this:

GS::UniString favName;
favName = "myFav";
API_Favorite favorite (favName);
API_Element& favElement = favorite.element;
ACAPI_WriteReport("favElement.header.guid: %d", false, favElement.header.guid);

The above code outputs the guid as 0.

Tried to get the systemItemPair of the favorite like this:

ACAPI_Element_GetClassificationItems(favElement.header.guid, favorite.classifications.Get());

and fed it into the for-loop like for default, it gave out a huge list of pairs instead of just one for the favorite in question.

I am able to clear the default Classification:
ACAPI_Element_RemoveClassificationItemDefault(typeID, variationID, item.guid);

But the default Classification is not getting set by:
ACAPI_Element_AddClassificationItemDefault(typeID, variationID, favElement.header.guid);

Possibly because this guid is 0.

What am I doing wrong?

Please help!

Thanks,
Dushyant
2 REPLIES 2
akomporday
Graphisoft
Graphisoft
Hey,
You can get a Favorite by:

API_Favorite favorite;
favorite.name = "myFav";
ACAPI_Favorite_Get (&favorite);
You can read more about favorites here:
http://archicadapi.graphisoft.com/documentation/api_favorite

Does it help your other problem?
dushyant
Enthusiast
Hi, thanks for your reply.
It had got fixed by adding the following:
favorite.classifications.New();

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!