We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2019-09-29 04:11 PM - last edited on 2022-09-29 10:14 AM by Daniel Kassai
Solved! Go to Solution.
2019-09-30 12:30 PM
static GS::UniString DrawLevel (USize level) { GS::UniString string; for (UIndex ii = 0; ii < level; ++ii) string += '\t'; return string; } static GS::UniString DrawItem (const GS::UniString& name, USize level) { return DrawLevel (level) + name + '\n'; } static GS::UniString DrawFolder (const GS::UniString& folderName, const GS::HashTable<GS::UniString, GS::Array<GS::UniString>>& subFoldersInFolder, const GS::HashTable<GS::UniString, GS::Array<GS::UniString>>& favoritesInFolder, USize level = 0) { GS::UniString string = DrawItem (folderName, level); string.Insert (string.GetLength () - 1, " ["); ++level; if (subFoldersInFolder.ContainsKey (folderName)) { for (const GS::UniString& subFolder : subFoldersInFolder[folderName]) { string += DrawFolder (subFolder, subFoldersInFolder, favoritesInFolder, level); } } if (favoritesInFolder.ContainsKey (folderName)) { for (const GS::UniString& favorite : favoritesInFolder[folderName]) { string += DrawItem (favorite, level); } } string.Insert (string.GetLength () - 1, " ]"); return string; } static GSErrCode DrawFavoritesTree () { API_ToolBoxInfo toolboxInfo = {}; GSErrCode err = NoError; err = ACAPI_Environment (APIEnv_GetToolBoxInfoID, &toolboxInfo, (void*)(GS::IntPtr) true); if (err != NoError) return err; // Get all favorites GS::HashTable<GS::UniString, GS::Array<GS::UniString>> favoritesInFolder; GS::Array<API_FavoriteFolderHierarchy> folders; for (Int32 ii = 0; ii < toolboxInfo.nTools; ++ii) { const API_ToolBoxItem& toolBoxItem = (*toolboxInfo.data)[ii]; GS::Array<API_FavoriteFolderHierarchy> foldersForTool; GS::Array<GS::UniString> favoriteNames; ACAPI_Favorite_GetNum (toolBoxItem.typeID, toolBoxItem.variationID, nullptr, &foldersForTool, &favoriteNames); folders.Append (foldersForTool); for (UIndex jj = 0; jj < favoriteNames.GetSize (); ++jj) { favoritesInFolder.Retrieve (foldersForTool[jj].GetLast ()).Push (favoriteNames[jj]); } } BMKillHandle ((GSHandle *)&toolboxInfo.data); if (folders.IsEmpty ()) return APIERR_GENERAL; // Build tree from favorites GS::HashTable<GS::UniString, GS::Array<GS::UniString>> subFoldersInFolder; for (const API_FavoriteFolderHierarchy& folderHierarchy : folders) { GS::Optional<GS::UniString> parentFolderName; for (const GS::UniString& folderName : folderHierarchy) { if (parentFolderName.HasValue ()) { GS::Array<GS::UniString>& subFolders = subFoldersInFolder.Retrieve (parentFolderName.Get ()); if (!subFolders.Contains (folderName)) subFolders.Push (folderName); } subFoldersInFolder.Retrieve (folderName); parentFolderName = folderName; } } // Sort folders and favorites in tree for (GS::Array<GS::UniString>& subFolders : subFoldersInFolder.Values ()) { GS::Sort (subFolders.Begin (), subFolders.End ()); } for (GS::Array<GS::UniString>& favorites : favoritesInFolder.Values ()) { GS::Sort (favorites.Begin (), favorites.End ()); } // Draw tree into the Report Window: const GS::UniString rootFolderName = folders.GetFirst ().GetFirst (); ACAPI_WriteReport (DrawFolder (rootFolderName, subFoldersInFolder, favoritesInFolder), false); return err; }
2019-09-30 12:30 PM
static GS::UniString DrawLevel (USize level) { GS::UniString string; for (UIndex ii = 0; ii < level; ++ii) string += '\t'; return string; } static GS::UniString DrawItem (const GS::UniString& name, USize level) { return DrawLevel (level) + name + '\n'; } static GS::UniString DrawFolder (const GS::UniString& folderName, const GS::HashTable<GS::UniString, GS::Array<GS::UniString>>& subFoldersInFolder, const GS::HashTable<GS::UniString, GS::Array<GS::UniString>>& favoritesInFolder, USize level = 0) { GS::UniString string = DrawItem (folderName, level); string.Insert (string.GetLength () - 1, " ["); ++level; if (subFoldersInFolder.ContainsKey (folderName)) { for (const GS::UniString& subFolder : subFoldersInFolder[folderName]) { string += DrawFolder (subFolder, subFoldersInFolder, favoritesInFolder, level); } } if (favoritesInFolder.ContainsKey (folderName)) { for (const GS::UniString& favorite : favoritesInFolder[folderName]) { string += DrawItem (favorite, level); } } string.Insert (string.GetLength () - 1, " ]"); return string; } static GSErrCode DrawFavoritesTree () { API_ToolBoxInfo toolboxInfo = {}; GSErrCode err = NoError; err = ACAPI_Environment (APIEnv_GetToolBoxInfoID, &toolboxInfo, (void*)(GS::IntPtr) true); if (err != NoError) return err; // Get all favorites GS::HashTable<GS::UniString, GS::Array<GS::UniString>> favoritesInFolder; GS::Array<API_FavoriteFolderHierarchy> folders; for (Int32 ii = 0; ii < toolboxInfo.nTools; ++ii) { const API_ToolBoxItem& toolBoxItem = (*toolboxInfo.data)[ii]; GS::Array<API_FavoriteFolderHierarchy> foldersForTool; GS::Array<GS::UniString> favoriteNames; ACAPI_Favorite_GetNum (toolBoxItem.typeID, toolBoxItem.variationID, nullptr, &foldersForTool, &favoriteNames); folders.Append (foldersForTool); for (UIndex jj = 0; jj < favoriteNames.GetSize (); ++jj) { favoritesInFolder.Retrieve (foldersForTool[jj].GetLast ()).Push (favoriteNames[jj]); } } BMKillHandle ((GSHandle *)&toolboxInfo.data); if (folders.IsEmpty ()) return APIERR_GENERAL; // Build tree from favorites GS::HashTable<GS::UniString, GS::Array<GS::UniString>> subFoldersInFolder; for (const API_FavoriteFolderHierarchy& folderHierarchy : folders) { GS::Optional<GS::UniString> parentFolderName; for (const GS::UniString& folderName : folderHierarchy) { if (parentFolderName.HasValue ()) { GS::Array<GS::UniString>& subFolders = subFoldersInFolder.Retrieve (parentFolderName.Get ()); if (!subFolders.Contains (folderName)) subFolders.Push (folderName); } subFoldersInFolder.Retrieve (folderName); parentFolderName = folderName; } } // Sort folders and favorites in tree for (GS::Array<GS::UniString>& subFolders : subFoldersInFolder.Values ()) { GS::Sort (subFolders.Begin (), subFolders.End ()); } for (GS::Array<GS::UniString>& favorites : favoritesInFolder.Values ()) { GS::Sort (favorites.Begin (), favorites.End ()); } // Draw tree into the Report Window: const GS::UniString rootFolderName = folders.GetFirst ().GetFirst (); ACAPI_WriteReport (DrawFolder (rootFolderName, subFoldersInFolder, favoritesInFolder), false); return err; }
2019-10-01 01:23 AM
2019-10-01 11:03 AM
poco2013 wrote:Hi,
In the same vane as above :
I tried compiling the Favorites_Test example and got a huge number of errors -- 973 errors -- basically could not find the standard header files such as: error.h, float.h, correct.h, stdef.h, stdin.h --- etc. etc.
All other examples that I tried compile fine without modification. Obviously something was missed in Favorites_Test. Using Download API Development Kit 23 3006 on Windows 10 with VS 2017
What do I need to fix?
2019-10-02 12:45 AM
2019-10-02 10:18 AM
poco2013 wrote:Bit harsh – Tamas gave you some good leads to check out.
Thanks for the non-response
2019-10-02 11:38 AM
poco2013 wrote:Which edition of VS 2017 did you install? The Community Edition usually requires an additional download of the Windows SDK.
In the same vane as above :
I tried compiling the Favorites_Test example and got a huge number of errors -- 973 errors -- basically could not find the standard header files such as: error.h, float.h, correct.h, stdef.h, stdin.h --- etc. etc.
All other examples that I tried compile fine without modification. Obviously something was missed in Favorites_Test. Using Download API Development Kit 23 3006 on Windows 10 with VS 2017
What do I need to fix?
2019-10-02 01:45 PM
2020-07-22 12:50 PM
Tibor wrote:
Hi Dushyant,
The current version of Python API does not able to retrieve the folderhierarchy of the favorites.
Currently it’s available only via C++ API. The code below draws the hierarchy of the favorites to the Report window, simply call DrawFavoritesTree method.
(Note, the code was written by using AC23 API.)
static GS::UniString DrawLevel (USize level) { GS::UniString string; for (UIndex ii = 0; ii < level; ++ii) string += '\t'; return string; } static GS::UniString DrawItem (const GS::UniString& name, USize level) { return DrawLevel (level) + name + '\n'; } static GS::UniString DrawFolder (const GS::UniString& folderName, const GS::HashTable<GS::UniString, GS::Array<GS::UniString>>& subFoldersInFolder, const GS::HashTable<GS::UniString, GS::Array<GS::UniString>>& favoritesInFolder, USize level = 0) { GS::UniString string = DrawItem (folderName, level); string.Insert (string.GetLength () - 1, " ["); ++level; if (subFoldersInFolder.ContainsKey (folderName)) { for (const GS::UniString& subFolder : subFoldersInFolder[folderName]) { string += DrawFolder (subFolder, subFoldersInFolder, favoritesInFolder, level); } } if (favoritesInFolder.ContainsKey (folderName)) { for (const GS::UniString& favorite : favoritesInFolder[folderName]) { string += DrawItem (favorite, level); } } string.Insert (string.GetLength () - 1, " ]"); return string; } static GSErrCode DrawFavoritesTree () { API_ToolBoxInfo toolboxInfo = {}; GSErrCode err = NoError; err = ACAPI_Environment (APIEnv_GetToolBoxInfoID, &toolboxInfo, (void*)(GS::IntPtr) true); if (err != NoError) return err; // Get all favorites GS::HashTable<GS::UniString, GS::Array<GS::UniString>> favoritesInFolder; GS::Array<API_FavoriteFolderHierarchy> folders; for (Int32 ii = 0; ii < toolboxInfo.nTools; ++ii) { const API_ToolBoxItem& toolBoxItem = (*toolboxInfo.data)[ii]; GS::Array<API_FavoriteFolderHierarchy> foldersForTool; GS::Array<GS::UniString> favoriteNames; ACAPI_Favorite_GetNum (toolBoxItem.typeID, toolBoxItem.variationID, nullptr, &foldersForTool, &favoriteNames); folders.Append (foldersForTool); for (UIndex jj = 0; jj < favoriteNames.GetSize (); ++jj) { favoritesInFolder.Retrieve (foldersForTool[jj].GetLast ()).Push (favoriteNames[jj]); } } BMKillHandle ((GSHandle *)&toolboxInfo.data); if (folders.IsEmpty ()) return APIERR_GENERAL; // Build tree from favorites GS::HashTable<GS::UniString, GS::Array<GS::UniString>> subFoldersInFolder; for (const API_FavoriteFolderHierarchy& folderHierarchy : folders) { GS::Optional<GS::UniString> parentFolderName; for (const GS::UniString& folderName : folderHierarchy) { if (parentFolderName.HasValue ()) { GS::Array<GS::UniString>& subFolders = subFoldersInFolder.Retrieve (parentFolderName.Get ()); if (!subFolders.Contains (folderName)) subFolders.Push (folderName); } subFoldersInFolder.Retrieve (folderName); parentFolderName = folderName; } } // Sort folders and favorites in tree for (GS::Array<GS::UniString>& subFolders : subFoldersInFolder.Values ()) { GS::Sort (subFolders.Begin (), subFolders.End ()); } for (GS::Array<GS::UniString>& favorites : favoritesInFolder.Values ()) { GS::Sort (favorites.Begin (), favorites.End ()); } // Draw tree into the Report Window: const GS::UniString rootFolderName = folders.GetFirst ().GetFirst (); ACAPI_WriteReport (DrawFolder (rootFolderName, subFoldersInFolder, favoritesInFolder), false); return err; }FavoritesTreeInReportWindow.png
2020-07-22 01:08 PM
dushyant wrote:Unfortunately my answer is no. Currently (AC24.3010) the Python API is not able to access any information related to the Favorites.
Does the current Python API release (with AC-24) include anything to access the 'Favorites'?