Why does going through the project files take so long?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, I am creating a palette in which I am displaying all projects and their structure (folders and drawing files) to the user.
So when iterating all projects in the active hub and only getting their names and the names of their sub folders and files it takes a very long time 1-3minutes on small hubs. Is there a reason for this? Is there a way to get the data faster?
Demo code:
#include <Core/CoreAll.h>
#include <Fusion/FusionAll.h>
#include <CAM/CAMAll.h>
using namespace adsk::core;
using namespace adsk::fusion;
using namespace adsk::cam;
Ptr<Application> app;
Ptr<UserInterface> ui;
void IterateFusionFolder(const Ptr<DataFolder>& folder)
{
for (const auto& subFolder : folder->dataFolders())
{
const auto name = subFolder->name();
IterateFusionFolder(subFolder);
}
for (const auto& file : folder->dataFiles())
{
const auto extension = file->fileExtension();
if (extension != "f2d")
continue;
const auto name = file->name();
}
}
extern "C" XI_EXPORT bool run(const char* context)
{
app = Application::get();
if (!app)
return false;
ui = app->userInterface();
if (!ui)
return false;
const auto projects = Application::get()->data()->activeHub()->dataProjects();
for (const auto& project : projects)
{
IterateFusionFolder(project->rootFolder());
}
return true;
}
extern "C" XI_EXPORT bool stop(const char* context)
{
if (ui)
{
ui->messageBox("Stop addin");
ui = nullptr;
}
return true;
}
#ifdef XI_WIN
#include <windows.h>
BOOL APIENTRY DllMain(HMODULE hmodule, DWORD reason, LPVOID reserved)
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
#endif // XI_WIN