I have some drawings open in my inventor session.
I'd to run a macro saved in one file called "rule".dwg
macro simply gets the file name, display it with message box
and then close the "processed" file if it is not the "rule" one.
At th end only "rule" drawing will remain open.
I have some proble with close command line
oDocument.Close does nothing.
ThisApplication.Document.close returns error
Thanks for helping
' Declaration Dim oDocument As DrawingDocument ' Starting cycle For Each oDocument In ThisApplication.Documents.VisibleDocuments ' Get file name Dim myoutputname As String myoutputname = System.IO.Path.GetFileNameWithoutExtension(oDocument.FullFileName) 'Code If myoutputname <> "rule" Then MessageBox.Show(myoutputname, "Title") 'oDocument.Close'???????? Else MessageBox.Show("This file contains the rule", "Title") End If 'end for each cycle Next
Solved! Go to Solution.
Solved by Andrii_Humeniuk. Go to Solution.
Hi @m.magini . In my case the code works fine. Maybe it's because I'm specifying True or False for the SkipSave value in the Close() method.
' Declaration
Dim oDocument As DrawingDocument
' Starting cycle
For Each oDocument In ThisApplication.Documents.VisibleDocuments
' Get file name
Dim myoutputname As String
myoutputname = System.IO.Path.GetFileNameWithoutExtension(oDocument.FullFileName)
'Code
If myoutputname <> "rule" Then
MessageBox.Show(myoutputname, "Title")
'oDocument.Close'????????
Else
MessageBox.Show("This file contains the rule", "Title")
End If
'end for each cycle
oDocument.Close(True)
Next
Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor
LinkedIn | My free Inventor Addin | My Repositories
Did you find this reply helpful ? If so please use the Accept as Solution/Like.
Can't find what you're looking for? Ask the community or share your knowledge.