Vous êtes sur la page 1sur 3

http://www.vietnam-cadcamcae.

com/cadcamcaemagazine/cad-magazine/the-second-
number.html

Script to create
PDF and DWG
on Catia
http://www.vietnam-cadcamcae.com/cadcamcaemagazine/cad-magazine/the-second-
number.html

In the beginning, creating a textfile with extensions .CATvbs on


notepad, wordpad or Microsoft Word.

Copy and paste all bellow lines into the textfile.CATvbs

Language="VBSCRIPT"
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")
http://www.vietnam-cadcamcae.com/cadcamcaemagazine/cad-magazine/the-second-
number.html

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
specsAndGeomWindow.Close
Set drawingDocument = CATIA.ActiveDocument
drawingDocument.Close
End If
Next

Wscript.Echo "DWG and PDF files created in subfolders to


" & PathToCATFiles

On Catia, run this macro. The macro create both PDF and
DWG at the same time.

Vous aimerez peut-être aussi