Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
HI, I am able to open and SAVE as PDF for the DWG that are linked to an Assembly. But I am not able to get the REV # that is in the Custom iproperty of each DWG.
I used the below line in many ways but no success:
iProperties.Value("Custom", "REV #")
But since I am running the RULE from an assembly. The RULE does not pick up the REV# that is in the DWG's "Custom" iproperty. Looks like I am missing a piece of code that will do it. I plan to use that REV# and put it in the PDF file name that is generated. Can anyone help me? Here is my entire code:
Sub Main() Dim oDoc As Document oDoc = ThisDoc.Document oDocName = System.IO.Path.GetDirectoryName(oDoc.FullFileName) & "\" & System.IO.Path.GetFileNameWithoutExtension(oDoc.FullFileName) ' oFile = GetFileNameWithoutExtension(oDoc.FullFileName) 'MessageBox.Show(oFile, "Title") If Not (oDoc.DocumentType = kAssemblyDocumentObject Or oDoc.DocumentType = kDrawingDocumentObject) Then MessageBox.Show("Please run this rule from the assembly or drawing files.", "iLogic") Exit Sub End If 'get user input If MessageBox.Show ( _ "This will create a PDF file for all of the files referenced by this document that have drawings files." _ & vbLf & "This rule expects that the drawing file shares the same name and location as the component." _ & vbLf & " " _ & vbLf & "Are you sure you want to create PDF Drawings for all of the referenced documents?" _ & vbLf & "This could take a while.", "iLogic - Batch Output PDFs ",MessageBoxButtons.YesNo) = vbNo Then Exit Sub End If Dim PDFAddIn As TranslatorAddIn Dim oContext As TranslationContext Dim oOptions As NameValueMap Dim oDataMedium As DataMedium Call ConfigurePDFAddinSettings(PDFAddIn, oContext, oOptions, oDataMedium) 'Call GetPropertySample '----------------------------------------- ' Folder Selection Dim oFolder As String = ThisDoc.Path Dim Dialog = New FolderBrowserDialog() Dialog.SelectedPath = oFolder Dialog.ShowNewFolderButton = True Dialog.Description = "Select Or Create A Folder Where You want PDFs TO be Created" If DialogResult.OK = Dialog.ShowDialog() Then oFolder = Dialog.SelectedPath 'MessageBox.Show(oFolder, "Title") End If ' ------------------ ' If Not System.IO.Directory.Exists(oFolder) Then ' System.IO.Directory.CreateDirectory(oFolder) ' End If ' '- - - - - - - - - - - - -Component Drawings - - - - - - - - - - - - Dim oRefDoc As Document Dim oDrawDoc As DrawingDocument Dim oPenDoc As Inventor.DrawingDocument For Each oRefDoc In oDoc.AllReferencedDocuments oBaseName = System.IO.Path.GetFileNameWithoutExtension(oRefDoc.FullFileName) oPathAndName = System.IO.Path.GetDirectoryName(oRefDoc.FullFileName) & "\" & oBaseName If(System.IO.File.Exists(oPathAndName & ".dwg")) Then oDrawDoc = ThisApplication.Documents.Open(oPathAndName & ".dwg", True) 'NEED HELP HERE IN GETTING THE REV# FROM THE CUSTOM IPROPERTY OF THE DWG THAT IS OPEN IN ABOVE LINE oDataMedium.FileName = oFolder & "\" & oBaseName & ".pdf" Call PDFAddIn.SaveCopyAs(oDrawDoc, oContext, oOptions, oDataMedium) oDrawDoc.Close(True) Else oNoDwgString = oNoDwgString & vbLf & dwgPathName End If Next ' '- - - - - - - - - - - - -xx - - - - - - - - - - - - - - - - - - - - ' '- - - - - - - - - - - - -Top Level Drawing - - - - - - - - - - - - oBaseName = System.IO.Path.GetFileNameWithoutExtension(oDoc.FullFileName) oPathAndName = System.IO.Path.GetDirectoryName(oDoc.FullFileName) & "\" & oBaseName oDataMedium.FileName = oFolder & "\" & oBaseName & ".pdf" If oDoc.DocumentType = kAssemblyDocumentObject Then oDrawDoc = ThisApplication.Documents.Open(oPathAndName & ".dwg", False) Call PDFAddIn.SaveCopyAs(oDrawDoc, oContext, oOptions, oDataMedium) oDrawDoc.Close ElseIf oDoc.DocumentType = kDrawingDocumentObject Then Call PDFAddIn.SaveCopyAs(oDoc, oContext, oOptions, oDataMedium) End If ' '- - - - - - - - - - - - - MessageBox.Show("New Files Created in: " & vbLf & oFolder, "iLogic") 'MsgBox("Files found without drawings: " & vbLf & oNoDwgString) Shell("explorer.exe " & oFolder,vbNormalFocus) End Sub Sub ConfigurePDFAddinSettings(ByRef PDFAddIn As TranslatorAddIn, ByRef oContext As TranslationContext, ByRef oOptions As NameValueMap, ByRef oDataMedium As DataMedium) PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism oOptions = ThisApplication.TransientObjects.CreateNameValueMap oOptions.Value("All_Color_AS_Black") = 1 oOptions.Value("Remove_Line_Weights") = 0 oOptions.Value("Vector_Resolution") = 400 oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets oOptions.Value("Custom_Begin_Sheet") = 1 oOptions.Value("Custom_End_Sheet") = 1 oDataMedium = ThisApplication.TransientObjects.CreateDataMedium End Sub
@ nigel.hay @Curtis_W. @MechMachineMan
Solved! Go to Solution.