Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MACRO PDF with revision number if exists in the drawing

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
Anonymous
1020 Views, 7 Replies

MACRO PDF with revision number if exists in the drawing

Hi,

 

I have a macro for exporting my drawings to PDF.

But I want improve by adding the revision number only if the drawing has a revision number.

 

Actually (an extract of my macro with VBA)

'Set filename as original document filename.
Dim FileName As String
FileName = oDocument.FullFileName
 
Dim Temp() As String
Temp = Split(FileName, "\")
 
FileName = Left(Temp(UBound(Temp)), Len(Temp(UBound(Temp))) - 4)
    
'Set the destination to save files.
oDataMedium.FileName = "C:\Path...\" & FileName & ".pdf"

 

I wish this result :

 

If no revision : PartNumber.pdf

If revision : PartNumber_RevisionNumber.pdf

 

 

Thanks you,

7 REPLIES 7
Message 2 of 8
Ktomberlin
in reply to: Anonymous

This Should help.

 

Dim oRevNum As String
oRevNum
= iProperties.Value("Project", "Revision Number") Dim oFileName As String
oFileName
= ThisDoc.FileName(False) If oRevNum >= 1 Then oDataMedium.FileName = "C:\Path...\" & oFileName & "_" & oRevNum & ".pdf" Else oDataMedium.FileName = "C:\Path...\" & oFileName & ".pdf" End If
Message 3 of 8
Anonymous
in reply to: Ktomberlin

Thanks, but I think that working for iLogic, but don't working wih VBA.

How to get (Revision Number) with VBA (I'm a rookie with VBA)

 

 

Dim RevNum As (String ?)
RevNum = (?)

 

Message 4 of 8
Ktomberlin
in reply to: Anonymous

Sorry, forgot i had to change that in VB

 

Dim oRevNum As String = GetPropertyValue(ThisDoc, "Inventor Summary Information", "Revision Number")

Message 5 of 8
Anonymous
in reply to: Ktomberlin

The "Revision Number" don't work.

If I use iLogic and not "VBA", because it's working better.

 

How to add a button in the ribbon ?

Like this : (with custom icon)

http://modthemachine.typepad.com/my_weblog/2008/11/creating-buttons-for-vba-macros.html

Message 6 of 8
Ktomberlin
in reply to: Anonymous

This works now for sure.
   
'Set the destination to save files.
Dim oDocRevision As Property
Dim Revision As String
Set oDocRevision = oDocument.PropertySets.Item("Inventor Summary Information").Item("Revision Number")
               If oDocRevision.Value = 0 Then
                    oDataMedium.FileName = "C:\Temp\" & FileName & ".pdf"
                Else
                    Revision = "_Rev-" + CStr(oDocRevision.Value)
                    oDataMedium.FileName = "C:\Temp\" & FileName & Revision & ".pdf"
                End If
'Publish document.
Call PDFAddin.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
End Sub

Message 7 of 8
Anonymous
in reply to: Ktomberlin

Great, thank you very much.

 

Just a little correction.

I replaced :

 

If oDocRevision.Value = 0 Then

 by

If oDocRevision.Value = "" Then

 

Message 8 of 8
Ktomberlin
in reply to: Anonymous

You could change that to Null or 0 for the same result.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report