0
$\begingroup$

I want to batch process nif files, using PyNifly addon, I would like to import a .nif through a script without going through the menu manually.

bpy.ops.import_scene.pynifly() is what I got when enabling developer extras but I get an error when trying to import a file.

Download Blender cube .nif https://www.dropbox.com/s/5xblr15dkie2xkx/Cube.nif?dl=0

Download PyNifly https://github.com/BadDogSkyrim/PyNifly

Script

    import bpy
    bpy.ops.import_scene.pynifly(filepath="E:/Meshes/10mmAmmo.nif")

Console Error

Python: Traceback (most recent call last):
  File "\Text", line 2, in <module>
  File "C:\Program Files\Blender Foundation\Blender 3.4\3.4\scripts\modules\bpy\ops.py", line 113, in __call__
    ret = _op_call(self.idname_py(), None, kw)
RuntimeError: Error: Import of nif failed, see console window for details

I installed an addon called ActionRecorder and got this information, about the importing process.

Script

bpy.ops.import_scene.pynifly(filepath='', filter_glob='*.nif', files=<bpy_collection[0], IMPORT_SCENE_OT_pynifly.files>, create_bones=True, scale_factor=1.0, rename_bones=True, rename_bones_niftools=False, import_shapes=True, apply_skinning=True)

Error

Error: invalid syntax (<string>, line 1)

System Console Log

====================================
PYNIFLY IMPORT NIF V7.0.0


ERROR:pynifly:Import of nif failed
Traceback (most recent call last):
  File "C:\Program Files\Blender Foundation\Blender 3.4\3.4\scripts\addons\io_scene_nifly\__init__.py", line 1955, in execute
    NifImporter.do_import(fullfiles, flags)
  File "C:\Program Files\Blender Foundation\Blender 3.4\3.4\scripts\addons\io_scene_nifly\__init__.py", line 1874, in do_import
    imp = NifImporter(filename, flags, chargen=chargen, scale=scale)
  File "C:\Program Files\Blender Foundation\Blender 3.4\3.4\scripts\addons\io_scene_nifly\__init__.py", line 785, in __init__
    self.filename = filename[0]
IndexError: list index out of range
INFO:pynifly:

PyNifly IMPORT of [] completed WITH ERRORS {'CANCELLED'}
====================================


Error: Import of nif failed, see console window for details
ERROR:ActionRecorder:Uncaught exception
Traceback (most recent call last):
  File "\Text", line 2, in <module>
  File "C:\Program Files\Blender Foundation\Blender 3.4\3.4\scripts\modules\bpy\ops.py", line 113, in __call__
    ret = _op_call(self.idname_py(), None, kw)
RuntimeError: Error: Import of nif failed, see console window for details
$\endgroup$
8
  • 1
    $\begingroup$ Did you try seeing the console for details? $\endgroup$ Commented Feb 3, 2023 at 15:26
  • $\begingroup$ Yes, It's the same as error $\endgroup$ Commented Feb 4, 2023 at 16:02
  • $\begingroup$ There was no previous log information that gave more detail? $\endgroup$ Commented Feb 4, 2023 at 20:44
  • $\begingroup$ I added a log, from running the script at the top of my post, I've never seen this before today. $\endgroup$ Commented Feb 5, 2023 at 12:45
  • $\begingroup$ self.filename = filename[0] IndexError: list index out of range This means that the file name is the empty string. Are you trying to select multiple files at once perhaps? $\endgroup$ Commented Feb 6, 2023 at 4:34

1 Answer 1

0
$\begingroup$

Your script works:

bpy.ops.import_scene.pynifly(filepath="E:/dummydir/dummynif.nif")

You may want to make sure the file referenced actually exists. It gives the same error message if you reference a file that doesn't exist.

$\endgroup$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.