2D IGES: VBScript Macros

You can automate Data exchanges with IGES using VBScript macros, either at import or export,

Import

  1. Create a RunTime window (window in which all runtime variables a set)

  2. Type the command: cnext -macro MyMacro.CATScript
    where MyMacro.CATScript is the VBScript macro you want to execute.

  • The input files must be writable (not read only). Otherwise the system will display an information box and wait for an acknowledge.
  • The output file must not exist in the output directory otherwise the system will ask for a confirmation to overwrite the file and wait for an acknowledge.
You can transfer several files within the same VBScript macro, but it is recommended to do only one transfer per macro.

Example

VBScript Macro for implementing a IGES file 

Language="VBScript"
Sub CATMain()
Dim Document0 As Document
' Reading an IGES file
Set Document0 = CATIA.Documents.Open ( "E:\tmp\Box.ig2" )
' Saving the corresponding CATDrawing
CATIA.ActiveDocument.SaveAs "E:\tmp\Box"
CATIA.Quit
End Sub

 

Export

  1. Create a RunTime window (window in which all runtime variables are set):

  2. Type the command: cnext -macro MyMacro.CATScript
    where MyMacro. CATScript is the VBScript macro you want to execute.

  • The input files must be writable (not read only). Otherwise the system will display an information box and wait for an acknowledge.
  • The output file must not exist in the output directory otherwise the system will ask for a confirmation to overwrite the file and wait for an acknowledge.
You can transfer several files within the same VBScript macro, but it is recommended to do only one transfer per VBScript macro.

Example

VBScript macro for exporting a Part file to IGES

Language="VBScript"
Sub CATMain()
Dim DrawingDocument0 As Document
' Reading a CATDrawing file
Set DrawingDocument0 = CATIA.Documents.Open ( "E:\tmp\draw.CATDrawing" )
' Saving the Drawing in a 2D IGES file
DrawingDocument0.ExportData "E:\tmp\draw2", "ig2"
CATIA.Quit
End Sub