How to use numpy in Mechanical Scripting?

ZZ.tang Member Posts: 14
Name Dropper First Comment

Ansys 2023 R1

Best Answer

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 813
    First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
    Answer ✓

    Hi @ZZ.tang , currently Mechanical Scripting is based on IronPython, so it is not possible to use Numpy, which is based on CPython. There is a beta option you can turn on to activate the possibility to use CPython in Mechanical but it is beta (ie, we do not guarantee it will work and do not provide support over it).
    From the WB project schematic, go to tools /options / appearance and select "beta option":

    Then, in the same menu, go to Mechanical and activate "Show CPython Capability":

    Another method to be able to use Numpy with Mechanical would be to use PyMechanical.