0

I'm having a problem trying to import multiple models from a format that uses a custom plugin. I press a to select them all, but only the first is imported. I have well over a thousand models, how would I go about doing this? I tried the solution here: How to batch import Wavefront OBJ files?, but it only works for OBJs. How would I do this for .rip files?

The plugin I am using is located here: https://github.com/Dummiesman/RipImport

Zac Perry
  • 392
  • 3
  • 13
  • I don't know enough about scripting, but my blind guess is you would replace bpy.ops.import_scene.obj with watever operator i used for importing rip files, possibly bpy.ops.import_scene.rip (?) – Duarte Farrajota Ramos Apr 19 '17 at 01:27

1 Answers1

1

You can do this by calling bpy.ops.import_scene.rip() as shown below:

import os
import bpy

path_to_rip_dir = os.path.join('C:\\', 'rips') #where C:\\rips\\ has the list of rip files

file_list = sorted(os.listdir(path_to_rip_dir))

rip_list = [item for item in file_list if item.endswith('.rip')]

for item in rip_list:
    path_to_file = os.path.join(path_to_rip_dir, item)
    bpy.ops.import_scene.rip(filepath = path_to_file)

You will need to install the addon first as mentioned in the readme file of the addon:

  • Blender 32 Bit: On 32 bit Blender installations, extract the downloaded ZIP file to C:\Program Files (x86)\Blender Foundation\Blender\2.77\scripts\addon

  • Blender 64 Bit: On 64 bit Blender installations, extract the downloaded ZIP file to C:\Program Files\Blender Foundation\Blender\2.77\scripts\addons

  • After you extract the Add-on, it will NOT show up in your
    import/export list by default!

  • After extracting the Add-on, start Blender. Once Blender is
    started, open up File->User Preferences, and navigate over to the
    Add-ons tab. Find the add-on or search "NinjaRipper", and enable it. Click "Save User Preferences" on the bottom of the dialog, and close the dialog.

  • Now you will be able to use the Add-on.
Tak
  • 6,293
  • 7
  • 43
  • 85
  • What do the different keywords mean? I can't seem to get this to run... – Zac Perry Apr 19 '17 at 01:45
  • @ZacPerry just remove the **keywords from the last line, try import_rip.load(self, context) instead – Tak Apr 19 '17 at 01:46
  • Still does not function, gives me 'NameError: name 'import_rip' is not defined'. Maybe you could try basing your script off the one in the addon? Its on the github page in the original post. – Zac Perry Apr 19 '17 at 01:49
  • @ZacPerry did you install the add-on? it works fine with me – Tak Apr 19 '17 at 01:55
  • The original addon? Yes. The script you pasted in, no. I used it in the text editor. Maybe try using an actual model: https://drive.google.com/file/d/0B0JlgUd0NeDVdmtOTGhFRGtDUXc/view?usp=sharing – Zac Perry Apr 19 '17 at 01:59
  • @ZacPerry what happens when you press the space bar and type "ninja" anything comes up? – Tak Apr 19 '17 at 02:00
  • Yes. The import function shows up. Does using a real model wrok for you? Here is one to test if you have none. https://drive.google.com/file/d/0B0JlgUd0NeDVdmtOTGhFRGtDUXc/view?usp=sharing/ – Zac Perry Apr 19 '17 at 02:04
  • @ZacPerry Answer updated, but looks like the add-on is not working because even if you tried importing it manually using the spacebar Import NinjaRipper it doesn't work and throws many errors. – Tak Apr 19 '17 at 02:13
  • I seem to be able to import the models fine manually. How odd. Thanks anyway. – Zac Perry Apr 19 '17 at 02:24
  • @ZacPerry have you tried the new script? I updated my answer – Tak Apr 19 '17 at 02:25
  • Welp, it hasn't thrown me any errors, and blender froze, so its safe to say that it is working, thanks! – Zac Perry Apr 19 '17 at 02:28