Hi Matt,My desired naming convention per model will be similar to:CitI0005.daeThis model name is taken from the shape's object attributes and exported per-inital shape using the following script:
from scripting import *
ce = CE()
def export(object, modelName):
dir = ce.toFSPath("models/")
settings = DAEExportModelSettings()
settings.setGeneralLocation(dir)
settings.setGeneralName(modelName)
settings.setGranularityFile(DAEExportModelSettings.PER_INITIAL_SHAPE)
settings.setMiscOptionsWriteExportLog(False)
ce.export(object, settings)
if __name__ == '__main__':
print ("__DAE Export Loop Started__")
shapes = ce.getObjectsFrom(ce.selection, ce.isShape)
IDshape = 0
for shape in shapes :
name = ce.getAttribute(shape, 'MODEL')
string = name.rstrip('3ds')
modelName = string.strip('.')
export(shape, modelName)
print(modelName)
IDshape += 1
pass
print ("__All Selected Models Exported__")
This exports each model with a name such as:CitI0005_shape99.daeTo strip the shape name from each file I just run the following script externally:
# Modules
import os, shutil
# Root folder for files
daeRoot = r'C:\Users\******\Desktop\Sort'
def renameFiles(target):
os.chdir(target)
for filename in os.listdir('.'):
print filename
fullname = os.path.splitext(filename)[0]
ext = os.path.splitext(filename)[1]
prefix = fullname [:8]
newfilename = prefix + ext
print newfilename
os.rename(filename, newfilename)
print "Renamed " + filename + " to " + newfilename
if (__name__ == '__main__'):
renameFiles(daeRoot)
I was just wondering if there was a way to export without the shape name so I don't have to run this extra script to strip the characters? 🙂