    

 ## On this page

  

 

 # `PythonCode`

 Last update: 16.07.2025 

<a id="ansys.mechanical.stubs.v242.Ansys.ACT.Automation.Mechanical.PythonCode"></a>

#### *class* Ansys.ACT.Automation.Mechanical.PythonCode

Bases: [`object`](https://docs.python.org/3/library/functions.html#object)

Defines a PythonCode.

<a id="overview"></a>

## Overview

### Methods

NameDescription[`Activate`](#PythonCode.Activate)Activate the current object.[`Connect`](#PythonCode.Connect)Register the python code.[`CopyTo`](#PythonCode.CopyTo)Copies all visible properties from this object to another.[`CreateParameter`](#PythonCode.CreateParameter)Creates a new parameter for a Property.[`Delete`](#PythonCode.Delete)Run the Delete action.[`Duplicate`](#PythonCode.Duplicate)Duplicate method.[`GetParameter`](#PythonCode.GetParameter)Gets the parameter corresponding to the given property.[`GroupAllSimilarChildren`](#PythonCode.GroupAllSimilarChildren)Run the GroupAllSimilarChildren action.[`GroupSimilarObjects`](#PythonCode.GroupSimilarObjects)Run the GroupSimilarObjects action.[`PropertyByAPIName`](#PythonCode.PropertyByAPIName)Get a property by its API name.[`PropertyByName`](#PythonCode.PropertyByName)Get a property by its unique name.[`ReloadProperties`](#PythonCode.ReloadProperties)Reload properties to update properties provided by the provider.[`RemoveParameter`](#PythonCode.RemoveParameter)Removes the parameter from the parameter set corresponding to the given property.### Properties

NameDescription[`AllowRecursion`](#PythonCode.AllowRecursion)Gets or Sets whether the PythonCode allows recursion.[`Connected`](#PythonCode.Connected)Gets whether the callbacks are currently connected.[`DataModelObjectCategory`](#PythonCode.DataModelObjectCategory)Gets the current DataModelObject’s category.[`InternalObject`](#PythonCode.InternalObject)Gets the internal object. For advanced usage only.[`Properties`](#PythonCode.Properties)Gets the list of properties for this object.[`PropertyProvider`](#PythonCode.PropertyProvider)Gets or sets the propperty provider instance associated with this python code object.[`ScriptExecutionScope`](#PythonCode.ScriptExecutionScope)The scope identifier in which the code execution will take place.[`Text`](#PythonCode.Text)Gets or sets the text in the script tab for the Python Code object.[`VisibleProperties`](#PythonCode.VisibleProperties)Gets the list of properties that are visible for this object.<a id="property-detail"></a>

## Property detail

<a id="PythonCode.AllowRecursion"></a>

### *property* PythonCode.AllowRecursion *: [bool](https://docs.python.org/3/library/functions.html#bool) | [None](https://docs.python.org/3/library/constants.html#None)*

Gets or Sets whether the PythonCode allows recursion.

<a id="PythonCode.Connected"></a>

### *property* PythonCode.Connected *: [bool](https://docs.python.org/3/library/functions.html#bool) | [None](https://docs.python.org/3/library/constants.html#None)*

Gets whether the callbacks are currently connected.

<a id="PythonCode.DataModelObjectCategory"></a>

### *property* PythonCode.DataModelObjectCategory *: [Ansys.Mechanical.DataModel.Enums.DataModelObjectCategory](../../../Mechanical/DataModel/Enums/DataModelObjectCategory.md#ansys.mechanical.stubs.v242.Ansys.Mechanical.DataModel.Enums.DataModelObjectCategory) | [None](https://docs.python.org/3/library/constants.html#None)*

Gets the current DataModelObject’s category.

<a id="PythonCode.InternalObject"></a>

### *property* PythonCode.InternalObject *: Ansys.Common.Interop.DSObjectsAuto.IDSPythonCodeAuto | [None](https://docs.python.org/3/library/constants.html#None)*

Gets the internal object. For advanced usage only.

<a id="PythonCode.Properties"></a>

### *property* PythonCode.Properties *: [tuple](https://docs.python.org/3/library/stdtypes.html#tuple)\[Ansys.ACT.Automation.Mechanical.Property\] | [None](https://docs.python.org/3/library/constants.html#None)*

Gets the list of properties for this object.

<a id="PythonCode.PropertyProvider"></a>

### *property* PythonCode.PropertyProvider *: Ansys.ACT.Interfaces.Mechanical.IPropertyProvider | [None](https://docs.python.org/3/library/constants.html#None)*

Gets or sets the propperty provider instance associated with this python code object.

<a id="PythonCode.ScriptExecutionScope"></a>

### *property* PythonCode.ScriptExecutionScope *: [str](https://docs.python.org/3/library/stdtypes.html#str) | [None](https://docs.python.org/3/library/constants.html#None)*

The scope identifier in which the code execution will take place.

<a id="PythonCode.Text"></a>

### *property* PythonCode.Text *: [str](https://docs.python.org/3/library/stdtypes.html#str) | [None](https://docs.python.org/3/library/constants.html#None)*

Gets or sets the text in the script tab for the Python Code object.

<a id="PythonCode.VisibleProperties"></a>

### *property* PythonCode.VisibleProperties *: [tuple](https://docs.python.org/3/library/stdtypes.html#tuple)\[Ansys.ACT.Automation.Mechanical.Property\] | [None](https://docs.python.org/3/library/constants.html#None)*

Gets the list of properties that are visible for this object.

<a id="method-detail"></a>

## Method detail

<a id="PythonCode.Activate"></a>

### PythonCode.Activate()

Activate the current object.

<a id="PythonCode.Connect"></a>

### PythonCode.Connect()

Register the python code.

<a id="PythonCode.CopyTo"></a>

### PythonCode.CopyTo(other: Ansys.ACT.Automation.Mechanical.DataModelObject)

Copies all visible properties from this object to another.

<a id="PythonCode.CreateParameter"></a>

### PythonCode.CreateParameter(propName: [str](https://docs.python.org/3/library/stdtypes.html#str))

Creates a new parameter for a Property.

<a id="PythonCode.Delete"></a>

### PythonCode.Delete()

Run the Delete action.

<a id="PythonCode.Duplicate"></a>

### PythonCode.Duplicate()

Duplicate method.

<a id="PythonCode.GetParameter"></a>

### PythonCode.GetParameter(propName: [str](https://docs.python.org/3/library/stdtypes.html#str))

Gets the parameter corresponding to the given property.

<a id="PythonCode.GroupAllSimilarChildren"></a>

### PythonCode.GroupAllSimilarChildren()

Run the GroupAllSimilarChildren action.

<a id="PythonCode.GroupSimilarObjects"></a>

### PythonCode.GroupSimilarObjects()

Run the GroupSimilarObjects action.

<a id="PythonCode.PropertyByAPIName"></a>

### PythonCode.PropertyByAPIName(name: [str](https://docs.python.org/3/library/stdtypes.html#str))

```text
Get a property by its API name.
If multiple properties have the same API Name, only the first property with that name will be returned.

```

<a id="PythonCode.PropertyByName"></a>

### PythonCode.PropertyByName(name: [str](https://docs.python.org/3/library/stdtypes.html#str))

Get a property by its unique name.

<a id="PythonCode.ReloadProperties"></a>

### PythonCode.ReloadProperties()

Reload properties to update properties provided by the provider.

<a id="PythonCode.RemoveParameter"></a>

### PythonCode.RemoveParameter(propName: [str](https://docs.python.org/3/library/stdtypes.html#str))

Removes the parameter from the parameter set corresponding to the given property.