Forum

Author Topic: Problems with exporting model  (Read 9332 times)

Florian T.

  • Newbie
  • *
  • Posts: 10
    • View Profile
Problems with exporting model
« on: October 05, 2017, 03:08:18 PM »
Hey,

i just want to write a script which iterates through a given folder an all subfolders, opens psx files, export the model and then delete the psx files.
The following script always end in an Runtime Error:

import PhotoScan
import os

#def psx_to_obj_converter():

doc = PhotoScan.app.document
path = PhotoScan.app.getExistingDirectory("Bitte wählen Sie den Zielordner mit den *.psx Projekten in Ordner und Unterordnern")
for root, dirs, files in os.walk(path):
    for filename in files:
        if ".PSX" in filename.upper():
            doc.open(os.path.join(root, filename))
            chunk = doc.chunk
            chunk.exportModel(root, binary = False, precision = 6, texture_format = PhotoScan.ImageFormatJPEG, texture = True, normals = False, colors = False, cameras = False, udim = False, strip_extensions = False, format = PhotoScan.ModelFormatOBJ, projection = PhotoScan.CoordinateSystem("EPSG::31467"))
            #os.remove(path + "/" + filename)


The following error occures every time i tested it:

2017-10-05 13:49:16   File "C:/Users/ArchaeoBW/AppData/Local/Agisoft/PhotoScan Pro/scripts/psx to obj converter.py", line 13, in <module>
2017-10-05 13:49:16     chunk.exportModel(path, binary = False, precision = 6, texture_format = PhotoScan.ImageFormatJPEG, texture = True, normals = False, colors = False, cameras = False, udim = False, strip_extensions = False, format = PhotoScan.ModelFormatOBJ, projection = PhotoScan.CoordinateSystem("EPSG::31467"))
2017-10-05 13:49:16 RuntimeError: Can't create file: Permission denied (13): P:/2017_Maßnahmen/2017_258_Ludwigsburg_Schlosstr_29_31_Schmiedgaessle_5/Vermessung/Drone_3D


Thanks for your help!



Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15429
    • View Profile
Re: Problems with exporting model
« Reply #1 on: October 05, 2017, 03:22:10 PM »
Hello Florian,

It seems that you are not passing valid export file path to the exporModel() function. It should be a full path that includes the filename with the extension.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Florian T.

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Problems with exporting model
« Reply #2 on: October 05, 2017, 04:48:22 PM »
Thanks for advice. I replaced the "root" with "os.path.join(root, filename)". Now the script runs without any issues and it seems to work fine BUT after all there is no 3D File in the output folder. The texture as jpg file and the mtl file in case of obj export could be found but no obj file or ply or whatever.

Current Script:

import PhotoScan
import os

doc = PhotoScan.app.document
path = PhotoScan.app.getExistingDirectory("Bitte wählen Sie den Zielordner mit den *.psx Projekten in Ordner und Unterordnern")
for root, dirs, files in os.walk(path):
    for filename in files:
        if ".PSX" in filename.upper():
            doc.open(os.path.join(root, filename))
            chunk = doc.chunk
            chunk.exportModel(os.path.join(root, filename), binary = False, precision = 6, texture_format = PhotoScan.ImageFormatJPEG, texture = True, normals = False, colors = False, cameras = False, udim = False, strip_extensions = False, format = PhotoScan.ModelFormatOBJ, comment = "Copyright ArchaeoBW GmbH 2017", projection = PhotoScan.CoordinateSystem("EPSG::31467"))


Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15429
    • View Profile
Re: Problems with exporting model
« Reply #3 on: October 05, 2017, 05:08:17 PM »
Hello Florian,

What is in "filename" variable?

The export path should be like: "D:/Vermessung/Drone_3D/model.obj".
Best regards,
Alexey Pasumansky,
Agisoft LLC

Florian T.

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Problems with exporting model
« Reply #4 on: October 05, 2017, 06:22:44 PM »
Ah okay I got it :D. Just my failure , forgetting the .obj.

Thanks very much