    

 ## On this page

  

 

 # MacroExporter Class Reference

 Last update: 16.07.2025 

Export Statistics on Structures macross built with the MacroBuilder and export the resulting workflow as a Functional Mockup Unit ([FMU](class_f_m_u.xhtml)), for further use e.g. in Ansys OptiSLang. [More...](class_macro_exporter.xhtml#details)

## <a id="pub-methods" name="pub-methods"></a>Public Member Functions

 [addInputArg](class_macro_exporter.xhtml#aa66f1f2a43be5e47521d5fe7d467561a) (macro::MacroArg inputArg) Add an input argument. Only scalar input arguments are exposed as an [FMU](class_f_m_u.xhtml) 2.0 input. [More...](#aa66f1f2a43be5e47521d5fe7d467561a)  
  [addOutputArg](class_macro_exporter.xhtml#a948a4c1cf3a67539eae217ed0896d12e) (macro::MacroArg outputArg) Add an output argument. Only scalar output arguments are exposed as an [FMU](class_f_m_u.xhtml) 2.0 output. [More...](#a948a4c1cf3a67539eae217ed0896d12e)  
  [exportFMU2](class_macro_exporter.xhtml#a67a8b4f80b7a79cfa9613eeb2d139953) (string filename) Write an [FMU](class_f_m_u.xhtml) 2.0 file to disk Creates an .fmu archive containing the macro, a minimal database file, the necessary SoS libraries and the [FMU](class_f_m_u.xhtml) modelDescription.xml file. [More...](#a67a8b4f80b7a79cfa9613eeb2d139953)  
 <a id="add9901725fee3dba2798644e14f2793e"></a> [exportSDB](class_macro_exporter.xhtml#add9901725fee3dba2798644e14f2793e) (string filename) Write an SDB file, containing the macro created with the MacroBuilder.   
 <a id="a391cbad9a69a4732f82c4ea2fdcd5a54"></a> [MacroExporter](class_macro_exporter.xhtml#a391cbad9a69a4732f82c4ea2fdcd5a54) () Construct a [MacroExporter](class_macro_exporter.xhtml "Export Statistics on Structures macross built with the MacroBuilder and export the resulting workflow...") to export a macro workflow as an [FMU](class_f_m_u.xhtml) 2.0.   
  [setDllPath](class_macro_exporter.xhtml#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](class_f_m_u.xhtml) libraries. [More...](#a682461752380b2bbb0339143e5bd5a5e)  
 ## <a id="pub-attribs" name="pub-attribs"></a>Public Attributes

string [fmu\_author](class_macro_exporter.xhtml#a673353efb2f3c3226804f1d092f6b2c9) Author of the exported [FMU](class_f_m_u.xhtml). [More...](#a673353efb2f3c3226804f1d092f6b2c9)  
 <a id="a66ecd1a38a225ff328d907d2b2d82b3a"></a>string [fmu\_independent\_variable](class_macro_exporter.xhtml#a66ecd1a38a225ff328d907d2b2d82b3a) = "" Set the name of the independent variable of the exported [FMU](class_f_m_u.xhtml). 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](class_f_m_u.xhtml)'s inputs and outputs are not a function of an independent variable.   
 string [fmu\_model\_description](class_macro_exporter.xhtml#a3d112ff2dfe59a23793aece49bc1286b) Model description of the exported [FMU](class_f_m_u.xhtml). [More...](#a3d112ff2dfe59a23793aece49bc1286b)  
 string [fmu\_model\_name](class_macro_exporter.xhtml#a5fc548655b0cd078bce2bb9de42c8f4b) Model name of the exported [FMU](class_f_m_u.xhtml). [More...](#a5fc548655b0cd078bce2bb9de42c8f4b)  
 <a id="a2f8b3cba47ad64fb6bda4b6428a032d3"></a>bool [replace\_files](class_macro_exporter.xhtml#a2f8b3cba47ad64fb6bda4b6428a032d3) = false If false, an already existing exported files are not overwritten. Instead an error message is displayed.   
 <a id="a06cd29eee2d80e63ad5f041401b76f99"></a>string [script](class_macro_exporter.xhtml#a06cd29eee2d80e63ad5f041401b76f99) The Lua script function to be executed at each [FMU](class_f_m_u.xhtml) 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](class_f_m_u.xhtml) execution are the database and the design\_id sos.log(3, 'Calling [FMU](class_f_m_u.xhtml) macro workflow for design ID ' .. design\_id .. ' ...') –optional logging –any number of macros. All macro arguments to be deliverd through the [FMU](class_f_m_u.xhtml) interface, must be added using addInputVariable() or addOutputVariable() at the [MacroExporter](class_macro_exporter.xhtml "Export Statistics on Structures macross built with the MacroBuilder and export the resulting workflow..."). 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.   
 <a id="details" name="details"></a>## Detailed Description

Export Statistics on Structures macross built with the MacroBuilder and export the resulting workflow as a Functional Mockup Unit ([FMU](class_f_m_u.xhtml)), for further use e.g. in Ansys OptiSLang.

The [MacroExporter](class_macro_exporter.xhtml "Export Statistics on Structures macross built with the MacroBuilder and export the resulting workflow...") is invoked when exporting a macrobased [FMU](class_f_m_u.xhtml) from the graphical user interface. It gathers all inputs and outputs from the macro created with the MacroBuilder passed to the [MacroExporter](class_macro_exporter.xhtml "Export Statistics on Structures macross built with the MacroBuilder and export the resulting workflow...").

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



## Member Function Documentation

<a id="aa66f1f2a43be5e47521d5fe7d467561a"></a>## [◆ ](#aa66f1f2a43be5e47521d5fe7d467561a)addInputArg()

 addInputArg  ( macro::MacroArg  *inputArg*) 

Add an input argument. Only scalar input arguments are exposed as an [FMU](class_f_m_u.xhtml) 2.0 input.

Parameters inputArgThe input argument to add. 



<a id="a948a4c1cf3a67539eae217ed0896d12e"></a>## [◆ ](#a948a4c1cf3a67539eae217ed0896d12e)addOutputArg()

 addOutputArg  ( macro::MacroArg  *outputArg*) 

Add an output argument. Only scalar output arguments are exposed as an [FMU](class_f_m_u.xhtml) 2.0 output.

Parameters outputArgThe output argument to add. 



<a id="a67a8b4f80b7a79cfa9613eeb2d139953"></a>## [◆ ](#a67a8b4f80b7a79cfa9613eeb2d139953)exportFMU2()

 exportFMU2  ( string  *filename*) 

Write an [FMU](class_f_m_u.xhtml) 2.0 file to disk Creates an .fmu archive containing the macro, a minimal database file, the necessary SoS libraries and the [FMU](class_f_m_u.xhtml) modelDescription.xml file.

Parameters filenameRelative or absolute path to the .fmu archive to be written. replace\_filesIf True, an existing filename is overwritten without warning. If false and filename already exists, an error is thrown. 



<a id="a682461752380b2bbb0339143e5bd5a5e"></a>## [◆ ](#a682461752380b2bbb0339143e5bd5a5e)setDllPath()

 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](class_f_m_u.xhtml) libraries.

Parameters pathAbsolute path to the SoS library directory. 



## Member Data Documentation

<a id="a673353efb2f3c3226804f1d092f6b2c9"></a>## [◆ ](#a673353efb2f3c3226804f1d092f6b2c9)fmu\_author

 string fmu\_author

Author of the exported [FMU](class_f_m_u.xhtml).

NoteIs written into modelDescription.xml, which is part of the exported [FMU](class_f_m_u.xhtml) archive. 



<a id="a3d112ff2dfe59a23793aece49bc1286b"></a>## [◆ ](#a3d112ff2dfe59a23793aece49bc1286b)fmu\_model\_description

 string fmu\_model\_description

Model description of the exported [FMU](class_f_m_u.xhtml).

NoteIs written into modelDescription.xml, which is part of the exported [FMU](class_f_m_u.xhtml) archive. 



<a id="a5fc548655b0cd078bce2bb9de42c8f4b"></a>## [◆ ](#a5fc548655b0cd078bce2bb9de42c8f4b)fmu\_model\_name

 string fmu\_model\_name

Model name of the exported [FMU](class_f_m_u.xhtml).

NoteIs written into modelDescription.xml, which is part of the exported [FMU](class_f_m_u.xhtml) archive.