iLogic program to Save as PDF without line weights

iLogic program to Save as PDF without line weights

Anonymous
Not applicable
1,077 Views
3 Replies
Message 1 of 4

iLogic program to Save as PDF without line weights

Anonymous
Not applicable

Hello All,

 

I have an iLogic program that saves part drawings as a PDF in a specific location. I needed to edit the program to save the PDF documents without object line weights, rather than having to manually export as a pdf and select that from the options menu. I was reading through the iLogic API and found the recommend code, but I can't seem to get it to work (regardless of whether I assign the number "0" or "1" to the "oOptions.Value("Remove_Line_Weights")" line of code).

 

Does anyone know how to make this work?

 

I've included the code here:

 

Thanks!

 

SyntaxEditor Code Snippet

' 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("Remove_Line_Weights") = 0
        oOptions.Value("Vector_Resolution") = 400
        'oOptions.Value("Sheet_Range") = kPrintAllSheets
        'oOptions.Value("Custom_Begin_Sheet") = 2
        'oOptions.Value("Custom_End_Sheet") = 4

    End If

EPN = iProperties.Value("Project", "Part Number")

If(Not System.IO.Directory.Exists("G:\PUBLIC\EPNFOLDERS\" & EPN)) Then
    System.IO.Directory.CreateDirectory("G:\PUBLIC\EPNFOLDERS\" & EPN)
End If

'Saves the PDF in the desired location
ThisDoc.Document.SaveAs("G:\PUBLIC\EPNFOLDERS\" & EPN & "\" & EPN & " PRINT.pdf" , True)

 

0 Likes
Accepted solutions (1)
1,078 Views
3 Replies
Replies (3)
Message 2 of 4

rhasell
Advisor
Advisor
Accepted solution

Hi

 

I think the problem is in the last line, you don't actually specify the options in the save.

 

Here is a snippet of my code.

 

 

If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
oOptions.Value("All_Color_AS_Black") = 0
oOptions.Value("Remove_Line_Weights") = 0
oOptions.Value("Vector_Resolution") = 4800
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
End If
'---End PDF settings

'---
oPath = ThisDoc.Path
oFileName = ThisDoc.FileName(False) 'without extension
oRevNum = iProperties.Value("Project", "Revision Number")
oDocument = ThisApplication.ActiveDocument
	
		Dim strIniFile As String
        strIniFile = "C:\Data\2016-acadexport-[jun16]-2.ini"
        oOptions.Value("Export_Acad_IniFile") = strIniFile

	oFolder ="C:\DATA\1 EXPORT"
	oDataMedium.FileName =oFolder + "\" + oFileName & "[" & oRevNum & "]" & ".pdf"
If System.IO.File.Exists(oDataMedium.FileName) Then
	 oChoice=MessageBox.Show(oDataMediumPDF.FileName & " Already Exists - Overwrite?", "Title", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
		If oChoice=7
			Return
			Else
		End If
End If	
	
'''--- Publish document.
oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
MessageBox.Show("Done!", "Title")

 

Reg
2026.1
Message 3 of 4

rhasell
Advisor
Advisor

Hi

 

I forgot to remove some of the lines from the AutoCAD export, just ignore them.

 

Also, I don't remove line weights, that is why mine is still at zero, but if you change it to a "1" it will work.

 

Reg
2026.1
0 Likes
Message 4 of 4

Anonymous
Not applicable

Ah ok, I adjusted how the file is saved so that I can include the options. Thanks for pointing that out, works correctly now!

 

-Nick