Re-open with defer update error

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I am trying to create a code which will eventually batch plot Inventor drawings. If a drawing is open I want it to be re-opened with defer updates checked. I don't have problems when I open other referenced documents, but I do get problems when I close and re-open.
Basically I want to make sure that the drawings are not updated when my batch plot code opens them.
I will show a small portion of my code, to keep it simple. The code gets the current assembly model referenced on the drawing and iterates through all the files.
oDoc=ThisDoc.Document 'check file type If oDoc.DocumentType = kDrawingDocumentObject Then Dim oNVM As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap oNVM.Add("DeferUpdates", True) 'get the documentname of the current document oCurFileName = ThisApplication.ActiveDocument.FullDocumentName ThisApplication.ActiveDocument.Close(True) Dim oCurDoc as document oCurDoc = ThisApplication.Documents.OpenWithOptions(oCurFileName,oNVM) Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisDrawing.ModelDocument Dim oRefDoc As Document Dim oAllRefDocs As DocumentsEnumerator oAllRefDocs = oAsmDoc.AllReferencedDocuments For Each oRefDoc In oAllRefDocs dwgPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) - 3) & "dwg" 'Perform actions with drawings below this comment...... 'MessageBox.Show(dwgpathname, "DWG Path") Next End If
If I leave the red text out of the code, the code works. I hope someone can help me on the right track again.
Error in rule: test3, in document: Unknown Document
Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))