If you want to convert only one file:
import subprocess
spam = subprocess.check_output(['x2egg', 'box.x', 'box.egg'])
print spam
Also check this out: [url]Models converter].
Following code will find all models in /models directory, it gona add them to list and then pass to x2egg.exe
import subprocess
import os
directory = 'models'
x_models_list = []
def x2egg():
for filename in os.listdir(directory):
if filename.endswith('.x'):
x_models_list.append(filename)
for model_name in x_models_list:
try:
print 'Working on: ' + model_name
converted_model = os.path.splitext(model_name)[0]
infile = directory + '\\' + model_name
outfile = directory + '\\' + converted_model + '.egg'
return_code = subprocess.check_output(['x2egg', infile, outfile])
print return_code
except:
print 'error'
x2egg()
example.7z (33.7 KB)