rollback event... command stack is empty

 

I have a program that opens DFT files, switches to a specified Sheet, and exports a DXF file. All works well untill about 20 or so files and then Solid Edge crashes. The crash log includes this:

The rollback event cannot allow saving of the active document because the command stack is empty.

Please help.

Terry

 

Posted by: Terry Tyson
Post date: 6/30/2010 4:34:37 AM

18 REPLIES

RE: rollback event...command stack is empty

I had a similar problem before and the easiest thing I did was maintain a count and have the program exit Solid Edge and restart after so many files were processed. It slowed it a bit but I ran it overnight so the extra time was not noticed.

 

Posted by: Bill Ledbetter
Post date: 6/30/2010 4:40:57 AM

RE: rollback event... command stack is empty

 

Bill,

 

Thanks for the reply. Unfortunately that is not an option for me. I will let you know if something comes up.

 

Terry

 

Posted by: Terry Tyson
Post date: 7/1/2010 3:18:45 AM

RE: rollback event... command stack is empty

If I remember correctly, GTAC determined that the constant opening and closing of files was causing the problem. It became a memory issue. They told me once you close Solid Edge completely, it frees the memory back to the O/S.

 

I also recall getting that same error one time when programmatically calling files from outside of Insight. Are you using Insight?

 

Posted by: Bill Ledbetter
Post date: 7/1/2010 3:55:17 AM

RE: rollback event... command stack is empty

No, I'm not using Insight.

 

I tried using Marshal.ReleaseComObject() but I'm still getting the same problem. It seems like there should be some way to fix this. Smiley Sad

 

Posted by: Terry Tyson
Post date: 7/1/2010 11:47:49 AM

RE: rollback event... command stack is empty

Well, I haven't realy solved this problem yet but I do have a work arround. Closing the drawings is where the problem comes in so I changed it to leave all the drawings open until all files have been processed and then go through and close them all. I don't realy like leaving them open like that but it works for now. I will still try to figure out how to close the files as I go without crashing SE. I've even use ReleaseComObject but it still crashes after a certain number of files. I think it is a .NET problem. I may spend time learning C++ to see if this will solve the problem since, as I understand it, VC++ is not .NET.

 

Posted by: Terry Tyson
Post date: 7/8/2010 3:47:00 AM

RE: rollback event... command stack is empty

 

I haven't helped anyone in a long time so I thought I'd jump in here.  I've attached the source code and DFT2DXF.exe.  Simply call the .exe and pass the folder path that contains the drafts to convert.  See if this code works better than the .NET code.  Regarding dealing with COM objects, you're much better off using pure C++.  I just threw this together so it's by no means ideal production code.  Demo only...// DFT2DXF.cpp : Defines the entry point for the console application.//#include "stdafx.h"HRESULT ConvertDraftToDxf(SolidEdgeFramework::ApplicationPtr pApplication, CString& strDftPath);int _tmain(int argc, _TCHAR* argv[]){ HRESULT hr = S_OK; WIN32_FIND_DATA findData; HANDLE hFile; // Handle to file CString folderPath; CString strPath; CString strPattern; SolidEdgeFramework::ApplicationPtr pApplication = NULL; if (argc != 2) { wprintf(L"Please specify a folder."); return 1; } folderPath = argv[1]; CoInitialize(NULL); strPattern = folderPath + L"\\*.dft"; hFile = ::FindFirstFile(strPattern, &findData); if (hFile != INVALID_HANDLE_VALUE) { /* We found files. Start Solid Edge */ IfFailGo(pApplication.CreateInstance("SolidEdge.Application")); pApplication->Visible = VARIANT_TRUE; pApplication->DisplayAlerts = VARIANT_FALSE; do { strPath.Empty(); strPath = folderPath + L"\\" + findData.cFileName; IfFailGo(ConvertDraftToDxf(pApplication, strPath)); pApplication->DoIdle(); } while(::FindNextFile(hFile, &findData) == TRUE); // Close handle ::FindClose(hFile); }Error: if (pApplication != NULL) { pApplication->Quit(); pApplication = NULL; } CoUninitialize(); return 0;}HRESULT ConvertDraftToDxf(SolidEdgeFramework::ApplicationPtr pApplication, CString& strDftPath){ HRESULT hr = S_OK; SolidEdgeFramework:Smiley Very HappyocumentsPtr pDocuments = pApplication->Documents; SolidEdgeFramework:Smiley FrustratedolidEdgeDocumentPtr pDocument = NULL; SolidEdgeDraft:Smiley Very HappyraftDocumentPtr pDraft = NULL; SolidEdgeDraft:Smiley FrustratedectionsPtr pSections = NULL; SolidEdgeDraft:Smiley FrustratedectionPtr pSection = NULL; SolidEdgeDraft:Smiley FrustratedectionSheetsPtr pSectionSheets = NULL; SolidEdgeDraft:Smiley FrustratedheetPtr pSheet = NULL; SolidEdgeDraft:Smiley FrustratedheetWindowPtr pSheetWindow = NULL; CString strDxfPath = strDftPath + ".dxf"; _bstr_t bstrDftPath(strDftPath); _bstr_t bstrDxfPath(strDxfPath); pDocument = pDocuments->Open(bstrDftPath); IfFailGo(pApplication->DoIdle()); if (pDocument != NULL) { pDraft = pDocument; if (pDraft != NULL) { pSections = pDraft->Sections; pSection = pSections->WorkingSection; pSectionSheets = pSection->Sheets; for (LONG i = 1; i Count; i++) { pSheet = pSectionSheets->Item(i); IfFailGo(pSheet->Activate()); pSheetWindow = pApplication->ActiveWindow; if (pSheetWindow != NULL) { IfFailGo(pSheetWindow->FitEx(SolidEdgeDraft::igFitAll)); } } IfFailGo(pApplication->DoIdle()); IfFailGo(pDraft->SaveAs(bstrDxfPath)); IfFailGo(pApplication->DoIdle()); } }Error: pSheetWindow = NULL; pSheet = NULL; pSectionSheets = NULL; pSection = NULL; pSections = NULL; pDraft = NULL; if (pDocument != NULL) { pDocument->Close(VARIANT_FALSE); pDocument = NULL; } pDocuments = NULL; return S_OK;}

 

Posted by: Jason Newell
Post date: 7/8/2010 3:05:20 PM

RE: rollback event... command stack is empty

I just realized that I didn't go after a specific sheet name like you were. I guess I missed that part in your code. Give it a try anyways.

 

Posted by: Jason Newell
Post date: 7/8/2010 3:10:15 PM

RE: rollback event... command stack is empty

 

I felt bad about missing the sheet name requirement so I updated it to export all working sheets to .dxf.  Use this attachment when you test.

 

Posted by: Jason Newell
Post date: 7/8/2010 3:21:42 PM

RE: rollback event... command stack is empty

Thanks Jason. I have to prepare for a demo at 10:00 of the various things we have so far but I will definately be checking out your code. I had a hunch that I would need to get away from .NET for things like this. The programmers here all use VB so that is what I went with but I will be looking into C++.

 

Posted by: Terry Tyson
Post date: 7/9/2010 3:20:08 AM