Message 1 of 5
Description Iproperty behind export file name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I'm using the code below to batch export my drawings, which works very good.
Now I want to add the description of a part behind the file name.
I'm convinced I should add 0description behind this part of the code but it doesn't work.
Can someone help me in this?
oPDFDataMedium.FileName = oFolder + "\" + oFileName + "pdf"
Sub Main
'get the main assembly document
Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument
'run the Sub below on the main assembly
ExportDrawingToPDF(oADoc)
'Peruse each document in generated Documents list.
For Each oRefDoc As Document In oADoc.AllReferencedDocuments
'run the Sub below on each referenced document
ExportDrawingToPDF(oRefDoc)
Next
End Sub
Sub ExportDrawingToPDF(oDoc As Document)
'Set Folder options as you see fit here
oFolder = ThisDoc.Path + "\" ']
'PDF Options
oAddIns = ThisApplication.ApplicationAddIns
Dim PDFAddIn As TranslatorAddIn = oAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
oTO = ThisApplication.TransientObjects
oPDFContext = oTO.CreateTranslationContext
oPDFContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oPDFOptions = oTO.CreateNameValueMap
oPDFDataMedium = oTO.CreateDataMedium
oPDFOptions.Value("All_Color_AS_Black") = 0
oPDFOptions.Value("Remove_Line_Weights") = 1
oPDFOptions.Value("Vector_Resolution") = 4800
oPDFOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
'Generate text string of .idw file to look for in the same folder as component file.
idwPathName = Left(oDoc.FullDocumentName, Len(oDoc.FullDocumentName) - 3) & "idw"
'Check if generated drawing file name exists.
If System.IO.File.Exists(idwPathName) Then
'Open drawing file.
Dim oDrawDoc As DrawingDocument = ThisApplication.Documents.Open(idwPathName, True)
'get the value of the description iProperty, within the drawing
Dim oDescription As String = oDrawDoc.PropertySets.Item("Design Tracking Properties").Item("Description").Value
'Remove idw extension for PDF save.
oFileName = Left(oDoc.DisplayName, Len(oDoc.DisplayName) - 3)
'Generate text string of idw name and folder location.
oPDFDataMedium.FileName = oFolder + "\" + oFileName + "pdf"
'Save PDF Copy.
PDFAddIn.SaveCopyAs(oDrawDoc, oPDFContext, oPDFOptions, oPDFDataMedium)
'Close drawing file.
oDrawDoc.Close(True)
End If
End Sub