Re-open with defer update error

Re-open with defer update error

Anonymous
Not applicable
321 Views
1 Reply
Message 1 of 2

Re-open with defer update error

Anonymous
Not applicable

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))

 

0 Likes
322 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable

Basically, what I found out is that somehow my code still refers to the previously opened document. And it seems I cannot set the reference to the newly opened document. Perhaps anyone has ideas to set the reference to the just opened document or somehow make it "ThisDrawing"?

0 Likes