Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I have an issue with exporting file while saving a design.
I export the design using the following C++ script:
#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; // Event handler for the documentSaved event. class MyDocumentSavedEventHandler : public adsk::core::DocumentEventHandler { public: void notify(const Ptr<DocumentEventArgs>& eventArgs) override { // get active design Ptr<Product> product = app->activeProduct(); if (!product) return; Ptr<Design> design = product; if (!design) return; // get all components in this design Ptr<Components> comps = design->allComponents(); if (!comps) return; // create a single exportManager instance Ptr<ExportManager> exportMgr = design->exportManager(); if (!exportMgr) return; // export the component one by one with a specified format size_t count = comps->count(); for (size_t index = 0; index < count; ++index) { Ptr<Component> comp = comps->item(index); std::string name = comp->name(); std::string fileName = "/Users/ruediweber/FusionExport/test/" ; fileName.append(name); // export the component with STP format Ptr<STEPExportOptions> stepOptions = exportMgr->createSTEPExportOptions(fileName, comp); if (!stepOptions) continue; exportMgr->execute(stepOptions); } return; } } documentSaved_; extern "C" XI_EXPORT bool run(const char* context) { app = Application::get(); if (!app) return false; ui = app->userInterface(); if (!ui) return false; Ptr<DocumentEvent> documentSaved = app->documentSaved(); if (!documentSaved) return false; documentSaved->add(&documentSaved_); 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
The file contains the actual data from the current version, but the file name becomes the name of the preveous version.
Change the Design:
Bevor saving:
Saved file with new Version v103
File named with the previous version.
Fiel contains the current content:
Is there a way around this behaviour?
On the Step file it would be possible to manipulate the file name. In a F3D file this could be some kind of misleading.
Solved! Go to Solution.