Forum

Author Topic: document open command failure  (Read 8152 times)

kBarra

  • Newbie
  • *
  • Posts: 9
    • View Profile
document open command failure
« on: December 17, 2013, 09:54:04 AM »
Hi so I'm having a strange issue with opening a new document using python. The command says it succeeds but nothing opens in my scene

here is what is happening...

import os
path = "path_to_file.psz"
os.path.exists(path)
#returns true

new_doc = PhotoScan.Document()
new_doc.open(path)

#now photoscan starts to load the file, this take about 3-4 seconds
#after it finishes it returns True, but the file is empty. It gets stranger...

#I can query the chunks inside of the scene even though I see nothing
chunks = PhotoScan.Chunks(new_doc)
#returns "main_chunk", "main_chunk_1"

#I can even Duplicate the chunk.
mainChunk = chunks[0]
dupChunk = PhotoScan.Chunks(new_doc).add(mainChunk)
 
If I query the chunks again I will get 3 chunks, not just 2 like before. If I save out this file it has a size of 1KB. What could possibly be going on here? I am almost certain this was working before.

Any help is greatly appreciated



Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15160
    • View Profile
Re: document open command failure
« Reply #1 on: December 17, 2013, 10:23:52 AM »
Hello kBarra,

When you use new_doc = PhotoScan.Document(), that opens PhotoScan project in memory, but it will exist in parallel to the project opened in GUI. So if you wish to open project in the PhotoScan window, you need to use doc = PhotoScan.app.document.
Best regards,
Alexey Pasumansky,
Agisoft LLC

kBarra

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: document open command failure
« Reply #2 on: December 17, 2013, 10:56:47 AM »
thanks Alexey, you're a lifesaver. Still trying to get use to the subtle differences between a few of these API calls.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15160
    • View Profile
Re: document open command failure
« Reply #3 on: December 17, 2013, 11:05:55 AM »
Hello kBarra,

If you have any other difficulties please feel free to ask.

For example, to get list of chunks in document you can use shorter line:
Code: [Select]
chunks = new_doc.chunks
And to duplicate chunk with index 0 you can use the following:
Code: [Select]
new_doc.chunks.add(new_doc.chunks[0].copy())
« Last Edit: December 17, 2013, 11:07:41 AM by Alexey Pasumansky »
Best regards,
Alexey Pasumansky,
Agisoft LLC