Forum

Author Topic: copy chunck between document  (Read 1631 times)

ronan

  • Newbie
  • *
  • Posts: 10
    • View Profile
copy chunck between document
« on: July 28, 2017, 08:06:14 PM »
Hi,
I like to copy a chunk from a previous document and run a new script with it.
I have been trying the following but nothing is  saved in my new document.
Code: [Select]
app = PhotoScan.Application()
init_project_path = 'xxx'
project_path         = 'yyy'
doc_init = PhotoScan.Document()
doc_init.open(init_project_path)
chunk_init = doc_init.chunk

doc = PhotoScan.Document()
doc.save(project_path, chunks=[chunk_init])
doc.open(project_path)

chunk = doc.chunk
doc.save()

any advices?

Thanks
Ronan

ronan

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: copy chunck between document
« Reply #1 on: July 28, 2017, 09:34:33 PM »
if anyone interested, I came the solution to copy the whole document (.psx and .files) before opening the new created document.

Code: [Select]
if os.path.isfile(project_path)                                    : os.remove(project_path)
if os.path.isdir(project_path.replace('.psx','.files')): shutil.rmtree(project_path.replace('.psx','.files'))
shutil.copy(init_project_path,project_path)
shutil.copytree(init_project_path.replace('.psx','.files'),project_path.replace('.psx','.files'))
os.remove(project_path.replace('.psx','.files')+'/lock')

#start photoscan
############
doc = PhotoScan.Document()
doc.open(project_path)

chunk = doc.chunk
doc.save()