Skip to main content

optiSLang 3D Postprocessing Script API 2025 R1

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), for further use e.g. in Ansys OptiSLang. More...

Public Member Functions

 addInputArg (macro::MacroArg inputArg)
 Add an input argument. Only scalar input arguments are exposed as an FMU 2.0 input. More...
 
 addOutputArg (macro::MacroArg outputArg)
 Add an output argument. Only scalar output arguments are exposed as an FMU 2.0 output. More...
 
 exportFMU2 (string filename)
 Write an FMU 2.0 file to disk Creates an .fmu archive containing the macro, a minimal database file, the necessary SoS libraries and the FMU modelDescription.xml file. More...
 
 exportSDB (string filename)
 Write an SDB file, containing the macro created with the MacroBuilder.
 
 MacroExporter ()
 Construct a MacroExporter to export a macro workflow as an FMU 2.0.
 
 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 libraries. More...
 

Public Attributes

string fmu_author
 Author of the exported FMU. More...
 
string fmu_independent_variable = ""
 Set the name of the independent variable of the exported FMU. 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's inputs and outputs are not a function of an independent variable.
 
string fmu_model_description
 Model description of the exported FMU. More...
 
string fmu_model_name
 Model name of the exported FMU. More...
 
bool replace_files = false
 If false, an already existing exported files are not overwritten. Instead an error message is displayed.
 
string script
 The Lua script function to be executed at each FMU 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 execution are the database and the design_id sos.log(3, 'Calling FMU macro workflow for design ID ' .. design_id .. ' ...') –optional logging –any number of macros. All macro arguments to be deliverd through the FMU interface, must be added using addInputVariable() or addOutputVariable() at the MacroExporter. 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), for further use e.g. in Ansys OptiSLang.

The MacroExporter is invoked when exporting a macrobased FMU from the graphical user interface. It gathers all inputs and outputs from the macro created with the MacroBuilder passed to the MacroExporter.

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()

addInputArg ( macro::MacroArg  inputArg)

Add an input argument. Only scalar input arguments are exposed as an FMU 2.0 input.

Parameters
inputArgThe input argument to add.

◆ addOutputArg()

addOutputArg ( macro::MacroArg  outputArg)

Add an output argument. Only scalar output arguments are exposed as an FMU 2.0 output.

Parameters
outputArgThe output argument to add.

◆ exportFMU2()

exportFMU2 ( string  filename)

Write an FMU 2.0 file to disk Creates an .fmu archive containing the macro, a minimal database file, the necessary SoS libraries and the FMU 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.

◆ 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 libraries.

Parameters
pathAbsolute path to the SoS library directory.

Member Data Documentation

◆ fmu_author

string fmu_author

Author of the exported FMU.

Note
Is written into modelDescription.xml, which is part of the exported FMU archive.

◆ fmu_model_description

string fmu_model_description

Model description of the exported FMU.

Note
Is written into modelDescription.xml, which is part of the exported FMU archive.

◆ fmu_model_name

string fmu_model_name

Model name of the exported FMU.

Note
Is written into modelDescription.xml, which is part of the exported FMU archive.

Connect with Ansys