7
« on: December 17, 2019, 08:30:52 AM »
I'm looking to generate a csv file of camera paths and enabled/disabled status. I've sorted the following and have it running from the console...
import Metashape as ms
import csv
def get_camera_names(chunk):
camera_lst = []
enabled_lst = []
for c in chunk.cameras[:10]:
p = c.photo.meta["path"]
if c.enabled == True:
en = "True"
else:
en = "False"
camera_lst.append(p)
enabled_lst.append(en)
return (camera_lst, enabled_lst)
doc = ms.app.document
print(doc)
chunk = doc.chunk
print(chunk)
print(get_camera_names(chunk))
out_file = "J:\\MyDrive\\MyCode\\TestFile.txt"
with open(out_file, 'w', newline='') as myfile:
wr = csv.writer(myfile, quoting=csv.QUOTE_ALL)
wr.writerow(get_camera_names(chunk))
However, variable 'p' returns a bunch of unwanted characters in the string without the full path or extension. For example:
...,<Camera 'DJI_0735_Mission4X_nadir'>,<Camera 'DJI_0736_Mission4X_nadir'>,...
Unless the above is needed for subsequent import into a different .psx file, I'd like:
...,'C:/MyDrive/DJI_0735_Mission4X_nadir.jpg','C:/MyDrive/DJI_0736_Mission4X_nadir.jpg',...
Cheers
W
[my ultimate aim is to add the identical suite of cameras and their enabled/disabled status into a completely different psx file]