Forum

Author Topic: How to get file path?  (Read 2597 times)

cojeffj

  • Newbie
  • *
  • Posts: 5
    • View Profile
How to get file path?
« on: November 16, 2020, 09:48:54 PM »
I'm trying to get the path to the currently opened PSX file, so that when enabling network processing, I can avoid having to prompt the user for the PSX path and root directory:
Code: [Select]
path = Metashape.app.getOpenFileName("Specify path to the PSX document:")
root = Metashape.app.getExistingDirectory("Specify network root path:")

batch_id = client.createBatch(path[len(root):], network_tasks)
I was able to get the server IP that is specified in network preferences with:
Code: [Select]
netHost = str(Metashape.app.settings.network_host)
However, I'm unsure how to get those paths. I'm assuming they are attributes in Metashape.app.document? They are not listed in the documentation.

Alternatively, is there another way to start the network batch on the current document?

Thanks!
« Last Edit: November 16, 2020, 10:28:14 PM by cojeffj »

jedfrechette

  • Full Member
  • ***
  • Posts: 130
  • Lidar Guys
    • View Profile
    • www.lidarguys.com
Re: How to get file path?
« Reply #1 on: November 17, 2020, 12:57:57 AM »
Is this what you're after?
Code: [Select]
from os import path

current_doc = Metashape.app.document.path
current_dir = path.dirname(current_doc)
Jed

cojeffj

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: How to get file path?
« Reply #2 on: November 17, 2020, 01:43:17 AM »
That helps out a ton! thanks!!

cojeffj

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: How to get file path?
« Reply #3 on: November 17, 2020, 11:33:11 PM »
I don't suppose you know of a way to get the root path that's specified in Metashape's preferences?

Edit: I found what I needed by digging around a little.
Code: [Select]
Metashape.app.settings.network_path
« Last Edit: November 17, 2020, 11:57:48 PM by cojeffj »