Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Anonymous
in reply to: bradeneuropeArthur

Hey, I had a follow-up question if possible. I understand that .FileSaveCounter is a read-only file but the code you supplied says that as long as the value of .FileSaveCounter is 0, I can't perform the rest of my code. I can't flip it the other way because my file save counter is never 0. Curently it's at 33 or 34, something like that. Do you know a way to edit the code you supplied or perhaps have the counter reset to 0 at the beginning of the code? Here's my bit so far, thank you for your help.

Public Sub Main()
Dim doc = ThisDoc.Document

doc.FileSaveCount = 0
MsgBox(doc.FileSaveCounter)

If doc.FileSaveCounter = 0 Then
	
	
	Dim modelname As String
	Dim odoc As Document


	iLogicForm.Show("Save Drawing")

	modelname = iProperties.Value("Summary", "Title")

	If saved = True Then
		ThisDoc.Document.saveasinventordwg("[MACHINE DRAWING FILEPATH]" & modelname & ".dwg", True)
	
		oFileName = ThisDoc.FileName(False) 'without extension
		oRevNum = iProperties.Value("Project", "Revision Number")
		oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
		oDocument = ThisApplication.ActiveDocument
		oContext = ThisApplication.TransientObjects.CreateTranslationContext
		oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
		oOptions = ThisApplication.TransientObjects.CreateNameValueMap
		oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

		oOptions.Value("All_Color_AS_Black") = 1
		oOptions.Value("Remove_Line_Weights") = 1
		oOptions.Value("Vector_Resolution") = 400
		oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets

		'get PDF target folder path
		oFolder = "[PDF DRAWING FILEPATH]"

		'Check for the PDF folder and create it if it does not exist
		If Not System.IO.Directory.Exists(oFolder) Then
	   		System.IO.Directory.CreateDirectory(oFolder)
		End If

		'Set the PDF target file name
		oDataMedium.FileName = oFolder & "\" & modelname & ".pdf"
	
		'Publish document
		oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
	
		ThisApplication.Documents.Open("[MACHINE DRAWING FILEPATH]" & modelname & ".dwg")
		ThisApplication.CommandManager.ControlDefinitions.Item("VaultCheckinTop").Execute2(False)

	Else
		Logger.Debug("saved?: " & saved)
		Exit Sub

	End If

	saved = False

End If
End Sub