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: 330
    25 Answers First Anniversary 100 Comments 25 Likes
    ✭✭✭✭

    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: 35
    10 Comments 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: 35
    10 Comments 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