2018-12-26
05:43 AM
- last edited on
2022-10-04
04:47 PM
by
Daniel Kassai
2018-12-26 03:10 PM
2018-12-26 03:23 PM
Tsepov wrote:It would be nice to have a list of methods in examples with a brief description. It's easy to miss some stuff in examples.
learn an example
2018-12-27 06:39 AM
2018-12-30 07:06 PM
2019-01-02 12:31 PM
Tsepov wrote:I think it's a wrong direction. Even if I could tell you the dialogID of the Navigator palette, you still need the itemID of the TreeView and finally you will retrieve only the index of the selected items.
How I can get Navigator dialogID ?
#include "DG.h" short currDialID; short currItem; DGGetFocus (DG_ALL_DIALOGS, &currDialID, &currItem);
#include "Queue.hpp"
using NavItemChildren = GS::Array<API_NavigatorItem>;
using NavItemParentChildrenPair = GS::Pair<API_NavigatorItem, NavItemChildren>;
static NavItemChildren GetNavItemChildren (const API_NavigatorItem& parentItem)
{
NavItemChildren childrenItems;
API_NavigatorItem** items = nullptr;
GSErrCode err = ACAPI_Navigator (APINavigator_GetNavigatorChildrenItemsID, (void*)&parentItem, &items);
if (err == NoError) {
Int32 childCount = BMhGetSize ((GSHandle)items) / Sizeof32 (API_NavigatorItem);
for (Int32 ii = 0; ii < childCount; ++ii) {
childrenItems.Push ((*items)[ii]);
}
BMhKill ((GSHandle *)&items);
}
return childrenItems;
}
static API_Guid GetLayoutBookRootGuid ()
{
API_NavigatorSet set = {};
set.mapId = API_LayoutMap;
ACAPI_Navigator (APINavigator_GetNavigatorSetID, &set, nullptr);
return set.rootGuid;
}
static GS::HashTable<API_Guid, NavItemParentChildrenPair> GetLayoutBook ()
{
GS::HashTable<API_Guid, NavItemParentChildrenPair> result;
API_NavigatorItem item = {};
item.guid = GetLayoutBookRootGuid ();
item.mapId = API_LayoutMap;
GS::Queue<API_NavigatorItem> queue = { item };
while (queue.IsEmpty () == false) {
API_NavigatorItem parentItem = queue.Pop ();
NavItemChildren childrenItems = GetNavItemChildren (parentItem);
for (const auto& child : childrenItems) {
queue.Push (child);
}
result.Add (parentItem.guid, NavItemParentChildrenPair (parentItem, childrenItems));
}
return result;
}
static GS::Array<API_NavigatorItem> GetLayoutSubsets (const GS::HashTable<API_Guid, NavItemParentChildrenPair>& layoutBook)
{
GS::Array<API_NavigatorItem> subsets;
for (const NavItemParentChildrenPair& parentChildrenPair : layoutBook.Values ()) {
if (parentChildrenPair.first.itemType == API_SubSetNavItem)
subsets.Push (parentChildrenPair.first);
}
return subsets;
}
static const NavItemChildren& GetLayoutsFromSubset (const API_Guid& subsetGuid, const GS::HashTable<API_Guid, NavItemParentChildrenPair>& layoutBook)
{
return layoutBook[subsetGuid].second;
}
// Usage:
const GS::HashTable<API_Guid, NavItemParentChildrenPair> layoutBook = GetLayoutBook ();
for (const auto& subset : GetLayoutSubsets (layoutBook)) {
const NavItemChildren& layouts = GetLayoutsFromSubset (subset.guid, layoutBook);
// ...
}
Note, this code works in ARCHICAD 22.2019-01-06 07:24 PM
2019-01-09 12:36 PM