Forum

Author Topic: Chunk Region Control Script  (Read 5310 times)

Vladimir Denisov

  • Jr. Member
  • **
  • Posts: 79
    • View Profile
Chunk Region Control Script
« on: November 30, 2021, 06:59:44 PM »
Simple script for chunk region control. It move and scale to relative current transform. Agisoft, you can include it into your repository.

Get script  from GitHub Gist






Costas

  • Jr. Member
  • **
  • Posts: 70
  • Aerial Mapping
    • View Profile
Re: Chunk Region Control Script
« Reply #1 on: December 01, 2021, 02:40:39 PM »
I'm not good at scripting.

I have many scripts that load itself when i open Metashape and are added in a Custom Menu. (pic 1)
This way i open that menu and click the script i want to run.

Your script does not load automatically when i open Metashape. To make it appear in a custom menu i have to run it through console first. (pic 2).

Is it possible to make it to run automatically when i open Metashape? Can you modify it for me please?
« Last Edit: December 01, 2021, 02:42:18 PM by Costas »

Vladimir Denisov

  • Jr. Member
  • **
  • Posts: 79
    • View Profile
Re: Chunk Region Control Script
« Reply #2 on: December 01, 2021, 05:04:38 PM »
I'm not good at scripting.

I have many scripts that load itself when i open Metashape and are added in a Custom Menu. (pic 1)
This way i open that menu and click the script i want to run.

Your script does not load automatically when i open Metashape. To make it appear in a custom menu i have to run it through console first. (pic 2).

Is it possible to make it to run automatically when i open Metashape? Can you modify it for me please?

Place script into %LOCALAPPDATA%\Agisoft\Metashape Pro\scripts\
How to do this:
  • Press Windows+R keyboard keys
  • Type: %LOCALAPPDATA%
  • Press OK
  • Folder opened
  • Open Agisoft\Metashape Pro\scripts\ folder
  • Copy script into this folder.
« Last Edit: December 01, 2021, 05:30:14 PM by Vladimir Denisov »

Costas

  • Jr. Member
  • **
  • Posts: 70
  • Aerial Mapping
    • View Profile
Re: Chunk Region Control Script
« Reply #3 on: December 01, 2021, 05:30:39 PM »
I have already done that as i have done with all other scripts but i get no custom menu for this script.

The menu appears only if i run it through the console.

When i start Metashape i get this error in console

Quote
Traceback (most recent call last):
2021-12-01 16:32:17   File "C:/Users/ANAX-UAS/AppData/Local/Agisoft/Photogrammetric Kit for TOPCON/scripts/ChunkRegionControl.py", line 246, in <module>
2021-12-01 16:32:17     dlg = ChunkRegionControl(parent)
2021-12-01 16:32:17   File "C:/Users/ANAX-UAS/AppData/Local/Agisoft/Photogrammetric Kit for TOPCON/scripts/ChunkRegionControl.py", line 12, in __init__
2021-12-01 16:32:17     self.chunk = Metashape.app.document.chunk
2021-12-01 16:32:17 AttributeError: 'NoneType' object has no attribute 'chunk'
« Last Edit: December 01, 2021, 05:35:12 PM by Costas »

Vladimir Denisov

  • Jr. Member
  • **
  • Posts: 79
    • View Profile
Re: Chunk Region Control Script
« Reply #4 on: December 01, 2021, 05:58:06 PM »
Now i fix it

Vladimir Denisov

  • Jr. Member
  • **
  • Posts: 79
    • View Profile
Re: Chunk Region Control Script
« Reply #5 on: December 01, 2021, 06:16:24 PM »
I have already done that as i have done with all other scripts but i get no custom menu for this script.

The menu appears only if i run it through the console.

When i start Metashape i get this error in console

Quote
Traceback (most recent call last):
2021-12-01 16:32:17   File "C:/Users/ANAX-UAS/AppData/Local/Agisoft/Photogrammetric Kit for TOPCON/scripts/ChunkRegionControl.py", line 246, in <module>
2021-12-01 16:32:17     dlg = ChunkRegionControl(parent)
2021-12-01 16:32:17   File "C:/Users/ANAX-UAS/AppData/Local/Agisoft/Photogrammetric Kit for TOPCON/scripts/ChunkRegionControl.py", line 12, in __init__
2021-12-01 16:32:17     self.chunk = Metashape.app.document.chunk
2021-12-01 16:32:17 AttributeError: 'NoneType' object has no attribute 'chunk'


Please download the updated version of the script. Errors fixed.

Vladimir Denisov

  • Jr. Member
  • **
  • Posts: 79
    • View Profile
Re: Chunk Region Control Script
« Reply #6 on: December 01, 2021, 06:28:58 PM »
But if script autoloaded, then dialog not always on top of the main window. May be I fix it later.

Vladimir Denisov

  • Jr. Member
  • **
  • Posts: 79
    • View Profile
Re: Chunk Region Control Script
« Reply #7 on: December 01, 2021, 07:01:50 PM »
Now I fix always on top dialog when autoloading.
version 0.1.5

Costas

  • Jr. Member
  • **
  • Posts: 70
  • Aerial Mapping
    • View Profile
Re: Chunk Region Control Script
« Reply #8 on: December 02, 2021, 11:17:41 AM »
Thank you a lot.

It loads fine now.  ;D

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15177
    • View Profile
Re: Chunk Region Control Script
« Reply #9 on: December 07, 2021, 06:08:06 PM »
Hello Vladimir,

We have added your script (with minor edits) to our GitHub repository as it might be helpful for many users:
https://github.com/agisoft-llc/metashape-scripts/blob/master/src/region_control.py
Best regards,
Alexey Pasumansky,
Agisoft LLC