Mechanical API Migration Notes

As improvements are made to Mechanical APIs and the way that they display and transmit data, great efforts are taken to ensure that changes are backwards-compatible. For your convenience, this section lists 2024 R2 Mechanical API changes that might impact your existing scripts so that you can determine if any action is necessary before migrating them.


Note:  For general ACT migration information, see Migration Notes in the ACT Developer's Guide.


Behavior change for Tree.AllObjects

For geometries in a Mechanical system that are linked to an External Model system, if a geometry in Mechanical has a single body part, the part name will be the same as the body name. Consequently, this query now returns two matches:

[x for x in DataModel.Tree.AllObjects if x.Name=="Surface Body 1(External Model)"]

To get the body, run either of these queries instead:

SURFACE_BODY1 = DataModel.Tree.Find(name="Surface Body 1(External Model)")[0]

SURFACE_BODY1 = [x for x in DataModel.Tree.AllObjects if x.Name=="Surface Body 1(External Model)" and x.GetType()==Ansys.ACT.Automation.Mechanical.Body][0]

Set/GetLoadCombinationType
  • The behavior of SetLoadCombinationType/GetLoadCombinationType for the Solution Combination object has changed. The LoadCombinationType was previously an integer. Now the LoadCombinationType is set using an enum as shown below. In additon, GetLoadCombinationType returns an enum instead of integer

    Original:

    sc = Model.AddSolutionCombination()
    scdef = sc.Definition
    scdef.SetLoadCombinationType(0,1)

    Migrated:

    sc = Model.AddSolutionCombination()
    scdef = sc.Definition
    scdef.SetLoadCombinationType(0,LoadCombinationType.SRS)