Forum

Author Topic: Import Scalebars between Markers  (Read 6497 times)

ser1993

  • Newbie
  • *
  • Posts: 11
    • View Profile
Import Scalebars between Markers
« on: November 06, 2023, 02:04:26 AM »
Hi,

Would it be possible to have a feature where you can easily import scale bars between markers from a CSV file?
This feature is very helpful for projects where you always have the same markers and you change the object in the middle (i.e. turntable). It takes so much time to place scalebars manually every time! For instance, you can prepare a CSV with

Code: [Select]
NAMESCALEBAR; MARKER1; MARKER2; MEASURE
and import it every time you need it.

Thanks,
Matteo

ser1993

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Import Scalebars between Markers
« Reply #1 on: December 01, 2023, 09:58:16 AM »
Nobody can help me with that?

drewjgray

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Import Scalebars between Markers
« Reply #2 on: December 23, 2023, 12:15:45 AM »
Hey ser1993, you can do this quite easily with the python api if you are familiar with it. Here is an example. I auto-detect 3 circular 12bit markers which are each 1 meter apart. Once the markers are detected you can use the python api to automatically create scale bars. Here is my code below:

Code: [Select]
def create_scale_bars(self):
        print('Creating scale bars...')
        marker1, marker2, marker3 = None, None, None
        for marker in self.chunk.markers:
            if marker.label == 'target 1':
                marker1 = marker
            elif marker.label == 'target 2':
                marker2 = marker
            elif marker.label == 'target 3':
                marker3 = marker

        distance = 1.0
        if marker1 and marker2 and marker3:
            scale_bar1 = self.chunk.addScalebar(marker1, marker2)
            scale_bar1.reference.distance = distance
            print(f'Scale bar of {distance}m added between "target 1" and "target 2"')
            scale_bar2 = self.chunk.addScalebar(marker1, marker3)
            scale_bar2.reference.distance = distance
            print(f'Scale bar of {distance}m added between "target 1" and "target 2"')
        else:
            print("Markers not found")
       
        self.doc.save()