### Print Guids in Creation Order Example Source: https://graphisoft.github.io/archicad-api-devkit/group___draw_order.html Example demonstrating how to iterate through all elements in their creation order and print their GUIDs. It initializes the creation order table, retrieves each GUID in a loop, prints it, and finally disposes of the table. ```c void PrintGuidsInCreationOrder () { if (ACAPI_DrawOrder_InitCreationOrderTable (nullptr) == NoError) { API_Guid guid = APINULLGuid; while ((ACAPI_DrawOrder_CreationOrderGetNext (&guid) == NoError) && (guid != GS::NULLGuid)) { ACAPI_WriteReport (APIGuidToString (guid), false); } ACAPI_DrawOrder_DisposeCreationOrderTable (); } return; } ``` -------------------------------- ### Start, Create, Clip, and Stop Clipping Session Source: https://graphisoft.github.io/archicad-api-devkit/group___database.html This example demonstrates the workflow for creating elements within a clipping session. It involves starting the session, creating elements, applying a clipping region, and then stopping the session. ```C++ API_Region clipRegion {}; API_Element element {}; GSErrCode err; clipRegion.box.xMin = 0.0; clipRegion.box.xMax = 2.0; clipRegion.box.yMin = 1.54; clipRegion.box.yMax = 2.54; err = ACAPI_Database_StartClippingSession (); if (err == NoError) { /* ... */ err = ACAPI_Element_Create (&element, nullptr); /* ... */ err = ACAPI_Database_DoClip (&clipRegion, nullptr); } err = ACAPI_Database_StopClippingSession (); ``` -------------------------------- ### Example: Iterate and Select Next Renovation Filter Source: https://graphisoft.github.io/archicad-api-devkit/group___renovation.html This example demonstrates how to retrieve the list of renovation filters and iterate through them. It includes logic to find a specific filter by GUID and select the next one in the list, wrapping around to the first filter if the last one is reached. ```c++ GS::Array renFilters; GSErrCode err = ACAPI_Renovation_GetRenovationFilters (&renFilters); if (err == NoError) { GS::USize nRenFilters = renFilters.GetSize (); for (GS::UIndex i = 0; i < nRenFilters; ++i) { if (oldView.renovationFilterGuid == renFilters[i]) { newView.renovationFilterGuid = renFilters[i + 1 >= nRenFilters ? 0 : i + 1]; break; } } } ``` -------------------------------- ### Initialize Add-on with Classification Visibility Handler Source: https://graphisoft.github.io/archicad-api-devkit/group___add_on_integration.html Example of an add-on's Initialize function that installs a menu handler and a classification visibility handler. Ensures the add-on remains in memory. ```c //------------------------------------------------------ // Called after the add-on has been loaded into memory //------------------------------------------------------ GSErrCode APIMenuCommandProc_Main (const API_MenuParams *menuParams); bool ClassificationVisibilityHandler (API_ClassificationVisibilityMode visibilityMode, const GS::Array& classificationGuids, const API_Guid& classificationItemGuid); GSErrCode Initialize (void) { GSErrCode err = ACAPI_MenuItem_InstallMenuHandler (32500, APIMenuCommandProc_Main); if (err != NoError) { return err; } err = ACAPI_AddOnIntegration_InstallClassificationVisibilityHandler (ClassificationVisibilityHandler); if (err != NoError) { return err; } ACAPI_KeepInMemory (true); return NoError; } ``` -------------------------------- ### Example: Get Property Definition Names Source: https://graphisoft.github.io/archicad-api-devkit/group___attribute.html Demonstrates how to retrieve the names of property definitions for a specified attribute type and index. It handles potential errors during the retrieval process. ```c++ GSErrCode GetPropertyDefinitionNames (API_AttrTypeID attributeTypeID, short attributeIndex, GS::Array& names) { API_Attr_Head attributeHeader {}; GS::Array definitions; attributeHeader.typeID = attributeTypeID; attributeHeader.index = ACAPI_CreateAttributeIndex (attributeIndex); GSErrCode error = ACAPI_Attribute_GetPropertyDefinitions (attributeHeader, API_PropertyDefinitionFilter_All, definitions); if (error == NoError) { for (UInt32 i = 0; i < definitions.GetSize (); i++) { names.Push(definitions[i].name); } } return error; } ``` -------------------------------- ### Example: Get Visible Classification Items Source: https://graphisoft.github.io/archicad-api-devkit/group___classification.html This example demonstrates how to iterate through all classification items of an element and check their visibility using ACAPI_Element_IsClassificationItemVisible. It requires valid element and classification GUIDs. ```cpp GSErrCode GetVisibleClassificationItems (const API_Guid& elemGuid, GS::Array>& visibleClassifications) { GSErrCode error = NoError; GS::Array> systemItemPairs; error = ACAPI_Element_GetClassificationItems (APINULLGuid, systemItemPairs); if (error == NoError) { for (UInt32 i = 0; i < systemItemPairs.GetSize (); ++i) { if (ACAPI_Element_IsClassificationItemVisible (elemGuid, systemItemPairs[i].second)) { visibleClassifications.Push (systemItemPairs[i]); } } } return error; } ``` -------------------------------- ### Initialize Source: https://graphisoft.github.io/archicad-api-devkit/group___add_on_lifetime.html The main entry point of the add-on. It returns a GSErrCode. ```APIDOC ## Initialize ### Description The main entry point of the add-on. ### Signature GSErrCode Initialize(void) ### Parameters None ``` -------------------------------- ### Get Filtered List of Elements by Type Source: https://graphisoft.github.io/archicad-api-devkit/group___element.html Retrieves a filtered list of element GUIDs, for example, only elements on the active floor. This is a more efficient way to iterate through specific elements compared to getting all elements first. ```cpp GS::Array elemList; ACAPI_Element_GetElemList (API_WallID, &elemList, APIFilt_OnActFloor); for (GS::Array::ConstIterator it = elemList.Enumerate (); it != nullptr; ++it) { API_Element element = {}; element.header.guid = *it; if (ACAPI_Element_Get (&element) == NoError) { /* do what you want */ } } ``` -------------------------------- ### Get Property Value from Element Source: https://graphisoft.github.io/archicad-api-devkit/group___property.html Retrieves a property value directly from an element using its GUID. This example fetches user-defined properties and then retrieves the value for the first definition. ```cpp GSErrCode GetPropertyValue (const API_Guid& elemGuid, API_PropertyValue& value) { GS::Array definitions; GS::ErrCode error = ACAPI_Element_GetPropertyDefinitions (elemGuid, API_PropertyDefinitionFilter_UserDefined, definitions); if (error == NoError) { API_Property property {}; error = ACAPI_Element_GetPropertyValue (elemGuid, definitions[0].guid, property); if (error == NoError) { value = property.value; } } return error; } ``` -------------------------------- ### Example Resource Definitions Source: https://graphisoft.github.io/archicad-api-devkit/group___add_on_integration.html This section shows example resource definitions for menu strings, status bar prompts, and toolbar icons used in conjunction with menu registration. ```rc 'STR#' 32800 "Menu strings" { /* [ 1] */ "Show Selections^ES^E3^ED^32800" } ``` ```rc 'STR#' 32620 "Status bar prompt strings" { /* [ 1] */ "Show Selections palette" } ``` ```rc 'GICN' 32600 "TB_show_selections" { "TB_show_selections" } ``` -------------------------------- ### Example: Registering a Test XML Publish Format Source: https://graphisoft.github.io/archicad-api-devkit/group___add_on_integration.html This example demonstrates how to define and register a new publish format named 'TestXML' with the 'text/Testxml' MIME type. It sets file extensions for 2D and 3D outputs and specifies that it should be a single file output. ```c++ //------------------------------------------------------ // Interface definitions //------------------------------------------------------ GSErrCode RegisterInterface (void) { API_PublishFormatData formatData {}; formatData.mimeType = "text/Testxml"; formatData.popUpText = "TestXML"; formatData.fileExtText2D = "testFormat"; formatData.fileExtText3D = "testFormat3d"; formatData.windowTypes = { APIWind_AllID }; formatData.singleFile = false; formatData.iconID = DG::Icon::NoIcon; return ACAPI_AddOnIntegration_RegisterPublishFormat (formatData); } ``` -------------------------------- ### Element Get Property Values By Guid Source: https://graphisoft.github.io/archicad-api-devkit/struct_a_p_i___railing_inner_post_quantity.html Retrieves property values for an element using a GUID. ```APIDOC ## Element Get Property Values By Guid ### Description Fetches property values for an element, identified by a globally unique identifier (GUID). ### Function - **ACAPI_Element_GetPropertyValuesByGuid** Gets the property values of the element using its GUID. ``` -------------------------------- ### Get Element Data by GUID Source: https://graphisoft.github.io/archicad-api-devkit/group___element.html Retrieves the main parameters of a given element using its GUID. Ensure the element header's GUID is correctly set before calling. ```cpp API_Element element = {}; GSErrCode err; element.header.guid = GSGuid2APIGuid (GS::Guid ("EF7A21F7-F841-4030-B6DC-C1DC8DA2F1E6")); err = ACAPI_Element_Get (&element); ``` -------------------------------- ### Example: Creating and Adding Sections to a Library Part Source: https://graphisoft.github.io/archicad-api-devkit/group___library_part.html Demonstrates the process of creating a new library part from scratch, adding parameter and 2D drawing sections, writing a 2D script, and finally saving the library part. This example utilizes several ACAPI functions for library part manipulation. ```c++ API_LibPartDetails details {}; API_LibPart libPart {}; GSHandle paramsHdl, draw2DHdl; API_LibPartSection section; double a, b; char buffer[256] = {}; GSErrCode err; const GS::UnID unID = BL::BuiltInLibraryMainGuidContainer::GetInstance ().GetUnIDWithNullRevGuid (BL::BuiltInLibPartID::StairLibPartID); CHCopyC (unID.ToUniString ().ToCStr (), libPart.parentUnID); // General Stair subtype GS::ucscpy (libPart.docu_UName, L("Test LibPart")); err = ACAPI_LibraryPart_Search (&libPart, false); if (libPart.location != nullptr) delete libPart.location; if (libPart.index != 0) { ACAPI_WriteReport ("Test LibPart already exists", true); return; } paramsHdl = nullptr; draw2DHdl = nullptr; a = 2.0; /* Create the parameter section */ b = 3.0; if (err == NoError) { err = ACAPI_LibraryPart_GetSect_ParamDef (&libPart, nullptr, &a, &b, nullptr, ¶msHdl); if (err == NoError) { details.object.fixSize = false; details.object.autoHotspot = true; err = ACAPI_LibraryPart_SetDetails_ParamDef (&libPart, paramsHdl, &details); } } err = ACAPI_LibraryPart_SetUpSect_2DDrawHdl (); /* Create the 2DBinary section */ if (err == NoError) { /* ... */ /* ... ACAPI_Element_Create ... */ /* ... ACAPI_Element_Create ... */ /* ... ACAPI_Element_Create ... */ /* ... */ err = ACAPI_LibraryPart_GetSect_2DDrawHdl (&draw2DHdl); } if (err == NoError) err = ACAPI_LibraryPart_Create (&libPart); /* Create the Library Part from scratch */ if (err == NoError) { section = {}; section.sectType = API_SectParamDef; err = ACAPI_LibraryPart_AddSection (§ion, paramsHdl, nullptr); /* Add parameters section */ } if (err == NoError) { section = {}; section.sectType = API_Sect2DDraw; err = ACAPI_LibraryPart_AddSection (§ion, draw2DHdl, nullptr); /* Add 2D binary section */ } if (err == NoError) { section = {}; section.sectType = API_Sect2DScript; err = ACAPI_LibraryPart_NewSection (§ion); /* Open the 2D Script section */ if (err == NoError) { CHCopyC ("rect2 0,0,a,b\n", buffer); /* ...write it */ err = ACAPI_LibraryPart_WriteSection (static_cast (strlen (buffer)), buffer); } err = ACAPI_LibraryPart_EndSection (); /* ...close it */ } err = ACAPI_LibraryPart_Save (&libPart); /* Save and register the Library Part */ BMKillHandle (¶msHdl); BMKillHandle (&draw2DHdl); ``` -------------------------------- ### Element Get Property Values Of Default Elem By Guid Source: https://graphisoft.github.io/archicad-api-devkit/struct_a_p_i___railing_inner_post_quantity.html Retrieves property values of the default element using a GUID. ```APIDOC ## Element Get Property Values Of Default Elem By Guid ### Description Fetches property values for the default element configuration, identified by a GUID. ### Function - **ACAPI_Element_GetPropertyValuesOfDefaultElemByGuid** Gets the property values of the default element using its GUID. ``` -------------------------------- ### ACAPI_Element_GetPropertyValuesByGuid Source: https://graphisoft.github.io/archicad-api-devkit/class_a_c_a_p_i_1_1_element_1_1_opening.html Gets property values for an element using its GUID. ```APIDOC ## ACAPI_Element_GetPropertyValuesByGuid ### Description Gets property values for an element using its GUID. ### Method Not specified (likely a function call within the API SDK) ### Endpoint Not applicable (SDK function) ### Parameters None explicitly defined in the source. ### Request Example Not applicable. ### Response Not specified. ``` -------------------------------- ### Initialize() Add-on Entry Point Source: https://graphisoft.github.io/archicad-api-devkit/group___add_on_lifetime.html This function is the main entry point for an add-on. It is called after the add-on is loaded into memory and communication channels are set up. Use this to initialize global variables, install callback functions for services, and register notification handlers. ```cpp typedef struct { double len; Int32 index; } NType; GSHandle** handle; Int32 nAlloc; Int32 nElem; // ----------------------------------------------------------------------------- // Called after the Add-On has been loaded into memory // ----------------------------------------------------------------------------- GSErrCode Initialize () { // If the add-on has user interface and wants to use context sensitive help engine IO::Location helpLoc; ACAPI_GetOwnLocation (&helpLoc); DG::RegisterAdditionalHelpLocation (MDID_DeveloperID, MDID_LocalID, &helpLoc, &GS::EmptyUniString, &GS::EmptyUniString, nullptr, &GS::EmptyUniString); // // Install the menu handler procedure // GSErrCode err = ACAPI_MenuItem_InstallMenuHandler (32500, MenuCommandHandler); if (err != NoError) DBPrintf ("Initialize():: ACAPI_MenuItem_InstallMenuHandler failed\n"); // // Install the change defaults notification handler procedure // API_ToolBoxItem toolBoxItem {}; toolBoxItem.type = API_ZombieElemID; // for all types err = ACAPI_Element_CatchChangeDefaults (&toolBoxItem, APIDefaultsChangeHandler); if (err == NoError) { err = ACAPI_ProjectOperation_CatchProjectEvent (APINotify_Close, APIProjectEventHandler); } return err; } // Initialize ``` -------------------------------- ### Initialize Function Implementation Source: https://graphisoft.github.io/archicad-api-devkit/_required_functions.html The Initialize function serves as the main entry point for the add-on after it has been loaded into memory. It's used to set up the add-on and install callback functions. ```c GSErrCode Initialize(void) ``` -------------------------------- ### Get Opened Windows by Type Source: https://graphisoft.github.io/archicad-api-devkit/group___window.html Retrieves the GUIDs of all currently opened windows of a specified type. Use this to get a list of windows to interact with. ```c++ GSErrCode err = ACAPI_Window_GetOwnWindows (windowTypeID, &guid); ``` -------------------------------- ### Create Example Property Definition Source: https://graphisoft.github.io/archicad-api-devkit/group___property.html Demonstrates how to create an example property definition using ACAPI_Property_CreatePropertyDefinition. Ensure the groupGuid is valid and the definition's properties are correctly set. ```cpp GSErrCode CreateExamplePropertyDefinition (API_Guid groupGuid, API_PropertyDefinition& definition) { definition.guid = APINULLGuid; definition.groupGuid = groupGuid; definition.name = "Property Definition"; definition.description = "An example property definition."; definition.collectionType = API_PropertySingleCollectionType; definition.valueType = API_PropertyBooleanValueType; definition.definitionType = API_PropertyCustomDefinitionType; definition.defaultValue.basicValue.singleVariant.variant.type = definition.valueType; definition.defaultValue.basicValue.singleVariant.variant.boolValue = false; return ACAPI_Property_CreatePropertyDefinition (definition); } ``` -------------------------------- ### Get All Property Values by GUID Source: https://graphisoft.github.io/archicad-api-devkit/group___property.html Retrieves all user-defined property values for a default element type using their GUIDs. Requires Archicad 26 or later. ```cpp GSErrCode GetAllPropertyValuesByGuid (const API_ElemType& type, GS::Array& values) { GS::Array definitions; GS::GSErrCode error = ACAPI_Element_GetPropertyDefinitionsOfDefaultElem (type, API_PropertyDefinitionFilter_UserDefined, definitions); if (error == NoError) { GS::Array propGuids; for (UInt32 i = 0; i < definitions.GetSize (); i++) { propGuids.Push (definitions[i].guid); } GS::Array properties; error = ACAPI_Element_GetPropertyValuesOfDefaultElemByGuid (type, propGuids, properties); if (error == NoError) { for (UInt32 i = 0; i < properties.GetSize (); i++) { if (properties[i].isDefault) { values.Push (properties[i].definition.defaultValue.basicValue); } else { values.Push (properties[i].value); } } } } return error; } ``` -------------------------------- ### Property Management Functions Source: https://graphisoft.github.io/archicad-api-devkit/struct_a_p_i___translator_name_config.html Functions for installing and registering handlers for property objects and their visibility. ```APIDOC ## ACAPI_Property_InstallPropertyObjectHandler ### Description Installs a handler for property objects. ### Method Not applicable (C++ API function) ### Endpoint Not applicable (C++ API function) ## ACAPI_Property_InstallPropertyVisibilityHandler ### Description Installs a handler for controlling the visibility of properties. ### Method Not applicable (C++ API function) ### Endpoint Not applicable (C++ API function) ## ACAPI_Property_RegisterPropertyObjectHandler ### Description Registers a handler for property objects. ### Method Not applicable (C++ API function) ### Endpoint Not applicable (C++ API function) ## ACAPI_Property_RegisterPropertyVisibilityHandler ### Description Registers a handler for property visibility. ### Method Not applicable (C++ API function) ### Endpoint Not applicable (C++ API function) ``` -------------------------------- ### Create and Add Sections to a Library Part Source: https://graphisoft.github.io/archicad-api-devkit/group___library_part.html This example demonstrates the process of creating a Library Part from scratch, adding parameter and 2D binary sections, opening and writing to a 2D script section, and finally closing it using ACAPI_LibraryPart_EndSection before saving the Library Part. It requires prior setup of Library Part details and sections. ```c++ API_LibPartDetails details {}; API_LibPart libPart {}; GSHandle paramsHdl, draw2DHdl; API_LibPartSection section; double a, b; char buffer[256] = {}; GSErrCode err; const GS::UnID unID = BL::BuiltInLibraryMainGuidContainer::GetInstance ().GetUnIDWithNullRevGuid (BL::BuiltInLibPartID::StairLibPartID); CHCopyC (unID.ToUniString ().ToCStr (), libPart.parentUnID); // General Stair subtype GS::ucscpy (libPart.docu_UName, L("Test LibPart")); err = ACAPI_LibraryPart_Search (&libPart, false); if (libPart.location != nullptr) delete libPart.location; if (libPart.index != 0) { ACAPI_WriteReport ("Test LibPart already exists", true); return; } paramsHdl = nullptr; draw2DHdl = nullptr; a = 2.0; /* Create the parameter section */ b = 3.0; if (err == NoError) { err = ACAPI_LibraryPart_GetSect_ParamDef (&libPart, nullptr, &a, &b, nullptr, ¶msHdl); if (err == NoError) { details.object.fixSize = false; details.object.autoHotspot = true; err = ACAPI_LibraryPart_SetDetails_ParamDef (&libPart, paramsHdl, &details); } } err = ACAPI_LibraryPart_SetUpSect_2DDrawHdl (); /* Create the 2DBinary section */ if (err == NoError) { /* ... */ /* ... ACAPI_Element_Create ... */ /* ... ACAPI_Element_Create ... */ /* ... ACAPI_Element_Create ... */ /* ... */ err = ACAPI_LibraryPart_GetSect_2DDrawHdl (&draw2DHdl); } if (err == NoError) err = ACAPI_LibraryPart_Create (&libPart); /* Create the Library Part from scratch */ if (err == NoError) { section = {}; section.sectType = API_SectParamDef; err = ACAPI_LibraryPart_AddSection (§ion, paramsHdl, nullptr); /* Add parameters section */ } if (err == NoError) { section = {}; section.sectType = API_Sect2DDraw; err = ACAPI_LibraryPart_AddSection (§ion, draw2DHdl, nullptr); /* Add 2D binary section */ } if (err == NoError) { section = {}; section.sectType = API_Sect2DScript; err = ACAPI_LibraryPart_NewSection (§ion); /* Open the 2D Script section */ if (err == NoError) { CHCopyC ("rect2 0,0,a,b\n", buffer); /* ...write it */ err = ACAPI_LibraryPart_WriteSection (static_cast (strlen (buffer)), buffer); } err = ACAPI_LibraryPart_EndSection (); /* ...close it */ } err = ACAPI_LibraryPart_Save (&libPart); /* Save and register the Library Part */ BMKillHandle (¶msHdl); BMKillHandle (&draw2DHdl); ``` -------------------------------- ### Retrieve Built-in Library Part GUID Source: https://graphisoft.github.io/archicad-api-devkit/group___library_part.html Use ACAPI_LibraryPart_GetBuiltInLibpartUnId to get the GUID of a library part compiled into the add-on's module as a 'FILE' resource. ```c GSErrCode ACAPI_LibraryPart_GetBuiltInLibpartUnId ( | short | _templateFileResID_ , | | char * | _lpfUnId_ ) ``` -------------------------------- ### Get All Property Values for an Element Component by GUID Source: https://graphisoft.github.io/archicad-api-devkit/group___property.html Retrieves user-defined property values for a specific element component using property definition GUIDs. This function requires obtaining property definition GUIDs first. ```cpp GSErrCode GetAllPropertyValues (const API_ElemComponentID& elemComponent, GS::Array& values) { GS::Array definitions; GSErrCode error = ACAPI_Element_GetPropertyDefinitions (elemComponent, API_PropertyDefinitionFilter_UserDefined, definitions); if (error == NoError) { GS::Array propertyDefinitionGuids; for (UInt32 i = 0; i < definitions.GetSize (); i++) { propertyDefinitionGuids.Push (definitions[i].guid); } GS::Array properties; error = ACAPI_Element_GetPropertyValuesByGuid (elemComponent, propertyDefinitionGuids, properties); if (error == NoError) { for (UInt32 i = 0; i < properties.GetSize (); i++) { if (properties[i].isDefault) { values.Push (properties[i].definition.defaultValue.basicValue); } else { values.Push (properties[i].value); } } } } return error; } ``` -------------------------------- ### Element Observer Management Source: https://graphisoft.github.io/archicad-api-devkit/struct_a_p_i___stair_polyline_edge_data-members.html Functions for installing and detaching element observers. ```APIDOC ## Element Observer Management Functions to manage observers attached to elements. ### Functions * `ACAPI_Element_InstallElementObserver` * `ACAPI_Element_DetachObserver ``` -------------------------------- ### Property Object and Visibility Handlers Source: https://graphisoft.github.io/archicad-api-devkit/struct_a_p_i___property_value.html Functions for installing and registering handlers for property objects and visibility. ```APIDOC ## ACAPI_Property_InstallPropertyObjectHandler ### Description Installs a handler for property objects. ### Method (Not specified, likely a C++ function call) ### Parameters - **handler** (API_PropertyObjectHandler*): Pointer to the property object handler. ### Request Example ```cpp // Example usage (conceptual) API_PropertyObjectHandler* myHandler = ...; ACAPI_Property_InstallPropertyObjectHandler(myHandler); ``` ### Response (No specific response details provided in the source) ``` ```APIDOC ## ACAPI_Property_InstallPropertyVisibilityHandler ### Description Installs a handler for property visibility. ### Method (Not specified, likely a C++ function call) ### Parameters - **handler** (API_PropertyVisibilityHandler*): Pointer to the property visibility handler. ### Request Example ```cpp // Example usage (conceptual) API_PropertyVisibilityHandler* myHandler = ...; ACAPI_Property_InstallPropertyVisibilityHandler(myHandler); ``` ### Response (No specific response details provided in the source) ``` ```APIDOC ## ACAPI_Property_RegisterPropertyObjectHandler ### Description Registers a handler for property objects. ### Method (Not specified, likely a C++ function call) ### Parameters - **handler** (API_PropertyObjectHandler*): Pointer to the property object handler. ### Request Example ```cpp // Example usage (conceptual) API_PropertyObjectHandler* myHandler = ...; ACAPI_Property_RegisterPropertyObjectHandler(myHandler); ``` ### Response (No specific response details provided in the source) ``` ```APIDOC ## ACAPI_Property_RegisterPropertyVisibilityHandler ### Description Registers a handler for property visibility. ### Method (Not specified, likely a C++ function call) ### Parameters - **handler** (API_PropertyVisibilityHandler*): Pointer to the property visibility handler. ### Request Example ```cpp // Example usage (conceptual) API_PropertyVisibilityHandler* myHandler = ...; ACAPI_Property_RegisterPropertyVisibilityHandler(myHandler); ``` ### Response (No specific response details provided in the source) ``` -------------------------------- ### ACAPI_Element_GetPropertyValuesOfDefaultElemByGuid Source: https://graphisoft.github.io/archicad-api-devkit/class_a_c_a_p_i_1_1_element_1_1_opening.html Gets property values for the default element using its GUID. ```APIDOC ## ACAPI_Element_GetPropertyValuesOfDefaultElemByGuid ### Description Gets property values for the default element using its GUID. ### Method Not specified (likely a function call within the API SDK) ### Endpoint Not applicable (SDK function) ### Parameters None explicitly defined in the source. ### Request Example Not applicable. ### Response Not specified. ``` -------------------------------- ### Install Menu Handler Source: https://graphisoft.github.io/archicad-api-devkit/group___add_on_integration.html Installs a callback procedure for handling the add-on's menu commands. Associate a menu string resource ID with the handler procedure. ```c++ GSErrCode | ACAPI_MenuItem_InstallMenuHandler (short menuStrResID, APIMenuCommandProc *handlerProc) ``` -------------------------------- ### Graphical Arc Input with ACAPI_UserInput_GetArc Source: https://graphisoft.github.io/archicad-api-devkit/group___user_input.html This example demonstrates how to use ACAPI_UserInput_GetArc to get arc input from the user. It first obtains a center point using ACAPI_UserInput_GetPoint, then a start point and radius using ACAPI_UserInput_GetLine, and finally the arc itself using ACAPI_UserInput_GetArc. Custom cursor feedback is configured for each input step. The resulting arc's properties are then reported. ```c API_GetPointType pointInfo {}; API_GetLineType lineInfo {}; API_GetArcType arcInfo {}; char buffer [256]; GSErrCode err; CHCopyC ("Click the arc center point", pointInfo.prompt); pointInfo.changeCursorSet = true; /* show cross cursors suggesting the center point */ pointInfo.cursorSet.nothingOnCursor = APICursor_XPoint; pointInfo.cursorSet.pointOnCursor = APICursor_ArrowXPoint; pointInfo.cursorSet.lineOnCursor = APICursor_PencilXPoint; pointInfo.cursorSet.refPointOnCursor = APICursor_ArrowXPoint; pointInfo.cursorSet.refLineOnCursor = APICursor_PencilXPoint; pointInfo.cursorSet.crossOnCursor = APICursor_ArrowXPoint; pointInfo.cursorSet.normalOnCursor = APICursor_PencilXPoint; pointInfo.cursorSet.tangentOnCursor = APICursor_ArrowXPoint; err = ACAPI_UserInput_GetPoint (&pointInfo, nullptr); if (!err) { CHCopyC ("Enter the arc start point", lineInfo.prompt); lineInfo.startCoord = pointInfo.pos; lineInfo.changeCursorSet = true; /* use hand cursors for drawing the radius of the arc */ lineInfo.cursorSet.nothingOnCursor = APICursor_Hand; lineInfo.cursorSet.pointOnCursor = APICursor_MiniHand; lineInfo.cursorSet.lineOnCursor = APICursor_MiniHand; lineInfo.cursorSet.refPointOnCursor = APICursor_MiniHand; lineInfo.cursorSet.refLineOnCursor = APICursor_MiniHand; lineInfo.cursorSet.crossOnCursor = APICursor_MiniHand; lineInfo.cursorSet.normalOnCursor = APICursor_MiniHand; lineInfo.cursorSet.tangentOnCursor = APICursor_MiniHand; err = ACAPI_UserInput_GetLine (&lineInfo, nullptr); } if (!err) { CHCopyC ("Enter the arc end point", arcInfo.prompt); arcInfo.origo = lineInfo.startCoord; arcInfo.startCoord = lineInfo.pos; arcInfo.startCoordGiven = true; arcInfo.changeCursorSet = true; /* use eye cursors for getting the arc */ arcInfo.cursorSet.nothingOnCursor = APICursor_Eye; arcInfo.cursorSet.pointOnCursor = APICursor_DoubleEye; arcInfo.cursorSet.lineOnCursor = APICursor_DoubleEye; arcInfo.cursorSet.refPointOnCursor = APICursor_DoubleEye; arcInfo.cursorSet.refLineOnCursor = APICursor_DoubleEye; arcInfo.cursorSet.crossOnCursor = APICursor_DoubleEye; arcInfo.cursorSet.normalOnCursor = APICursor_DoubleEye; arcInfo.cursorSet.tangentOnCursor = APICursor_DoubleEye; err = ACAPI_UserInput_GetArc (&arcInfo, nullptr); } if (!err) { sprintf (buffer, "Origo coordinates: (%f, %f)", arcInfo.origo.x, arcInfo.origo.y); ACAPI_WriteReport (buffer, false); if (arcInfo.negArc) sprintf (buffer, "Arc begins: (%f, %f)\nArc ends: (%f, %f)", arcInfo.pos.x, arcInfo.pos.y, arcInfo.startCoord.x, arcInfo.startCoord.y); else sprintf (buffer, "Arc begins: (%f, %f)\nArc ends: (%f, %f)", arcInfo.startCoord.x, arcInfo.startCoord.y, arcInfo.pos.x, arcInfo.pos.y); ACAPI_WriteReport (buffer, false); } else if (err == APIERR_CANCEL) ACAPI_WriteReport ("Input was interrupted", true); ``` -------------------------------- ### Example: Creating and Assigning Objects to an IFC Group Source: https://graphisoft.github.io/archicad-api-devkit/group___i_f_c.html Demonstrates creating an IFC group, assigning objects to it, and retrieving relationship data. This example shows how to use GetIfcRelAssignsToGroup and GetIfcRelServicesBuildings to access group-related IFC objects. ```cpp auto groupResult = hookAssignments.CreateIfcGroup (guid, type, name, addAsRoot); if (groupResult.IsOk ()) { auto group = groupResult.Unwrap (); myGroupingData.groupObjects.emplace (group); hookAssignments.AssignObjects (group, GetElementObjects (toAssign)); if (toService.has_value ()) hookAssignments.ServiceBuildings (group, GetElementObjects (*toService)); if (name.has_value ()) { auto relAssigns = hookAssignments.GetIfcRelAssignsToGroup (group); if (relAssigns.IsOk ()) myGroupingData.relationToGroupNameTable.emplace (*relAssigns, *name); auto relServices = hookAssignments.GetIfcRelServicesBuildings (group); if (relServices.IsOk ()) myGroupingData.relationToGroupNameTable.emplace (*relServices, *name); } } ``` -------------------------------- ### Initialize, Update, and Close Process Window Source: https://graphisoft.github.io/archicad-api-devkit/group___process_window.html This example shows how to initialize a process window, update its progress, and finally close it. It's useful for providing user feedback during long operations like listing library parts. Ensure ACAPI_ProcessWindow_IsProcessCanceled is checked periodically to allow user interruption. ```c++ GSErrCode err; API_LibPart libPart {}; GS::UniString title ("Listing the library"); GS::UniString subtitle ("working..."); Int32 nPhase; Int32 i, nLib; char buffer [256]; err = ACAPI_LibraryPart_GetNum (&nLib); if (nLib > 0) { nPhase = 1; ACAPI_ProcessWindow_InitProcessWindow (&title, &nPhase); ACAPI_ProcessWindow_SetNextProcessPhase (&subtitle, &nLib); for (i = 1; i <= nLib; i++) { libPart.index = i; err = ACAPI_LibraryPart_Get (&libPart); if (!err) { sprintf (buffer, "[%2d] \"%s\"", i, (const char *) GS::UniString (libPart.docu_UName).ToCStr ()); ACAPI_WriteReport (buffer, false); } ACAPI_ProcessWindow_SetProcessValue (&i); if (ACAPI_ProcessWindow_IsProcessCanceled ()) break; } ACAPI_ProcessWindow_CloseProcessWindow (); } ``` -------------------------------- ### Retrieve Element Classification Items Source: https://graphisoft.github.io/archicad-api-devkit/group___classification.html Use ACAPI_Element_GetClassificationItems to get all classification system and item GUID pairs for a given element. Ensure the element GUID is valid. ```cpp GSErrCode ACAPI_Element_GetClassificationItems | ( | const API_Guid & | _elemGuid_ , | | GS::Array< GS::Pair< API_Guid, API_Guid > > & | _systemItemPairs_ ) ``` -------------------------------- ### Get Override Combination Names Source: https://graphisoft.github.io/archicad-api-devkit/group___graphical_override.html Retrieves the names of all override combinations in the current plan. It first gets the GUIDs of all combinations and then fetches the details for each to extract their names. ```cpp GSErrCode GetOverrideCombinationNames (GS::Array& combinationNames) { GS::Array combinationsGuids; GS::GSErrCode error = ACAPI_GraphicalOverride_GetOverrideCombinationList (combinationsGuids); if (error == NoError) { for (USize i = 0; i < combinationsGuids.GetSize(); ++i) { API_OverrideCombination combination = {combinationsGuids[i]}; error = ACAPI_GraphicalOverride_GetOverrideCombination (combination, nullptr); if (error == NoError) { combinationNames.Push (combination.name); } } } return error; } ``` -------------------------------- ### Install Menu Handler in Initialize Source: https://graphisoft.github.io/archicad-api-devkit/group___add_on_integration.html Installs a callback procedure for handling add-on menu commands. This function should be called in the Initialize function of your add-on. It registers the callback function that will be invoked when a user selects one of your add-on's menu commands. ```c // ----------------------------------------------------------------------------- // Called when the add-on has been loaded into memory // ----------------------------------------------------------------------------- GSErrCode Initialize (void) { GSErrCode err = NoError; err = ACAPI_MenuItem_InstallMenuHandler (32500, CustomAPIMenuCommandProc); return err; } ``` -------------------------------- ### Element Get Header Source: https://graphisoft.github.io/archicad-api-devkit/struct_a_p_i___railing_inner_post_quantity.html Retrieves the header information of an element. ```APIDOC ## Element Get Header ### Description Fetches the header data associated with an element, which typically contains metadata and identification information. ### Function - **ACAPI_Element_GetHeader** Gets the header information of the element. ``` -------------------------------- ### Get Hotlink Node Tree Structure Source: https://graphisoft.github.io/archicad-api-devkit/group___hotlink.html Use this to retrieve the hierarchical structure of hotlink nodes. It requires the GUID of the parent node and returns a hashtable mapping parent GUIDs to arrays of their children's GUIDs. Ensure the hotlink root node GUID is obtained first. ```c API_HotlinkTypeID type = APIHotlink_Module; API_Guid hotlinkRootNodeGuid = APINULLGuid; if (ACAPI_Hotlink_GetHotlinkRootNodeGuid (&type, &hotlinkRootNodeGuid) == NoError) { GS::HashTable > hotlinkNodeTree; if (ACAPI_Hotlink_GetHotlinkNodeTree (&hotlinkRootNodeGuid, &hotlinkNodeTree) == NoError) { if (hotlinkNodeTree.ContainsKey (hotlinkRootNodeGuid)) { ACAPI_WriteReport ("List of main level hotlink nodes:", false); const GS::Array& nodeRefList = hotlinkNodeTree.Get (hotlinkRootNodeGuid); for (UInt32 i = 0; i < nodeRefList.GetSize (); i++) { char guidStr[64]; APIGuid2GSGuid (nodeRefList[i]).ConvertToString (guidStr); ACAPI_WriteReport (guidStr, false); } } else { ACAPI_WriteReport ("No hotlink node was found", false); } } } ``` -------------------------------- ### Create and Find Default System Group Source: https://graphisoft.github.io/archicad-api-devkit/class_a_c_a_p_i_1_1_m_e_p_1_1_system_group.html This example shows how to find an existing system group by a default name or create it if it doesn't exist. It utilizes GetSystemGroupIDs and CreateSystemGroup functions. ```cpp constexpr std::string_view DefaultSystemGroupName { "Generated System Group" }; std::optional FindOrCreateDefaultGroup () { // First, locate the default system group: auto systemGroups { ACAPI::MEP::GetSystemGroupIDs () }; if (systemGroups.IsErr ()) return {}; for (const auto& id : systemGroups.Unwrap ()) { auto systemGroup { ACAPI::MEP::SystemGroup::Get (id) }; if (systemGroup.IsErr ()) return {}; if (systemGroup->GetName () == DefaultSystemGroupName) return systemGroup.Unwrap (); } auto newlyCreatedSystemGroup { ACAPI::MEP::CreateSystemGroup (GS::UniString { DefaultSystemGroupName }) }; if (newlyCreatedSystemGroup.IsErr ()) return {}; return newlyCreatedSystemGroup.Unwrap (); } ``` -------------------------------- ### Initialize Source: https://graphisoft.github.io/archicad-api-devkit/functions_func_i.html Initializes the AddonServiceInterface, preparing it for operation. ```APIDOC ## Initialize() ### Description Initializes the `ACAPI::AddonServiceInterface`, setting up necessary components for the addon. ### Method Not applicable (function call) ### Endpoint Not applicable (function call) ### Parameters None ### Response - Returns an instance of `ACAPI::AddonServiceInterface`. ``` -------------------------------- ### Get Object ID Source: https://graphisoft.github.io/archicad-api-devkit/class_a_c_a_p_i_1_1_m_e_p_1_1_equipment_default.html Retrieves the unique identifier (GUID) of the equipment object. ```APIDOC ## Get Object ID ### Description Gets the object ID (GUID) for this equipment. ### Method Signature API_Guid | GetObjectId () const ``` -------------------------------- ### Property Value and Import Functions Source: https://graphisoft.github.io/archicad-api-devkit/struct_a_p_i___single_variant.html Functions for getting, setting, and importing property values, and registering handlers. ```APIDOC ## ACAPI_Property_GetPropertyValueString ### Description Retrieves the string representation of a property value. ### Method Not specified (likely a function call in the Archicad API SDK) ## ACAPI_Property_Import ### Description Imports property data. ### Method Not specified (likely a function call in the Archicad API SDK) ## ACAPI_Property_InstallPropertyObjectHandler ### Description Installs a handler for property objects. ### Method Not specified (likely a function call in the Archicad API SDK) ## ACAPI_Property_InstallPropertyVisibilityHandler ### Description Installs a handler for property visibility. ### Method Not specified (likely a function call in the Archicad API SDK) ## ACAPI_Property_IsValidValue ### Description Checks if a given value is valid for a property. ### Method Not specified (likely a function call in the Archicad API SDK) ## ACAPI_Property_ModifyPropertyValue ### Description Modifies the value of a property. ### Method Not specified (likely a function call in the Archicad API SDK) ## ACAPI_Property_RegisterPropertyObjectHandler ### Description Registers a handler for property objects. ### Method Not specified (likely a function call in the Archicad API SDK) ## ACAPI_Property_RegisterPropertyVisibilityHandler ### Description Registers a handler for property visibility. ### Method Not specified (likely a function call in the Archicad API SDK) ## ACAPI_Property_SetPropertyValueFromString ### Description Sets a property value from a string. ### Method Not specified (likely a function call in the Archicad API SDK) ``` -------------------------------- ### Element Observer and Observer Management Source: https://graphisoft.github.io/archicad-api-devkit/struct_a_p_i___property_object_ref_type-members.html Functions for installing and detaching observers to monitor element changes. ```APIDOC ## Element Observer Management ### Description Functions to manage observers for monitoring element changes. ### Functions * `ACAPI_Element_InstallElementObserver` * `ACAPI_Element_DetachObserver` ``` -------------------------------- ### Install Add-On Command Handler Source: https://graphisoft.github.io/archicad-api-devkit/group___add_on_add_on_communication.html Installs a handler object for HTTP requests, identified by Add-On MDID and name. Should be called from Initialize. The Add-On remains in memory after a successful call. ```c++ GSErrCode ACAPI_AddOnAddOnCommunication_InstallAddOnCommandHandler | ( | GS::Owner< API_AddOnCommand > | _addOnCommand_| ) | ``` -------------------------------- ### Get Begin Node ID Source: https://graphisoft.github.io/archicad-api-devkit/class_a_c_a_p_i_1_1_m_e_p_1_1_routing_segment.html Retrieves the UniqueID of the starting node for the RoutingSegment. ```APIDOC ## GetBeginNodeId() ### Description Returns the UniqueID of the RoutingNode from which the RoutingSegment originates. ### Returns - UniqueID - The UniqueID of the starting RoutingNode. ``` -------------------------------- ### Menu Integration Functions Source: https://graphisoft.github.io/archicad-api-devkit/struct_a_p_i___translator_name_config.html Functions for installing and registering custom menu items within ARCHICAD. ```APIDOC ## ACAPI_MenuItem_InstallMenuHandler ### Description Installs a handler for custom menu items. ### Method Not applicable (C++ API function) ### Endpoint Not applicable (C++ API function) ## ACAPI_MenuItem_RegisterMenu ### Description Registers a custom menu item in ARCHICAD. ### Method Not applicable (C++ API function) ### Endpoint Not applicable (C++ API function) ``` -------------------------------- ### Element Get Compound Info String Source: https://graphisoft.github.io/archicad-api-devkit/struct_a_p_i___railing_inner_post_quantity.html Retrieves the compound information string for an element. ```APIDOC ## Element Get Compound Info String ### Description Fetches a string that contains combined information about the element's properties or structure. ### Function - **ACAPI_Element_GetCompoundInfoString** Gets the compound information string of the element. ``` -------------------------------- ### Get Attribute Folder Source: https://graphisoft.github.io/archicad-api-devkit/group___attribute.html Retrieves an attribute folder using its path or GUID. Ensure the folder path is legal and that either a GUID or path is provided, or the root folder will be accessed. ```c++ GSErrCode ACAPI_Attribute_GetFolder(API_AttributeFolder& _folder) ``` ```c++ API_AttributeFolder folder {}; folder.typeID = API_LinetypeID; folder.guid = GS::Guid ("27075EFF-611F-4B11-9BBB-553AC8BDA922"); DBVERIFY (ACAPI_Attribute_GetFolder (folder) == NoError); for (const auto& name : folder.path) { ACAPI_WriteReport (name, false); // ... ``` -------------------------------- ### Initialize Source: https://graphisoft.github.io/archicad-api-devkit/class_a_c_a_p_i_1_1_addon_service_interface.html Callback function for the initialization phase of the Add-on service. ```APIDOC ## Initialize() ### Description The callback function for the initialization phase. ### Returns GSErrCode - The error code indicating the result of the initialization. ``` -------------------------------- ### Get Object ID Source: https://graphisoft.github.io/archicad-api-devkit/class_a_c_a_p_i_1_1_m_e_p_1_1_modifiable_element_base.html Retrieves the unique GUID identifying the object type of the element. ```APIDOC ## GetObjectId ### Description Retrieves the object ID of the element. ### Method Signature ```cpp API_Guid GetObjectId () const ``` ``` -------------------------------- ### ProductVersionInfoImplBase Constructor Source: https://graphisoft.github.io/archicad-api-devkit/class_a_c_a_p_i_1_1_license_info_1_1_impl_1_1_product_version_info_impl_base-members.html Constructor for the ProductVersionInfoImplBase class. ```APIDOC ## ProductVersionInfoImplBase::ProductVersionInfoImplBase ### Description Constructor for the ProductVersionInfoImplBase class. ### Method `ProductVersionInfoImplBase()` ``` -------------------------------- ### Initialize() Source: https://graphisoft.github.io/archicad-api-devkit/group___add_on_lifetime.html The main entry point of the add-on. This function is called by the library after the add-on has been loaded into memory and communication channels are set up. It's used for initializing global variables, memory, installing callback functions, and registering help engines. ```APIDOC ## Initialize() ### Description The main entry point of the add-on. It is called by the library right after the DLL/code fragment has been loaded into the memory, and the communication channels are set up correctly. This is the place where you can initialize your global variables, dynamic memory blocks etc. In this function you will also have to install the callback functions for the different services you registered in the CheckEnvironment and RegisterInterface routines. Also you can install the notification handlers here. If your add-on has user interface, and you want to use a context sensitive help engine (you want to use not just tooltips, but help anchors too), then this is the place where you can register your own help engine's path with your add-on's MDID. ### Returns * NoError - The initialization procedure has completed with success. ### Remarks You can use this function as the main entry point of your code. ### Example ```c typedef struct { double len; Int32 index; } NType; GSHandle** handle; Int32 nAlloc; Int32 nElem; // ----------------------------------------------------------------------------- // Called after the Add-On has been loaded into memory // ----------------------------------------------------------------------------- GSErrCode Initialize () { // If the add-on has user interface and wants to use context sensitive help engine IO::Location helpLoc; ACAPI_GetOwnLocation (&helpLoc); DG::RegisterAdditionalHelpLocation (MDID_DeveloperID, MDID_LocalID, &helpLoc, &GS::EmptyUniString, &GS::EmptyUniString, nullptr, &GS::EmptyUniString); // // Install the menu handler procedure // GSErrCode err = ACAPI_MenuItem_InstallMenuHandler (32500, MenuCommandHandler); if (err != NoError) DBPrintf ("Initialize():: ACAPI_MenuItem_InstallMenuHandler failed\n"); // // Install the change defaults notification handler procedure // API_ToolBoxItem toolBoxItem {}; toolBoxItem.type = API_ZombieElemID; // for all types err = ACAPI_Element_CatchChangeDefaults (&toolBoxItem, APIDefaultsChangeHandler); if (err == NoError) { err = ACAPI_ProjectOperation_CatchProjectEvent (APINotify_Close, APIProjectEventHandler); } return err; } // Initialize ``` ``` -------------------------------- ### Get TWID Source: https://graphisoft.github.io/archicad-api-devkit/class_a_c_a_p_i_1_1_design_options_1_1_design_option_manager.html Retrieves the GUID of the Design Option object set for TW reserve/release. ```APIDOC ## GetTWID ### Description This function is used to get the guid of the Design Option object set. This guid can be used for TW reserve/release. ### Signature Result< API_Guid > GetTWID () const ### Parameters None ```