Forum

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - justinT

Pages: [1]
1
Python and Java API / Set distances of scalebars via Python API
« on: May 26, 2022, 03:59:25 AM »
Hi all,

I am trying to update the distances of scalebars via the Python API of Metashape. However, it turned out that my code does not work. Please kindly find my code as follows:
Code: [Select]
    chunk.addScalebar(chunk.markers[0], chunk.markers[1])
    chunk.addScalebar(chunk.markers[0], chunk.markers[2])
    chunk.addScalebar(chunk.markers[0], chunk.markers[3])
    chunk.addScalebar(chunk.markers[1], chunk.markers[2])
    chunk.addScalebar(chunk.markers[1], chunk.markers[3])
    chunk.addScalebar(chunk.markers[2], chunk.markers[3])

    chunk.sortScalebars()
    #Input distance of scalebars.
    chunk.scalebars[0].Reference.distance = 0.03
    chunk.scalebars[1].Reference.distance = 0.04
    chunk.scalebars[2].Reference.distance = 0.05
    chunk.scalebars[3].Reference.distance = 0.05
    chunk.scalebars[4].Reference.distance = 0.04
    chunk.scalebars[5].Reference.distance = 0.03

This code does not give me any error or warning. However, the corresponding distances will not change accordingly.

However, I found it is possible for me to rename the scalebars via the code:

Code: [Select]
chunk.scalebars[0].label = "example_scalebar"

Thus, I was wondering if I might be looking at the wrong functions/objects to change the distance.

Thank you so much for your attention.

Pages: [1]