Forum

Author Topic: addPhotos Error  (Read 4332 times)

benton

  • Newbie
  • *
  • Posts: 29
    • View Profile
addPhotos Error
« on: September 14, 2017, 04:31:59 AM »
Hi,

PhotoScan Pro Ver 1.2.6 Build 2834

I have the following code that returns an error, can someone tell me why?


This is the error I get (in red);

2017-09-14 09:27:38 Saving project...
2017-09-14 09:27:38 saved project in 0.016 sec
2017-09-14 09:27:38 Finished processing in 0.016 sec (exit code 1)
2017-09-14 09:27:38 Loading project...
2017-09-14 09:27:38 loaded project in 0 sec
2017-09-14 09:27:39 Finished processing in 0 sec (exit code 1)
2017-09-14 09:27:39 E:\python_dev\py_test101.psz
2017-09-14 09:27:39 ['E:\\python_dev\\JPEG\\DJI_0416.JPG', 'E:\\python_dev\\JPEG\\DJI_0417.JPG', 'E:\\python_dev\\JPEG\\DJI_0418.JPG', 'E:\\python_dev\\JPEG\\DJI_0419.JPG', 'E:\\python_dev\\JPEG\\DJI_0420.JPG', 'E:\\python_dev\\JPEG\\DJI_0421.JPG', 'E:\\python_dev\\JPEG\\DJI_0422.JPG', 'E:\\python_dev\\JPEG\\DJI_0433.JPG', 'E:\\python_dev\\JPEG\\DJI_0434.JPG', 'E:\\python_dev\\JPEG\\DJI_0435.JPG', 'E:\\python_dev\\JPEG\\DJI_0436.JPG', 'E:\\python_dev\\JPEG\\DJI_0437.JPG', 'E:\\python_dev\\JPEG\\DJI_0438.JPG', 'E:\\python_dev\\JPEG\\DJI_0439.JPG', 'E:\\python_dev\\JPEG\\DJI_0446.JPG', 'E:\\python_dev\\JPEG\\DJI_0447.JPG', 'E:\\python_dev\\JPEG\\DJI_0448.JPG', 'E:\\python_dev\\JPEG\\DJI_0449.JPG', 'E:\\python_dev\\JPEG\\DJI_0450.JPG', 'E:\\python_dev\\JPEG\\DJI_0451.JPG', 'E:\\python_dev\\JPEG\\DJI_0452.JPG', 'E:\\python_dev\\JPEG\\DJI_0462.JPG', 'E:\\python_dev\\JPEG\\DJI_0463.JPG', 'E:\\python_dev\\JPEG\\DJI_0464.JPG', 'E:\\python_dev\\JPEG\\DJI_0465.JPG', 'E:\\python_dev\\JPEG\\DJI_0466.JPG', 'E:\\python_dev\\JPEG\\DJI_0467.JPG']
2017-09-14 09:27:39 Traceback (most recent call last):
2017-09-14 09:27:39   File "E:/python_dev/create_project_ver2.py", line 28, in <module>
2017-09-14 09:27:39     chunk.addPhotos(image_list)
2017-09-14 09:27:39 AttributeError: 'NoneType' object has no attribute 'addPhotos'

>>>

This is the code;

Code: [Select]
import PhotoScan
import os

global doc
doc = PhotoScan.app.document

project_path = r'E:\python_dev\py_test101.psz'
path_photos = r'E:\python_dev\JPEG'

# Create project file
doc.save(project_path, chunks = doc.chunks)
doc.open(project_path)
chunk = doc.chunk

# Add Photos
image_list = [
    os.path.join(path_photos, path)
    for path in os.listdir(path_photos)
    if path.lower().endswith(("jpg", "jpeg", "tif", "png"))
    ]

print(project_path)
print(image_list)

chunk.addPhotos(image_list)

# Save project
doc.save()

Ben
« Last Edit: September 14, 2017, 05:55:51 AM by benton »

Gall

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Re: addPhotos Error
« Reply #1 on: September 14, 2017, 10:34:21 AM »
When you start a new project there is no chunk by default.
In the API, doc.chunk references the active chunk or None if there is no chunk in the project.
You can use
Code: [Select]
chunk = doc.addChunk()
# Or this form if you may have already created a chunk
chunk = doc.chunk or doc.addChunk()

to create a new chunk to work with (it will also be set automatically as the active chunk).

benton

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: addPhotos Error
« Reply #2 on: September 18, 2017, 03:23:06 AM »
Thank You