SAVE TO PDF with rev

SAVE TO PDF with rev

Anonymous
Not applicable
431 Views
3 Replies
Message 1 of 4

SAVE TO PDF with rev

Anonymous
Not applicable

Hi Autodesk Community 

 

i am seeking some advice on how to get my ilogic code to work a bit more effectively 

 

 

currently the code will save a pdf with the part number and revision number as the suffix on save in the IDW Environment

 

the issue i am having is that evan if the drawing has no revisions or revision table it will save with rev 0 or 1 on the suffix

 

and once a table is added it will only increment after the second revision is put into the table 

 

is there a way i can make it that it only adds the revision suffix if a table exist within the drawing ? 

 

---------------------------------------------------------------
'Save PDF with options
path_and_namePDF = ThisDoc.PathAndFileName(False) ' without extension
PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD95-2F4D-42CE-8BE0-8AEA580399E4}")
oRevNum = iProperties.Value("Project", "Revision Number")
oDocument = ThisApplication.ActiveDocument
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

If PDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
oOptions.Value("All_Color_AS_Black") = 0
oOptions.Value("Remove_Line_Weights") = 0
oOptions.Value("Vector_Resolution") = 400
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
'oOptions.Value("Custom_Begin_Sheet") = 2
'oOptions.Value("Custom_End_Sheet") = 4
End If

'Set the destination file name
oDataMedium.FileName = path_and_namePDF & _
" Rev" & oRevNum & ".pdf"

On Error Goto handlePDFLock
'Publish document.
Call PDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)

i = MessageBox.Show("View the PDF file?", "Title",MessageBoxButtons.YesNo)
If i = vbYes Then : launchviewer = 1 : Else : launchviewer = 0 : End If
If launchviewer = 1 Then ThisDoc.Launch(oDataMedium.FileName)

Exit Sub

handlePDFLock:
MessageBox.Show("PDF could not be saved, most likely someone else has it open.", _
"No PDF for you " & ThisApplication.GeneralOptions.UserName & "!")
Resume Next

-----------------------------------------------------------------------------

 

Looking Forward to any assistance you can offer 

 

Thanks in advance 

 

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

salariua
Mentor
Mentor

EDIT: copied this from an existing rule which had one too many sheet counts..

 

Hi @Anonymous,

 

Here is a code that will track if you have a revision table on ANY of the drawing sheets. It will create a Boolean parameter which you can use with, if true then add revision if false then don't add revision.

 

' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim oSheets As Sheets
oSheets = oDrawDoc.Sheets
Dim oSheet As Sheet'Inventor.Sheet
Dim oRevisionTables As RevisionTables
Dim oAddRevision As Boolean = True


Dim i As Long
For i = 1 To oDrawDoc.Sheets.Count
	If oDrawDoc.Sheets.Item(i).RevisionTables.Count > 0 Then
		'MessageBox.Show("Revision table found on: " & i, "Title")
		Exit For
	Else
		'MessageBox.Show("Revision Table not found.", "Title")
		oAddRevision = False
	End If
Next
' add the save as PDF code here



'MessageBox.Show("Add revision?: " & oAddRevision, "Revision Tracking")

and here are some resources for save and export to pdf.

 

http://blog.ads-sol.com/search?q=revision+pdf

 

 

Adrian S.
blog.ads-sol.com 

AIP2012-2020 i7 6700k AMD R9 370
Did you find this reply helpful ?
If so please use the Accepted Solutions or Like button - Thank you!
0 Likes
Message 3 of 4

Anonymous
Not applicable

Hi,

Change the line...

 

oRevNum = iProperties.Value("Project", "Revision Number")

 

to these lines...

 

 

If iProperties.Value("Project", "Revision Number") = "0" Then
oRevNum = ""
Else
oRevNum = iProperties.Value("Project", "Revision Number")
End If

 

0 Likes
Message 4 of 4

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi @Anonymous,

 

A small improvement to @Anonymous

 

If iProperties.Value("Project", "Revision Number") = "0" Or iProperties.Value("Project", "Revision Number") = "" Then
	oRevNum = ""
Else
	oRevNum = iProperties.Value("Project", "Revision Number")
End If

Please feel free to contact if there is any doubt.

 

If solves problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes