Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

close all opened drawings

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
m.magini
241 Views, 2 Replies

close all opened drawings

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

 

Labels (1)
2 REPLIES 2
Message 2 of 3
Andrii_Humeniuk
in reply to: m.magini

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 - Leading design engineer

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

Message 3 of 3
m.magini
in reply to: m.magini

Thanks, it works for me too now.

Thank you

Bye

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report