24R2 changes to Mechanical API crashed plugins

Member Posts: 13
First Anniversary Name Dropper First Comment
**

Some time ago I was informed that there would be no changes to Ansys ACT API in further releases. But now I've switched from 24R1 to 24R2 and a function I used for a long time to extract the internal and external radius of a pipe cross-section stopped working, crashing multiple plugins/scripts I did.

There was no warning message that this function was obsolete. Why was it changed? Is there any document where that change was noted? Are there more functions that are being turned off?

Code:
geo_body = analysis.GeoData.GeoEntityById(edge_id).Bodies[0]
cross_sec = geo_body.CrossSection
geo_rad_out = cross_sec.Input.Variables.Item(2).Value(1)
geo_rad_int = cross_sec.Input.Variables.Item(1).Value(1)

Error msg:
AttributeError: '__ComObject' object has no attribute 'Input'

Tagged:

Best Answer

  • Member, Employee Posts: 2
    First Answer Photogenic Name Dropper First Comment
    ✭✭✭
    Answer ✓

    Hello, @Mateusz! You are welcome, I am happy to hear that the information was useful. I do support the recommendations of the Account Manager to watch for obsolete functions. The intent is for the obsolete messaging to also reference the replacement API (if a replacement API is needed or exists).

    Now, about these excellent questions:


    Is it safe to assume that if an API is automatically filled using Intellisense, it is considered published every time?

    Yes, everything shown in Intellisense should be published.


    Is everything found using dir() also considered published?

    No, dir() will also show unpublished items. The omission of Value and Unit from the Quantity type are an oversight that will be corrected. Regardless, it should be safe to continue using these Quantity APIs with confidence.

Answers

  • Member, Employee Posts: 2
    First Answer Photogenic Name Dropper First Comment
    ✭✭✭

    Hi @Mateusz! I think there is a little confusion regarding what is or is not changing.

    • ACT (Ansys Customization Toolkit) is not changing.
    • Mechanical Scripting API is under active development. You are correct: the removal of any documented Mechanical API functions will proceed through an obsoleting process.

    In reviewing the code snippet provided, it appears that unpublished functionality is being used. In effect, there is no "obsoleting" process for unpublished functionality because it is intended solely for internal usage. For future reference, both the Mechanical Scripting Intellisense and the Mechanical API reference will show published APIs; CrossSection.Input does not appear in the Mechanical API documentation sources for either 24R1 or 24R2.

    Extending from the code provided above, here is the recommended approach to get the CrossSection data:

    1. body = Model.Geometry.GetBody(geo_body)
    2. cross_sec = body.CrossSectionSelection
    3. geo_rad_out = cross_sec.OuterRadius
    4. geo_rad_in = cross_sec.InnerRadius

    Note: the cross section properties will return dimensions as a Quantity. Use geom_rad_in.Value to get the numeric value and geom_rad_in.Unit to get the unit. It is also possible to get a Quantity instance with a different unit by using km_geom_rad_in = geom_rad_in.ConvertUnit('km').

  • Member Posts: 13
    First Anniversary Name Dropper First Comment
    **

    Hello @Brycen Wendt, thanks for a quick respond!

    Some time ago, our Account Manager informed us that the scripts/plugins we developed should be compatible with future Ansys versions. We were advised to monitor functions that might become obsolete, which should be indicated in the log before they are deprecated. Our management was concerned about maintaining internally-developed plugins.

    I acknowledge that CrossSection.Input was undocumented; I likely sourced it from an older code file attached to one of the Ansys Store free plugins. I think it was ASMEPipeCheck.

    Is it safe to assume that if an API is automatically filled using Intellisense, it is considered published every time?
    Additionally, there are APIs not mentioned by Intellisense, such as cross_sec.OuterRadius, where you won't get Value or Unit using it. To discover its presence, you need to use dir(cross_sec.OuterRadius). Is everything found using dir() also considered published?
    I don't frequently use the Mechanical API reference (ACTRefecenteHTML from Customer Portal) because I don't find it very convenient.

    Thanks for the tip in the note! I didn't realize you could convert units without importing the units library. It's really handy to get the converted value in just one line!
    geo_rad_int = cross_sec.InnerRadius.ConvertUnit(geodata_unit).Value

Welcome!

It looks like you're new here. Sign in or register to get started.