Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

CATIA Macro to Export a PDF

Status
Not open for further replies.

wc389

Mechanical
Jul 15, 2014
2
BR


Guys,

I was asked to develop a Catia macro that will export a PDF from a CATDrawing in a specific network folder. At this moment I got it with a simple command in VBS as shown below but I still have some open with the naming convention.

---------------------------------------
Language="VBSCRIPT"

Sub CATMain()

Set drawingDocument1 = CATIA.ActiveDocument

drawingDocument1.ExportData "D:\users\wc389\Desktop\OUTTest\ "& CATIA.ActiveDocument.name &".pdf", "pdf"

End Sub
-------------------------------------

When I run the macro, it creates a PDF file with the complete file name, including the “CATDrawing” extension as name. For example, if I have an active drawing with the Part Number 12345.CATDrawing, it will create a PDF named as 123.CatDrawing.PDF.

Instead that, I need to read some title block parameter to follow as naming convention, for example the Drawing Number and Drawing Revision to naming by this way: 12345_rev01.pdf.
Some one knows how can I close this point?
 
Replies continue below

Recommended for you

Code:
Sub Pdf()

Set drawingDocument1 = CATIA.ActiveDocument

Dim sName As String
sName = Left(CATIA.ActiveDocument.Name, InStr(1, CATIA.ActiveDocument.Name, ".CATDrawing") - 1)
 
Dim oParameters As Parameters
Set oParameters = drawingDocument1.Parameters

Set oPar = oParameters.Item("Rev#") '<--Parameter Name

drawingDocument1.ExportData "C:\Alex\ " & sName & "_" & oPar.Value & ".pdf", "pdf"

End Sub

______

Alex ,
 
Hello Alex,

Your code is working as I was expexting...

Thank you for your reply...

Alan SANTOS....
 
may i suggest that you modify it so that it saves catdrawing and pdf into same dir.
 
Code:
Sub Pdf()

Set drawingDocument1 = CATIA.ActiveDocument

Dim sName As String
sName = Left(CATIA.ActiveDocument.Name, InStr(1, CATIA.ActiveDocument.Name, ".CATDrawing") - 1)
 
Dim oParameters As Parameters
Set oParameters = drawingDocument1.Parameters

Set oPar = oParameters.Item("Rev#") '<--Parameter Name

Dim sPath As String
sPath = CATIA.ActiveDocument.Path & "\" & sName & "_" & oPar.Value & ".pdf"

drawingDocument1.ExportData sPath, "pdf"

End Sub

______

Alex ,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top