ACAPI_​Element_​GetNoteKeywordForAutotextID

Returns the unistring keyword for note autotext id.

    GSErrCode  ACAPI_Element_GetNoteKeywordForAutotextID (
        API_NoteAutotextID     autotextID,
        GS::UniString&     keyword
    );

 

Parameters

autotextID
[in] The note autotext identifier.
keyword
[out] The result keyword for the note autotext.

 

Return Values

NoError
This function always return NoError.

For other common API errors see the API Errors document.

 

Remarks

This function is used to get the keyword for the note autotext.

 

Example


void	Do_LevelDimension_Edit ()
{
    API_Element element = {}, mask;

    if (!ClickAnElem ("Click a dimension to modify", API_LevelDimensionID, nullptr, &element.header.type, &element.header.guid)) {
        WriteReport_Alert ("No level dimension was clicked");
        return;
    }

    GSErrCode err = ACAPI_Element_Get (&element);
    if (err != NoError) {
        return;
    }

    ACAPI_ELEMENT_MASK_CLEAR (mask);
    ACAPI_ELEMENT_MASK_SET (mask, API_LevelDimensionType, note1.contentType);
    ACAPI_ELEMENT_MASK_SET (mask, API_LevelDimensionType, note1.contentUStr);

    element.levelDimension.note1.contentType = API_NoteContent_Custom;

    auto buildContentWithAllAvailableAutotexts = [&element] () -> GS::UniString {
        std::unordered_map<API_NoteAutotextID, std::unordered_set<API_ElemType>> autotextMap;
		const GSErrCode err = ACAPI_Element_GetNoteAutotexts (API_LevelDimensionID, autotextMap);
		if (err != NoError) {
			return "Custom";
		}

		GS::UniString content;
		for (auto& pairItem : autotextMap) {
			const API_NoteAutotextID autotextID = pairItem.first;
			const std::unordered_set<API_ElemType>& currentSet = pairItem.second;

			const bool isGeneralOrParentElemTypeSpecificAutotext =
				currentSet.empty () ||
				currentSet.find (element.levelDimension.parentType) != currentSet.end ();
			if (!isGeneralOrParentElemTypeSpecificAutotext) {
				continue;
			}
			GS::UniString keyword;
			ACAPI_Element_GetNoteKeywordForAutotextID (autotextID, keyword);

			if (!content.IsEmpty ()) {
				const GS::UniString separator = " ";
				content += separator;
			}
			content += keyword;
		}
		return content;
	};

	GS::UniString content = buildContentWithAllAvailableAutotexts ();
	element.levelDimension.note1.contentUStr = &content;

	err = ACAPI_Element_Change (&element, &mask, nullptr, 0, true);
}		// Do_LevelDimension_Edit

 

Requirements

Version: API 26 or later
Header: ACAPinc.h

See Also

API_NoteAutotextID, ACAPI_Element_GetNoteAutotexts, API_NoteType
API Functions