Using a Macro to Export Clash Results to an XML File

This task illustrates how to export, in XML format, a clash result saved in a CATProduct.

This is done by running a macro which opens the CATProduct containing the clash results and exports the first result to an XML file.

  • Have a CATProduct containing clash results.

  • Have cleared the Federated XML output option in the DMU Clash - Process tab of the Options dialog box (Tools > Options > Digital Mockup > DMU Space Analysis).

  1. Open and edit the macro to:

    Select Tools -> Macro -> Macros

    Identify the folder containing the macro, select the CATScript then click Edit...

    Add the name and path of the CATProduct that will be opened and that contains the clash results you want to export.

    Add the name (without the file extension) and path of the XML file that will contain exported clash results.

    Save the macro.

    Sample Macro

    Sub CATMain()

    ' 1 - Load the document
    sProductPath = CATIA.SystemService.Environ("C:
    \data\XML")
    Dim documents1 As Documents
    Set documents1 = CATIA.Documents
    Set productDocument1 = documents1.Open("C:
    \data\XML\product1.CATProduct")
    CATIA.ActiveWindow.ActiveViewer.Viewpoint3D.ProjectionMode = 0

    ' 2 - Retrieve the Clashes collection
    Dim rClashes As Clashes
    Set rClashes = CATIA.ActiveDocument.Product.GetTechnologicalObject("Clashes")

    ' 3 - Retrieve the first clash result
    Dim rClash As Clash
    Set rClash = rClashes.Item(1)

    ' 4 - Export it as a XML document
    rClash.Export CatClashExportTypeXMLResultOnly, "C:
    \data\XML\MacroExport\product1"

    End Sub

     

    • If the CATProduct containing clash results has been loaded into your CATIA session, delete the first step from the macro.

    • You can also add a loop to your macro to export more than one clash result.

     

  2. Click Run to run the macro.

    • A CATProduct is opened in your current DMU session.
    • A single XML file containing the first clash result is generated. This file is located in the folder identified in the macro.

    For more information on XML grammar, see reading XML clash files.

You can also add your macro to a toolbar if desired using the Tools -> Customize... command. Select the Commands tab, then the Macros category: all macros will be detected and listed. You can then drag and drop onto toolbars for convenient access.