.idw Export .PDF with revision

.idw Export .PDF with revision

GSK139
Participant Participant
322 Views
3 Replies
Message 1 of 4

.idw Export .PDF with revision

GSK139
Participant
Participant

Hello,

 

I am trying the code of ItsaCADworld.

But I cant get the code to work. The code is the same as the one in the video.

And is it possible to automatically put "REV"_"Revision_Number" behind the exported file name?

WorkspacePath = ThisDoc.WorkspacePath()
WorkspacePathLength = Len(WorkspacePath)
PathOnly = ThisDoc.Path
DirectoryPath = Strings.Right(PathOnly, PathOnly.Length - WorkspacePathLength)
PDFPath = "C:\PDFs\" & DirectoryPath
If (Not System.IO.Directory.Exists(PDFPath)) Then
	System.IO.Directory.CreateDirectory(PDFPath)
End If
ThisDoc.Document.SaveAs(PDFPath & "\" & ThisDoc.FileName(False) & ".pdf" , True)

 

0 Likes
323 Views
3 Replies
Replies (3)
Message 2 of 4

Ralf_Krieg
Advisor
Advisor

Hello

 

Sub main
	WorkspacePath = ThisDoc.WorkspacePath()
	WorkspacePathLength = Len(WorkspacePath)
	PathOnly = ThisDoc.Path
	DirectoryPath = Strings.Right(PathOnly, PathOnly.Length - WorkspacePathLength)
	PDFPath = "C:\PDFs\" & DirectoryPath
	
	If (Not System.IO.Directory.Exists(PDFPath)) Then
		System.IO.Directory.CreateDirectory(PDFPath)
	End If
	'ThisDoc.Document.SaveAs(PDFPath & "\" & ThisDoc.FileName(False) & ".pdf" , True)	
	
    ' Get the PDF translator Add-In.
    Dim PDFAddIn As TranslatorAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")

    Dim oContext As TranslationContext = ThisApplication.TransientObjects.CreateTranslationContext
    oContext.Type = kFileBrowseIOMechanism

    ' Create a NameValueMap object
    Dim oOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap

    ' Create a DataMedium object
    Dim oDataMedium As DataMedium = ThisApplication.TransientObjects.CreateDataMedium

    ' Check whether the translator has 'SaveCopyAs' options
    If PDFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then

        ' Options for drawings...

        oOptions.Value("All_Color_AS_Black") = 0

        '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

    'Set the destination file name
    oDataMedium.FileName = PDFPath & "\" & ThisDoc.FileName(False) & ".pdf" 

    'Publish document.
    Call PDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
End Sub

R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 3 of 4

GSK139
Participant
Participant

Thank you. Why do you need the add-in? Isnt it possible to do it without?

0 Likes
Message 4 of 4

Ralf_Krieg
Advisor
Advisor

Hello

 

The SaveAs method does nearly the  same as if you use the "Save As" option in GUI. You can select another filename, but can not convert to a different file type. Can't believe the code works.


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes