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!

Script for saving multiple drawing to pdf (Catia V5-6 R2014)

Status
Not open for further replies.

dvnce

Automotive
May 22, 2012
2
HU
Hi Everyone,

I know this topic is well-discussed in the forum but I haven't found any working macro I want, maybe the version number difference is the problem, I have V5-6 R2014. And I am quite new in this macro topic so I need a lot help.

I would like to make a macro to save multiple drawings to pdf without opening them. The drawings have 3 sheets and I just want to save only the first one.

I found this code shown below and it works well but saves all the sheet in the drawing to the pdf and I want only the first sheet. And it would be great if the filename would not contain the xxxx.CATDrawing.pdf ending.
The other thing is that this code want to open every file in the folder, and I just want the macro to open only .CADDrawing filetypes.
For starters I would be happy if these methods will work.

Language="VBSCRIPT"

Sub CATMain()

folderinput = InputBox ("Take your files from here","Input","",2000,4000)
folderoutput = InputBox ("Put your files here","Output","",2000,4000)


Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderinput)
Set fc = f.Files

For Each f1 in fc

Dim PartDocument1 'As Document
Set documents1 = CATIA.Documents
Dim document1 'As Document

INTRARE = folderinput & f1.name
Set PartDocument1 = CATIA.Documents.Open(INTRARE)

IESIRE = folderoutput & f1.name & ".pdf"
PartDocument1.ExportData IESIRE, "pdf"


s = s & f1.name
s = s & vbCrLf

CATIA.ActiveDocument.Close

Next

End Sub


Thank You in advance!
 
Replies continue below

Recommended for you

I searched for it but this one I found but I didn't find the solution for the other problems.
Can I ask you how did you learn CATScripts? From what kind of learning material? I am not really familiar with programming, back in the university there was some visual basic and that is, but it was a long time ago. With this background is this any chance that I can learn it by myself?

Thanks!

Regards,
Daniel
 
If you don't want to open the files, you need to run the macro in batch mode. To modify the automatic naming you need to do it in script by cutting last 11 characters from the end of the name of the file. You can also put a filter for what kind of files to open. Sorry but I don't have time to modify this script.

I've learned scripting by searching the forums and looking in CATIA automation docs. There is a FAQ section here, take a look at the end of the page.

Regards
Fernando

- Romania
- EU
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top