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.

Wall Tool from favorite

dushyant
Enthusiast
Hello,
Is there a way to activate the wall tool for drawing the wall, with a particular favorite wall’s settings? I can place a favorite wall with begC and endC. But I need the wall tool to get activated with the favorite’s settings applied & ready to draw.

Basically from the menu: Design > Design Tools > Wall , should get activated and instead of Default Settings, it should be ready with the settings of a particular favorite wall.

Thanks,
Dushyant
25 REPLIES 25
Ralph Wessel
Mentor
dushyant wrote:
Any idea why the Classification is not getting set to that of the Favorite? (It's not changing at all)
Classifications and Properties have to be set separately. Use ACAPI_Element_RemoveClassificationItemDefault, ACAPI_Element_AddClassificationItemDefault and ACAPI_Element_SetPropertiesOfDefaultElem as required.
Ralph Wessel BArch
Software Engineer Speckle Systems
dushyant
Enthusiast
Hi Ralph,
Thanks. I am trying to first get the existing classification of the element default:
API_Element& favElement = favorite.element;
    API_ElementMemo& favMemo = favorite.memo.Get();
    
    API_ElemTypeID typeID = tboxInfo.typeID;
    API_ElemVariationID variationID = APIVarId_LabelWall2;
    GS::Array<GS::Pair<API_Guid, API_Guid>>  systemItemPairs;
    
    ACAPI_Element_GetClassificationItemsDefault(typeID, variationID, systemItemPairs);
I am not able to figure out how to print/output the contents of systemItemPairs

Dushyant
Ralph Wessel
Mentor
You could do something like:
	for (auto i = systemItemPairs.Begin(); i != systemItemPairs.End(); ++i) {
		//guid of system is i->first
		//guid of item is i->second
	}
Ralph Wessel BArch
Software Engineer Speckle Systems
dushyant
Enthusiast
Thanks Ralph.
Is there a way to translate these guids into names?
Ralph Wessel
Mentor
dushyant wrote:
Is there a way to translate these guids into names?
Use ACAPI_Classification_GetClassificationSystem and ACAPI_Classification_GetClassificationItem.
Ralph Wessel BArch
Software Engineer Speckle Systems
dushyant
Enthusiast
Thanks Ralph. Got it!
dushyant
Enthusiast
Got the default item id from:
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 like this:
API_Favorite    favorite (favName);
API_Element& favElement = favorite.element;
ACAPI_WriteReport("favElement.header.guid: %d", false, favElement.header.guid);
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);
Please help!

Thanks.
Ralph Wessel
Mentor
dushyant wrote:
Not able to get the guid of a favorite like this:
API_Favorite    favorite (favName);
That's the default constructor for API_Favorite - so all that code does is construct a new instance with the name you specified. The other data will all be empty.

I think you want to call a function to look up a favorite by name, e.g. ACAPI_Favorite_Get.
Ralph Wessel BArch
Software Engineer Speckle Systems
dushyant
Enthusiast
Yes, I did use ACAPI_Favorite_Get() after that. So,

favName = "myFav"; // name of an existing favorite
API_Favorite favorite (favName);

ACAPI_Favorite_Get (&favorite); // returns NoError

API_Element& favElement = favorite.element;

ACAPI_Element_GetClassificationItems(favElement.header.guid, favorite.classifications.Get()); // this is not working

Dushyant
Ralph Wessel
Mentor
dushyant wrote:
ACAPI_Element_GetClassificationItems(favElement.header.guid, favorite.classifications.Get()); // this is not working
The function ACAPI_Element_GetClassificationItems retrieves the classifications of an element in the model. The element data in a favorite is a template for an element (not a placed element in the model) so the guid will be null.

What are you trying to do with that call? Don't you already have the Favorite classifications after calling ACAPI_Favorite_Get?
Ralph Wessel BArch
Software Engineer Speckle Systems