Skip to main content

Mechanical scripting interface

PythonCode

Last update: 14.01.2025

class Ansys.ACT.Automation.Mechanical.PythonCode

Bases: object

Defines a PythonCode.

Overview

Methods

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

Properties

Name Description
AllowRecursion Gets or Sets whether the PythonCode allows recursion.
Connected Gets whether the callbacks are currently connected.
DataModelObjectCategory Gets the current DataModelObject’s category.
InternalObject Gets the internal object. For advanced usage only.
Properties Gets the list of properties for this object.
PropertyProvider Gets or sets the propperty provider instance associated with this python code object.
ScriptExecutionScope The scope identifier in which the code execution will take place.
Text Gets or sets the text in the script tab for the Python Code object.
VisibleProperties Gets the list of properties that are visible for this object.

Property detail

property PythonCode.AllowRecursion : bool | None

Gets or Sets whether the PythonCode allows recursion.

property PythonCode.Connected : bool | None

Gets whether the callbacks are currently connected.

property PythonCode.DataModelObjectCategory : Ansys.Mechanical.DataModel.Enums.DataModelObjectCategory | None

Gets the current DataModelObject’s category.

property PythonCode.InternalObject : Ansys.Common.Interop.DSObjectsAuto.IDSPythonCodeAuto | None

Gets the internal object. For advanced usage only.

property PythonCode.Properties : tuple[Ansys.ACT.Automation.Mechanical.Property] | None

Gets the list of properties for this object.

property PythonCode.PropertyProvider : Ansys.ACT.Interfaces.Mechanical.IPropertyProvider | None

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

property PythonCode.ScriptExecutionScope : str | None

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

property PythonCode.Text : str | None

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

property PythonCode.VisibleProperties : tuple[Ansys.ACT.Automation.Mechanical.Property] | None

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

Method detail

PythonCode.Activate()

Activate the current object.

PythonCode.Connect()

Register the python code.

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

Copies all visible properties from this object to another.

PythonCode.CreateParameter(propName: str)

Creates a new parameter for a Property.

PythonCode.Delete()

Run the Delete action.

PythonCode.Duplicate()

Duplicate method.

PythonCode.GetParameter(propName: str)

Gets the parameter corresponding to the given property.

PythonCode.GroupAllSimilarChildren()

Run the GroupAllSimilarChildren action.

PythonCode.GroupSimilarObjects()

Run the GroupSimilarObjects action.

PythonCode.PropertyByAPIName(name: str)

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.

PythonCode.PropertyByName(name: str)

Get a property by its unique name.

PythonCode.ReloadProperties()

Reload properties to update properties provided by the provider.

PythonCode.RemoveParameter(propName: str)

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