Separate value from unit

Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 732
First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
edited June 2023 in Structures

In the following piece of code:

solution = ExtAPI.DataModel.Project.Model.Analyses[0].Solution # reference solution
results = solution.GetChildren(DataModelObjectCategory.Result,True) # get list of results in solution
time=list()
for result in results:
  time.append(result.Time)
print(time)

I get both value of time and unit of time in the list.


How can I get on the value, and not the unit?

Tagged:

Best Answer

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

    You can use:

    result.Time.Value
    result.Time.Unit
    

    to only retrieve the value or the unit.