DXF/DWG: VBScript macros

You can automate Data exchanges with DXF 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 VBScript macro.

Example

VBScript macro for implementing a DXF file 

Language="VBScript"

Sub CATMain()

Dim Document0 As Document

' Reading an DXF file

Set Document0 = CATIA.Documents.Open  ( "E:\tmp\Box.dxf" )

' 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 CATDrawing file to DXF

Language="VBScript"

sub CATMain()

Dim PartDocument0 As Document

' Reading a CATDrawing file

Set PartDocument0 = CATIA.Documents.Open ( "E:\tmp\Box.CATDrawing" ) 

' Saving the part in a DXF file

PartDocument0.ExportData "E:\tmp\Box2", "dxf"

CATIA.Quit

End Sub