Message 1 of 6
Project File Mapping

Not applicable
09-30-2016
08:12 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
All,
I have the code stated below, I was hoping you could help with a few things:
Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 24470 StartFragment: 314 EndFragment: 24438 StartSelection: 314 EndSelection: 314SyntaxEditor Code Snippet
Sub Main iLogicVb.RunRule("CustOn") 'query user MessageBox.Show("Would you like to print to the current Project File?: ", "iLogic Question",MessageBoxButtons.YesNo,MessageBoxIcon.Question) 'set condition based on answer If question = vbYes Then oFileName = ThisDoc.FileName(False) 'without extension oRevNum = iProperties.Value("Project", "Revision Number") Else End If ' Get the PDF translator Add-In. Dim PDFAddIn As TranslatorAddIn PDFAddIn = ThisApplication.ApplicationAddIns.ItemById _ ("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") 'Set a reference to the active document (the document to be published). Dim oDocument As Document oDocument = ThisApplication.ActiveDocument Dim oContext As TranslationContext oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = kFileBrowseIOMechanism 'Create a NameValueMap object Dim oOptions As NameValueMap oOptions = ThisApplication.TransientObjects.CreateNameValueMap ' Create a DataMedium object Dim oDataMedium As DataMedium oDataMedium = ThisApplication.TransientObjects.CreateDataMedium ' Check whether the translator has 'SaveCopyAs' options If PDFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then ' Options for drawings... 'oOptions.Value("Launch_Viewer") = launchviewer oOptions.Value("All_Color_AS_Black") = 1 'oOptions.Value("Sheet_Range") = ThisApplication.PrintRangeEnum.kPrintAllSheets oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets 'oOptions.Value("Remove_Line_Weights") = 0 'oOptions.Value("Vector_Resolution") = 400 'oOptions.Value("Custom_Begin_Sheet") = 2 'oOptions.Value("Custom_End_Sheet") = 4 End If 'get PDF target folder path oFolder = Left(ThisDoc.Path, InStrRev(oPath, "\")) & "PDF" '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 Dim fname As String fname = oFolder & "\" & oFileName & " Rev" & oRevNum & "-CUST.pdf" oDataMedium.FileName = fname 'Publish document. If System.IO.Directory.Exists(fname) Then System.IO.File.Delete(fname) MessageBox.Show("Earlier PDF deleted! ", "Inventor") End If PDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) MessageBox.Show("Print Created in default Projects - " & fname, "Inventor") End Sub
First I was hoping I could have the project name added after the question in the project file. Also I was going to try and set up a browser the would pop up if you were to hit no where you can manually map the file where you'd like it to save?
Any ideas? I am pretty new to all of this and its getting a little too complex for my experience.