0
$\begingroup$

With python I want to:

  • open a file
  • do some stuff to it
  • close it (if necessary)
  • open another
  • repeat

Currently my approach would be:

for f in args.files:
    print(f)
    bpy.ops.wm.open_mainfile(filepath=f)

which throws an error RuntimeError: Error: File written by newer Blender binary (300.42), expect loss of data! but only at the second file. Everything works of if that same file is the first of the list, so I suspect that I am missing some kind of "close a file before opening another" operation.

How can I do that?

$\endgroup$
4
  • $\begingroup$ maybe you're working on blender 3.x files with an older version like 2.8..? $\endgroup$
    – alambre
    Mar 3, 2022 at 20:30
  • $\begingroup$ @calambre - that doesn't seem to be the issue, as the first file gets processed without issue $\endgroup$
    – simone
    Mar 3, 2022 at 21:07
  • $\begingroup$ oh yes, you mentioned that, sorry... so you mean opening many files from a blender instance? not that easy I think, the time you open a new file that instance is gone, I think you need a persistent handler to remain in memory as you close and open them... never tried it myself, what I've done is opened a blend -or a batch- from command line and tell it to run an external script, it should be a lot easier to do I think $\endgroup$
    – alambre
    Mar 3, 2022 at 21:41
  • $\begingroup$ @calambre - yes, using a script (find/exec on linux) is what I did mostly, but that's less portable across linux and windows, so I was hoping fos something fully Blender-based $\endgroup$
    – simone
    Mar 4, 2022 at 5:38

0

You must log in to answer this question.

Browse other questions tagged .