Forum

Author Topic: doc.open() does not work  (Read 2648 times)

Roy

  • Newbie
  • *
  • Posts: 22
    • View Profile
doc.open() does not work
« on: January 31, 2024, 12:00:15 PM »
Hello.
i'm starting to write python code for my projects and I am stuck on a problem that I can't understand.

code:

import Metashape

doc = Metashape.app.document
doc.open("my_path")
....


and when I run this i get the following error:

'getset_descriptor' object has no attribute 'open'

what am I doing wrong?

would appreciate the help.
Roy

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15168
    • View Profile
Re: doc.open() does not work
« Reply #1 on: January 31, 2024, 05:09:49 PM »
Hello Roy,

Are you running your script from Metashape GUI (from Run Script dialog) or are using headless script or stand-alone Metashape Python module? If you are using headless scripts, run from the OS terminal, you need to use different approach:
Code: [Select]
doc = Metashape.Document()
doc.open(path)

Do you observe the same problem, if you open new Metashape instance and input these lines one by one (including the path variable definition) to the Console pane?

I would assume that there were some previous commands that have affected Python interpreter due to some misused commands, for example "doc = Metashape.app.document.open" or something like that.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Roy

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: doc.open() does not work
« Reply #2 on: February 04, 2024, 12:52:16 PM »
Hi.
Thanks for the help.

so it appears that you were spot on.
probably some previous commands affected because restart fixed the issue.

Also I found that my path had "/" and python wanted "\".
it seems to run good now.

thank you again :)

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15168
    • View Profile
Re: doc.open() does not work
« Reply #3 on: February 07, 2024, 03:49:21 PM »
Hello Roy,

Usually in the paths you either need to use "/" or "\\", because single backslash symbol is usually an auxiliary symbol that changes its meaning depending on the next symbols, like "\t" for tab, "\n" for new line and etc.
Best regards,
Alexey Pasumansky,
Agisoft LLC