iLogic code to save when a file is checked in

iLogic code to save when a file is checked in

Phoebe.Carter-PowellR3XJ8
Explorer Explorer
388 Views
0 Replies
Message 1 of 1

iLogic code to save when a file is checked in

Phoebe.Carter-PowellR3XJ8
Explorer
Explorer

Hi All,

 

I currently use some iLogic code to save a drawing as a pdf in a specified location everytime the drawing is saved. this is:

 

Sub Main()
FileName = ThisDoc.FileName(True) 'with extension

FileExtension = Right(FileName, 3)

If FileExtension = "idw" Then
Save_As_PDF
Else If FileExtension = "dwg" Then
Save_As_PDF
Else
ErrorMessage
End If
End Sub

Sub Save_As_PDF

oPath = ThisDoc.Path
oFileName = ThisDoc.FileName(False)
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

WorkspacePath = ThisDoc.WorkspacePath() 'Gets the workspace path

WorkspacePathLength = Len(WorkspacePath) 'Gets the length of the workspace path string

PathOnly = ThisDoc.Path 'Gets just the path of the file

DirectoryPath = Strings.Right(PathOnly, PathOnly.Length - WorkspacePathLength) 'Removes the workspace path from fullpath

PDFPath = "C:\PDF Save" &DirectoryPath 'Sets the directory that the pdf should be saved in
PDFName = PDFPath & "\" & ThisDoc.FileName(False) & ".pdf" 'Saves the pdf in the desired location

oDataMedium.FileName = PDFName

oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets

If Not System.IO.Directory.Exists(PDFPath) Then 'checks to see if that directory exists, if not, it is created
System.IO.Directory.CreateDirectory(PDFPath)
End If

oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
End Sub


Sub ErrorMessage
i = MessageBox.Show("This Is Not a drawing File. No PDF will be created.", "Create PDF", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
End Sub

 

However I want to change this so it is only saved as pdf/updated when the drawing is checked in, how can I do this?

 

Many Thanks

0 Likes
389 Views
0 Replies
Replies (0)