Separate value from unit

Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 871
100 Answers 500 Comments 250 Likes First Anniversary
✭✭✭✭
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: 871
    100 Answers 500 Comments 250 Likes First Anniversary
    ✭✭✭✭
    Answer ✓

    You can use:

    result.Time.Value
    result.Time.Unit
    

    to only retrieve the value or the unit.