Quantity function equivalent CPython

Dear All,
I am currently working on a script in Ansys Mechanical Scripting for which it is very easy to work with CPython (in BETA version unfortunately). Whatever, everything is working except when i have to define values which need the function Quantity (to define a temperature with attached unit for instance). Indeed, CPython does not recognize this Quantity function and return "Quantity" is not defined...
Any idea how can i bypass this difficulty ?

Thank you for your help,
Best regards,
Pierre

Answers

  • Mike.Thompson
    Mike.Thompson Member, Employee Posts: 240
    First Anniversary First Comment 5 Likes Ansys Employee

    Perhaps use the full path to the Quantity creator function. To get this, make a quantity in ironpython and then do MyQuantity.GetType()
    This will print the full object type path (I think it starts with Ansys. )

  • PierreLCV
    PierreLCV Member Posts: 24
    First Comment Name Dropper

    Dear Mike,
    Thank you for your quick reply !
    By typing Quantity.GetType(), i obtain:
    System.RuntimeType

    Not sure how can i use this...

    Thank you !
    Pierre

  • PierreLCV
    PierreLCV Member Posts: 24
    First Comment Name Dropper

    Dear Mike,
    Finally, I found ! To use Quantity in CPython, you just need to use the full link (as you said !)
    Ansys.Core.Units.Quantity()

    Problem fixed !

    Thank you !
    Pierre