STEP: VBScript Macros

You can automate Data exchanges between CATIA V5 and STEP 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:

  3. 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 STEP AP203 file

Language="VBScript"

Sub CATMain()

Dim Document0 As Document

' Reading a STEP file

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

' Saving the corresponding CATPart  

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
    nd 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.

Examples

VBScript macro for exporting a file to STEP AP203

Language="VBScript"  
Sub CATMain()  
Dim PartDocument0 As Document  
' Reading a CATPart file
  
Set PartDocument0 = CATIA.Documents.Open( "E:\tmp\Box.CATPart" ) 
 
' Saving the part in a STEP file
  
PartDocument0.ExportData "E:\tmp\Box2", "stp"
  
CATIA.Quit
  
End Sub
  


VBScript macro for exporting a Product file to STEP AP203
 

Language="VBScript  
Sub CATMain()
  
Dim ProductDocument0 As Document
  
Set ProductDocument0 = CATIA.Documents.Open( "E:\tmp\Product1.CATProduct" )
  
ProductDocument0.ExportData "E:\tmp\Product1", "stp"
  
CATIA.Quit
  
End Sub