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

# MacroFunction Class Reference

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

Definition of a single macro.

## Public Types

| Type | Name |
| - | - |
| enum | [eMeshType](#a780e3ecd635a51b0fd95798865bf59b0) \{  [ALL](#a780e3ecd635a51b0fd95798865bf59b0ab1d5eac4b1dca480c8056eaea7663b7a) = 0, [FEM](#a780e3ecd635a51b0fd95798865bf59b0a154e9b5357bed4c4d219188ca6307fbe), [GRID1D](#a780e3ecd635a51b0fd95798865bf59b0aa98690ce8950c246c4f3f01a4f7a061a), [GRID2D](#a780e3ecd635a51b0fd95798865bf59b0ae15336d9483644280ce6b341433a32f0),  [GRID3D](#a780e3ecd635a51b0fd95798865bf59b0a77756f32ebdf41b872da13882c7f6537)  } the enum data type for defining teh data type of the argument in script context |

## Public Member Functions

| Type | Name |
| - | - |
| | [addArg](#a34c2f0688d085969931dacae1bbab572) ([MacroArg](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_macro_arg.md) arg) adds a new argument to the end of the list |
| | [addRet](#adc9ad59339429434f4f5264f7082e80c) ([MacroArg](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_macro_arg.md) arg) adds a new return value to the end of the list |
| bool | [builderCompatible](#ad72b04d5c241d5013ae494a7e6a5444d) () |
| | [delArg](#ab8089d0d94e8c2777b1d916d16e2156f) (number i) erases the given argument from the list |
| | [delArgs](#a56070320bb7a6f0cfd74ef713e59841c) () erases all arguments from the list |
| | [delRet](#acda344069fda07e7be749a4275364fbc) (number i) erases the given return value from the list |
| | [delRets](#abd586c3832e1d673892228ef81071f15) () erases all return values from the list |
| string | [generateAutoTestMacro](#ab10c86a39058e4f25496e5aad78982be) () tries to generate a simplified test call of the defined function This may work, if all argument types are known. All values will be assigned to simplified defaults, like |
| [MacroArg](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_macro_arg.md) | [getArg](#a5c9c67e6f862bcf8ca468c8a5d769b85) (number i) |
|  string | [getHelp](#acec33d9069dae670176614e5edeec1b4) () gets m\_help |
|  string | [getIdent](#a8cf7d6a803e3c004fc7c8f79cfa68c30) () gets m\_func\_ident |
|  string | [getLongName](#a84a62e79fc4db9e03a7c34ab3a2f703b) () gets m\_func\_name\_long |
| string | [getMacro](#a71c3844280543a40bb76c70a2c5a828b) () gets the macro's code |
| [MacroArg](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_macro_arg.md) | [getRet](#a3b07ee91fca517295ee33aeedcbc5dc1) (number i) |
| std::vector\< [MacroArg](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_macro_arg.md) > | [getRets](#adab8ee51776d3ba36d190fd994869a34) () |
|  string | [getShortName](#adcc1a50f0500aa749944c4f30718f745) () gets m\_func\_name\_short |
|  string | [getTestMacro](#a2ad8a93da87e1c71eed3bbbcbc5e12e3) () Get cdoe to be executed to test this macro. |
|  string | [htmlHelp](#afeb5dfbeecea42a292841a25144bb201) () Get a html-Format help text. Includes a complete set of information of this [MacroFunction](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_macro_function.md), including arguments. |
| bool | [isHidden](#a451227147204d105046094b758ce3438) () const |
| | [MacroFunction](#a26650b23ff05d54b8790159090933669) () default constructor |
| [eMeshType](#a780e3ecd635a51b0fd95798865bf59b0) | [meshType](#a0c3181a72432b56a28e26dc267e03e9c) () const |
| bool | [needsMesh](#a9efdd2c387facefb8690c0f75448947f) () |
| number | [numArg](#acaf4e286d91a4645a3aab71156b80ce2) () |
| number | [numRet](#a65713576dbee7b0aaec0f982d614ae78) () |
| bool | [operator\<](#a47afb079614e0877c9fd531b4fb6f79f) ([MacroFunction](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_macro_function.md) other) a comparison operator used for std::set usage |
| string | [scriptChangeToFunction](#a3f780bb95596a963c14d39e6c80915c9) (string var\_ident, [MacroFunction](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_macro_function.md) other) identifies a script code that changes the function |
| | [setArg](#a26d997c6d5bc337447cc8baf8e337c5c) (number i, [MacroArg](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_macro_arg.md) arg) sets a new argument inside the vector |
| | [setHelp](#a3dc08a85532b2bfe34ab8d7aa14dc87a) (string s) sets m\_help |
| | [setHidden](#ac1eae8f6cde9616c5f0fe828e3a2e2c4) () hide macro Obscure the macro string. (Notice: ANSYS does not guarantee a strong encryption.) |
| | [setIdent](#a5f8048f93b77c41416eb9feb57f26dc2) (string s) sets m\_func\_ident |
| | [setLongName](#a2cad93a8a0b6c7ef572cc4554484b4a5) (string s) sets m\_func\_name\_long |
| | [setMacro](#a4ee7dec9efd650bb727b520b38deec17) (string s) set the macro's code |
| | [setMeshType](#a9e30eaf87c226168dc670e9ddc448d20) ([eMeshType](#a780e3ecd635a51b0fd95798865bf59b0) mesh\_type) sets the mesh type(s) being compatible with this macro |
| | [setNeedsMesh](#ac64f229a463a491cd30e37ff19fd9996) (bool needs\_mesh) |
| | [setRet](#aa201b9b70b6f4462cff2261c54c7fa3e) (number i, [MacroArg](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_macro_arg.md) arg) sets a new return value inside the vector |
| | [setShortName](#a10ab3b142028e4504d8450c731f6dabd) (string s) sets m\_func\_name\_short |
| | [setTestMacro](#a41c15fb3803eb47edfe16f762dc81241) (string s) Set code to be executed to test this macro. |

## Static Public Member Functions

| Type | Name |
| - | - |
| static bool | [validIdent](#a21521140ed5f808426bd3cdaba87281a) (string s) |

## Detailed Description

Definition of a single macro.

## Member Enumeration Documentation

### eMeshType

```cpp theme={null}
enum eMeshType
```

the enum data type for defining teh data type of the argument in script context

| Enumerator | |
| - | - |
| ALL | \< independent from mesh type (or all mesh types) |
| FEM | \< unstructured meshes |
| GRID1D | \< 1d structurted grids, eg. signals |
| GRID2D | \< 2d structured grids, eg. matrices |
| GRID3D | \< 3d structured grids, eg. voxels |

## Member Function Documentation

### addArg()

```cpp theme={null}
addArg(MacroArg arg)
```

adds a new argument to the end of the list

**Parameters**

| Name | Description |
| - | - |
| arg | the argument to be added |

### addRet()

```cpp theme={null}
addRet(MacroArg arg)
```

adds a new return value to the end of the list

**Parameters**

| Name | Description |
| - | - |
| arg | the return value to be added |

### builderCompatible()

```cpp theme={null}
bool builderCompatible()
```

**Returns**

true if this funtion can be used in the MacroBuilder

### delArg()

```cpp theme={null}
delArg(number i)
```

erases the given argument from the list

**Parameters**

| Name | Description |
| - | - |
| i | the existing index to be deleted, starting with 0 |

### delRet()

```cpp theme={null}
delRet(number i)
```

erases the given return value from the list

**Parameters**

| Name | Description |
| - | - |
| i | the existing index to be deleted, starting with 0 |

### generateAutoTestMacro()

```cpp theme={null}
string generateAutoTestMacro()
```

tries to generate a simplified test call of the defined function This may work, if all argument types are known. All values will be assigned to simplified defaults, like

* strings: empty
* numbers: 0
* matrices: 1x1, zero

  **Returns**

  the genrated test code or empty string (if not able to generate one)

### getArg()

```cpp theme={null}
MacroArg getArg(number i)
```

**Returns**

a reference to the specified argument

**Parameters**

| Name | Description |
| - | - |
| i | the index of the argument, starting with 0 |

### getMacro()

```cpp theme={null}
string getMacro()
```

gets the macro's code

**Exceptions**

| Name | Description |
| - | - |
| execption | if the macro is hidden |

### getRet()

```cpp theme={null}
MacroArg getRet(number i)
```

**Returns**

a reference to the specified return value

**Parameters**

| Name | Description |
| - | - |
| i | the index of the return value, starting with 0 |

### getRets()

```cpp theme={null}
std::vector< MacroArg > getRets()
```

**Returns**

a reference to the vector of MacroArgs

### isHidden()

```cpp theme={null}
bool isHidden() const
```

**Returns**

true if the macro is hidden

### meshType()

```cpp theme={null}
eMeshType meshType() const
```

**Returns**

the mesh type(s) being compatible with this macro

### needsMesh()

```cpp theme={null}
bool needsMesh()
```

**Returns**

true if this function needs a mesh

### numArg()

```cpp theme={null}
number numArg()
```

**Returns**

the number of defined arguments

### numRet()

```cpp theme={null}
number numRet()
```

**Returns**

the number of defined return values

### operator\<()

```cpp theme={null}
bool operator<(MacroFunction other)
```

a comparison operator used for std::set usage

**Parameters**

| Name | Description |
| - | - |
| other | the other function to be compared |

**Returns**

true if the ident of this function is "smaller" than the ident of the other function.

> [!NOTE]
>
> The "smaller" operator also checks if "numbers" are at the end of the ident, we try to resolve this according to "human ordering", e.g. "chunk\_9" \< "chunk\_10"

### scriptChangeToFunction()

```cpp theme={null}
string scriptChangeToFunction(
    string var_ident,
    MacroFunction other
)
```

identifies a script code that changes the function

**Parameters**

| Name | Description |
| - | - |
| other | the other function wotr which the differences are checked. |
| var\_ident | the variable ident in script to be changed. |

**Returns**

the script code to change this function to match the other on

### setArg()

```cpp theme={null}
setArg(
    number i,
    MacroArg arg
)
```

sets a new argument inside the vector

**Parameters**

| Name | Description |
| - | - |
| i | an existing index in the list, starting with 0 |
| arg | the new argument to be set |

### setHidden()

```cpp theme={null}
setHidden()
```

hide macro Obscure the macro string. (Notice: ANSYS does not guarantee a strong encryption.)

> [!WARNING]
>
> cannot be undone

### setMeshType()

```cpp theme={null}
setMeshType(eMeshType mesh_type)
```

sets the mesh type(s) being compatible with this macro

**Parameters**

| Name | Description |
| - | - |
| mesh\_type | the new value |

### setNeedsMesh()

```cpp theme={null}
setNeedsMesh(bool needs_mesh)
```

**Parameters**

| Name | Description |
| - | - |
| sets | the property if the function needs mesh |
| needs\_mesh | true if this function needs a mesh |

### setRet()

```cpp theme={null}
setRet(
    number i,
    MacroArg arg
)
```

sets a new return value inside the vector

**Parameters**

| Name | Description |
| - | - |
| i | an existing index in the list, starting with 0 |
| arg | the new return value to be set |

### validIdent()

```cpp theme={null}
static bool validIdent(string s)
```

`static`

**Returns**

true if the ident s can be used in Lua

**Parameters**

| Name | Description |
| - | - |
| s | the ident to be checked |
