> ## Documentation Index
> Fetch the complete documentation index at: https://developer.synopsys.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MacroExporter Class Reference

Part of [Script](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/group__script)

Export Statistics on Structures macross built with the MacroBuilder and export the resulting workflow as a Functional Mockup Unit ([FMU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_f_m_u)), for further use e.g. in Ansys OptiSLang.

## Public Member Functions

| Type | Name |
| - | - |
| | [addInputArg](#aa66f1f2a43be5e47521d5fe7d467561a) (macro::MacroArg inputArg) Add an input argument. Only scalar input arguments are exposed as an [FMU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_f_m_u) 2.0 input. |
| | [addOutputArg](#a948a4c1cf3a67539eae217ed0896d12e) (macro::MacroArg outputArg) Add an output argument. Only scalar output arguments are exposed as an [FMU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_f_m_u) 2.0 output. |
| | [exportFMU2](#a67a8b4f80b7a79cfa9613eeb2d139953) (string filename) Write an [FMU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_f_m_u) 2.0 file to disk Creates an .fmu archive containing the macro, a minimal database file, the necessary SoS libraries and the [FMU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_f_m_u) modelDescription.xml file. |
| | [exportSDB](#add9901725fee3dba2798644e14f2793e) (string filename) Write an SDB file, containing the macro created with the MacroBuilder. |
| | [MacroExporter](#a391cbad9a69a4732f82c4ea2fdcd5a54) () Construct a [MacroExporter](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_macro_exporter.md) to export a macro workflow as an [FMU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_f_m_u) 2.0. |
| | [setDllPath](#a682461752380b2bbb0339143e5bd5a5e) (string path) The Macro Exporter attempts to auto-detect the library directory. Use this method to manually set a path pointing to the SoS [FMU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_f_m_u) libraries. |

## Public Attributes

| Type | Name |
| - | - |
| string | [fmu\_author](#a673353efb2f3c3226804f1d092f6b2c9) Author of the exported [FMU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_f_m_u). |
|  string | [fmu\_independent\_variable](#a66ecd1a38a225ff328d907d2b2d82b3a) = "" Set the name of the independent variable of the exported [FMU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_f_m_u). Usually "time". The independent variable can be a Field-MOP/Signal-MOP input parameter. This parameter is optional. Leave it set to an empty string, if the [FMU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_f_m_u)'s inputs and outputs are not a function of an independent variable. |
| string | [fmu\_model\_description](#a3d112ff2dfe59a23793aece49bc1286b) Model description of the exported [FMU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_f_m_u). |
| string | [fmu\_model\_name](#a5fc548655b0cd078bce2bb9de42c8f4b) Model name of the exported [FMU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_f_m_u). |
|  bool | [replace\_files](#a2f8b3cba47ad64fb6bda4b6428a032d3) = false If false, an already existing exported files are not overwritten. Instead an error message is displayed. |
|  string | [script](#a06cd29eee2d80e63ad5f041401b76f99) The Lua script function to be executed at each [FMU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_f_m_u) execution step. The script string must adhere to the following convention: local function script(...) – the function MUST be named 'script' database, design\_id = ... – the first two arguments passed during [FMU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_f_m_u) execution are the database and the design\_id sos.log(3, 'Calling [FMU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_f_m_u) macro workflow for design ID ' .. design\_id .. ' ...') –optional logging –any number of macros. All macro arguments to be deliverd through the [FMU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_f_m_u) interface, must be added using addInputVariable() or addOutputVariable() at the [MacroExporter](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_macro_exporter.md). sos\_macros.elementEvaluateFieldMOP(database, design\_id, "pstrain", "pstrain", "real\_mat\_ord\_1", "plastic\_failure", "yield\_stress", "blank\_thickness\_1", "rho", "real\_mat\_abs\_1", "E\_Modul", "poisson\_ratio"); sos\_macros.elementMinOfField(database, design\_id, "pstrain", "", "min") sos\_macros.elementMeanOfField(database, design\_id, "pstrain", "", "mean") sos\_macros.elementMaxOfField(database, design\_id, "pstrain", "", "max") sos.log(3, '... finished.') end. |

## Detailed Description

Export Statistics on Structures macross built with the MacroBuilder and export the resulting workflow as a Functional Mockup Unit ([FMU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_f_m_u)), for further use e.g. in Ansys OptiSLang.

The [MacroExporter](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_macro_exporter.md) is invoked when exporting a macrobased [FMU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_f_m_u) from the graphical user interface. It gathers all inputs and outputs from the macro created with the MacroBuilder passed to the [MacroExporter](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_macro_exporter.md).

Script example based on sos\_demo.sdb: macro\_exporter = sos.MacroExporter(); macro\_exporter:exportFMU2('/dir/of/your/choice/approx\_fmop.fmu');

## Member Function Documentation

### addInputArg()

```cpp theme={null}
addInputArg(macro::MacroArg inputArg)
```

Add an input argument. Only scalar input arguments are exposed as an [FMU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_f_m_u) 2.0 input.

**Parameters**

| Name | Description |
| - | - |
| inputArg | The input argument to add. |

### addOutputArg()

```cpp theme={null}
addOutputArg(macro::MacroArg outputArg)
```

Add an output argument. Only scalar output arguments are exposed as an [FMU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_f_m_u) 2.0 output.

**Parameters**

| Name | Description |
| - | - |
| outputArg | The output argument to add. |

### exportFMU2()

```cpp theme={null}
exportFMU2(string filename)
```

Write an [FMU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_f_m_u) 2.0 file to disk Creates an .fmu archive containing the macro, a minimal database file, the necessary SoS libraries and the [FMU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_f_m_u) modelDescription.xml file.

**Parameters**

| Name | Description |
| - | - |
| filename | Relative or absolute path to the .fmu archive to be written. |
| replace\_files | If True, an existing filename is overwritten without warning. If false and filename already exists, an error is thrown. |

### setDllPath()

```cpp theme={null}
setDllPath(string path)
```

The Macro Exporter attempts to auto-detect the library directory. Use this method to manually set a path pointing to the SoS [FMU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_f_m_u) libraries.

**Parameters**

| Name | Description |
| - | - |
| path | Absolute path to the SoS library directory. |

## Member Data Documentation

### fmu\_author

```cpp theme={null}
string fmu_author
```

Author of the exported [FMU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_f_m_u).

> [!NOTE]
>
> Is written into modelDescription.xml, which is part of the exported [FMU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_f_m_u) archive.

### fmu\_model\_description

```cpp theme={null}
string fmu_model_description
```

Model description of the exported [FMU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_f_m_u).

> [!NOTE]
>
> Is written into modelDescription.xml, which is part of the exported [FMU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_f_m_u) archive.

### fmu\_model\_name

```cpp theme={null}
string fmu_model_name
```

Model name of the exported [FMU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_f_m_u).

> [!NOTE]
>
> Is written into modelDescription.xml, which is part of the exported [FMU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_f_m_u) archive.
