Welcome to 3DCADForums

Join our CAD community forums where over 25,000 users interact to solve day to day problems and share ideas. We encourage you to visit, invite you to participate and look forward to your input and opinions. Acrobat 3D, AutoCAD, Catia, Inventor, IronCAD, Creo, Pro/ENGINEER, Solid Edge, SolidWorks, and others.

Register Log in

save as .pdf

Ronny Schneider

New member
Script to do create PDF and DWG

Create a textfile with extensions .CATvbs
Paste all below line into thetextfile.CATvbs and in Catia run this macro.
This macro create both PDF and DWG at same time.
Sub CATMain()
Dim oFSO
Set oFSO= CreateObject("Scripting.FileSystemObject")

PathToCATFiles = InputBox("Enter path there CATDrawings-files exist" & vbCrLf, "File", "")

strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
If Not oFSO.FolderExists(PathToCATFiles& "\PDF") Then
oFSO.CreateFolder(PathToCATFiles& "\PDF")
End If
If Not oFSO.FolderExists(PathToCATFiles& "\DWG") Then
oFSO.CreateFolder(PathToCATFiles& "\DWG")
End If

Set FileList = objWMIService.ExecQuery("Associators of {Win32_Directory.Name='" & PathToCATFiles & "'} Where " & "ResultClass = CIM_DataFile")

For Each objFile In FileList

If objFile.Extension = "CATDrawing" Then

On Error Resume next
Set documents = CATIA.Documents
Set drawingDocument = documents.Open(PathToCATFiles & "\" & objFile.FileName & "." & objFile.Extension)
Set drawingDocument = CATIA.ActiveDocument
drawingDocument.ExportData PathToCATFiles & "\PDF\" & objFile.FileName & ".pdf", "pdf"
drawingDocument.ExportData PathToCATFiles & "\DWG\" & objFile.FileName & ".dwg", "dwg"
Set specsAndGeomWindow = CATIA.ActiveWindow
Set drawingDocument = CATIA.ActiveDocument
End If

Wscript.Echo "DWG and PDF files created in subfolders to " & PathToCATFiles
End Sub