Forum Navigation
You need to log in to create posts and topics.

Is it possible to round of the values while rendering

Hello Constanze,

I'm doing DXA analysis and while rendering I used Text label to add the Tot. Dislocation Length value in the movie but actually after the decimal, it's going up to 12 digit which is actually not very meaningful or physical, So I wanted to just keep it till 2 digits after the decimal.

By any means is possible. I tried to do it with python script but I didn't succeed.




Uploaded files:
  • Screenshot-from-2020-10-07-05-25-57.png

Hi Prash,

We are working on giving the user more control over the formatting of numbers in OVITO's text label layer. For the time being, however, a Python modifier function is required to gain full control over the number format. The Python modifier function should be inserted into the data pipeline, turning the floating-point representation into a string representation. Here is an example showing how to round the dislocation length attribute to one decimal place:

def modify(frame, data):
    data.attributes['DislocationAnalysis.total_line_length'] = '{:.1f}'.format(data.attributes['DislocationAnalysis.total_line_length'])

For more number formatting options, see this page for example.


Hi Alex,

Thank you so much again 🙂

It works perfectly.

Have a nice day.