saved pdf through code, line thickness is greater than exported pdf from inventor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I have saved the pdf of .idw files in one folder, but after getting output of pdf file its not look like exported pdf from inventor. The line thickness is bigger than actual can anyone help me to this whether is problem with layer anything else I need to add in below code. also I have attached both result of pdf.
Dim oDoc As PartDocument
oDoc = g_inventorApplication.ActiveDocument
Dim oFPath As String = oDoc.FullFileName
Dim iPrtF As iPartFactory
iPrtF = oDoc.ComponentDefinition.iPartFactory
'Current file path
Dim oPath As String = System.IO.Path.GetDirectoryName(oDoc.FullDocumentName)
'Get current filename without extension
Dim CurrentFilename As String = System.IO.Path.GetFileNameWithoutExtension(oDoc.FullDocumentName)
Dim CurrntPath As String = oPath & CurrentFilename & "\"
Dim oFirstMem As String = iPrtF.TableRows.Item(1).MemberName
Dim oDSuffix As String = ".idw"
'Check that the drawing for this part can be found
If Not System.IO.File.Exists(oPath & "\" & CurrentFilename & oDSuffix) Then
Dim oDCheck As Boolean = False
MessageBox.Show("Couldn't find the original Drawing document!", "Drawing")
Exit Sub
End If
Dim Path As String = oPath
Dim oCompDef As ComponentDefinition = oDoc.ComponentDefinition
Dim iPF As iPartFactory = oCompDef.iPartFactory
Dim oRow As iPartTableRow
Dim iPM As iPartMember
For Each oRow In iPF.TableRows
Dim oNewPart As PartDocument
Dim oCompDef2 As ComponentDefinition
Dim iPF2 As iPartFactory
iPF.DefaultRow = oRow
Dim oiPName As String
oiPName = oRow.PartName
Dim oiMNAme As String
oiMNAme = oRow.MemberName
'MsgBox(oiPName)
'Get current path
'MessageBox.Show(Path, "PAth")
' Perform Save As of Part
On Error Resume Next
Call oDoc.SaveAs(Path & "\" & oiPName, True)
'MessageBox.Show(Path & "\" & oiPName, "save")
oNewPart = Nothing
oNewPart = g_inventorApplication.Documents.Open(Path & "\" & oiPName, False)
oCompDef2 = Nothing
oCompDef2 = oNewPart.ComponentDefinition
iPF2 = Nothing
iPF2 = oCompDef2.iPartFactory
'Dim iR As Integer = oRow.Index
'iPF2.DefaultRow = oRow
iPF2.Delete()
oNewPart.Save()
oNewPart.Close(True)
Dim DrawingDoc As DrawingDocument = g_inventorApplication.Documents.Open(oPath & "\" & CurrentFilename & oDSuffix, False)
' Replace reference to part model
Dim oFD As FileDescriptor
oFD = DrawingDoc.ReferencedFileDescriptors(1).DocumentDescriptor.ReferencedFileDescriptor
Call oFD.ReplaceReference(Path & "\" & oiPName)
DrawingDoc.Update()
' Perform 'Save As' on the drawing - change this to reflect your drawing type .dwg or .idw
DrawingDoc.SaveAs(Path & "\" & oiMNAme & oDSuffix, False)
'PDF Saving Process
Dim PDFAddIn As TranslatorAddIn
Dim oContext As TranslationContext
Dim oOptions As NameValueMap
Dim oDataMedium As DataMedium
PDFAddIn = g_inventorApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
oContext = g_inventorApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = g_inventorApplication.TransientObjects.CreateNameValueMap
oDataMedium = g_inventorApplication.TransientObjects.CreateDataMedium
Dim drawingStyle = DrawingDoc.StylesManager.Layers
If PDFAddIn.HasSaveCopyAsOptions(oDoc, oContext, oOptions) Then
oOptions = g_inventorApplication.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
drawingStyle.Value("Visible(ANSI)") = 0.1
oDataMedium = g_inventorApplication.TransientObjects.CreateDataMedium
End If
Call ConfigurePDFAddinSettings(PDFAddIn, oContext, oOptions, oDataMedium)
'create a seperate folder for pdf
Dim oFolder As String = oPath & "\" & " PDF Files"
If Not System.IO.Directory.Exists(oFolder) Then
System.IO.Directory.CreateDirectory(oFolder)
End If
oDataMedium.FileName = oFolder & "\" & oiMNAme & ".pdf"
Call PDFAddIn.SaveCopyAs(DrawingDoc, oContext, oOptions, oDataMedium)
'End of PDF process
DrawingDoc.Close(True)
Next
' Make the assembly model active again...
oDoc.Activate()
MessageBox.Show("Great, Members and Copy drawings are ready in same folder...")