Hi, i’ve been lurking here at elysiun for a while, this is a my first post.
I’ve been trying to modify Pendragon’s 3ds script to make it more accesible, the goal is to import a bunch of 3ds files on one single shot. So far i got it to bypass the Import/Cancel buttons. I would like to RMB select the files i want to import, but can’t get more than the filename that is currently selected on the second entry of the fileselector. How do i do that?
Here is how it looks:
#!BPY
""" Registration info for Blender menus:
Name: 'Multi 3ds Import'
Blender: 232
Group: 'Import'
Tip: 'Multi 3ds Import (hopefully)'
"""
import Blender
from Blender import NMesh, Material, Texture, Scene, Lamp, Image
from Blender.Draw import *
from Blender.BGL import *
... rest of import script here, Import(fileName) function included
def my_callback(filename):
print filename
Import(filename)
Blender.Window.FileSelector(my_callback, "GO!")
Thanks for the advice, i believe you are right.
In the meanwhile i came with a workaround to load several files in the same script, it’s quick and dirty, but it might be of use for somebody trying to modify a script to do the same without having a complete python install.
...
def my_callback(filename):
bMaterials = False
print "3DS Bulkloader"
print "Attempting to bulkload " + filename
if filename[-4:]!=".blk":
filename = filename + ".blk"
print " " + filename
filepointer = open(filename, "rb")
for line in filepointer.readlines():
#pythonchomp
if line[-1:]=="
":
line = line[:-1]
if line[-1:]=="\r":
line = line[:-1]
print " " + Blender.sys.dirname(filename) + "/" + line
Import(Blender.sys.dirname(filename) + "/" + line)
Blender.Window.FileSelector(my_callback, "BulkLoad")
the .blk file is an ls -1 *.3ds > whatever.blk or dir /b *.3ds > whatever.blk depending on your operating system (maybe for windows the “/” should be changed.