Topic: Three-figure bearings - how to display leading zeros?

I have a parameter n to represent the bearing, going from 0 to 360.

I have a text box displaying the value of n : Bearing = %(n)

But how can I get it to display "00"n when n < 10 and "0"n when 10 < n < 100?

Re: Three-figure bearings - how to display leading zeros?

I have attached a plugin, which you can install in the beta version of Graph 4.5 with the Plugin Manager.
It will allow you to use the Python format function in a text label. For example you can write: Bearing = %format("n", "03.0f")
It will show the value of n with at width of at least 3, fill '0' in front of the value if needed and show no decimals.

You can find more information about how to use the format specification here:
https://docs.python.org/3/library/strin … formatspec

Post's attachments

Attachment icon TextFormatting.py 1.88 kb, 400 downloads since 2021-04-04 

Re: Three-figure bearings - how to display leading zeros?

Thank you Ivan, you are very helpful.

Re: Three-figure bearings - how to display leading zeros?

Hi Ivan,

It took a while, but our IT department have now installed 4.5 Beta for me. The new interface looks nice.

It was easy to import your Text Formatting python file to Plugins. Sure enough, it now displays 0 degrees as 000 degrees, but when I animate the diagram the text does not change. Please see attached.

Can you see what is wrong please?

Post's attachments

Attachment icon 3-figure bearings new.grf 2.45 kb, 359 downloads since 2021-05-12 

Attachment icon 3-figure bearings old.grf 2.43 kb, 363 downloads since 2021-05-12