saved pdf through code, line thickness is greater than exported pdf from inventor

saved pdf through code, line thickness is greater than exported pdf from inventor

2020mme013
Enthusiast Enthusiast
482 Views
7 Replies
Message 1 of 8

saved pdf through code, line thickness is greater than exported pdf from inventor

2020mme013
Enthusiast
Enthusiast

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...")Saved_through_Code.pngInventor_Exported.png

0 Likes
483 Views
7 Replies
Replies (7)
Message 2 of 8

A.Acheson
Mentor
Mentor

Yes I believe there is differences between the export as pdf and ilogic save as using translator. 

 

In the NameValueMap options you can try and adjust these options.

        'oOptions.Value("Remove_Line_Weights") = 0
        'oOptions.Value("Vector_Resolution") = 400

 In my previous testing I could not get the desired quality from the manual export. There doesn't seem to be much ability to control that process or the control is in multiple locations.  However I was able to adjust the ilogic method to work consistently. 

 

Some other post discussing this topic

 

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/poor-pdf-quality-using-pdf-translato...

 

https://knowledge.autodesk.com/support/inventor/troubleshooting/caas/sfdcarticles/sfdcarticles/Expor...

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 8

2020mme013
Enthusiast
Enthusiast

Yes I did that changes, even though there is no change in output. I think its issue with layer if anyone know how do i change layer line thickness.

0 Likes
Message 4 of 8

A.Acheson
Mentor
Mentor

You can change the layers in the style library. I had the most issues with the layers having dashed lines. Trying to get the line weight and dash spacing right was a difficult task. Here is also another post on the pdf reader line weight settings. Is the pdf reader delivering the same results as printing a physical drawing sheet? 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 5 of 8

2020mme013
Enthusiast
Enthusiast

this is also not working, I am getting different different output for different sample drawing sketch layer is changing in some drawing and in some drawing the layer is ok. but why its changing if I am having a same drawing of all member of ipart.

0 Likes
Message 6 of 8

A.Acheson
Mentor
Mentor

It sounds like you may have changed the layers in the local drawing and not the styles. Ensure the global style is updated and then the drawing also gets the global style updated. Can you export manually and ensure the line weights are consistent. This will eliminate code issues in the translator. 

 

AAcheson_0-1667341535259.png

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 7 of 8

2020mme013
Enthusiast
Enthusiast
Okay. Let me check with this setting once.
0 Likes
Message 8 of 8

2020mme013
Enthusiast
Enthusiast

Hi, I have done this setting, still there is no change in output. after exporting same drawing from inventor the layer is visible edge(ANSI), but when I am doing it from the code then layer is changing from visible Edge to the template name of layer which is in greater in line thickness and thats why through code its taking the name layer. why its changing automatically not getting. what we are doing from inventor manually is it not possible same with coding??

0 Likes