Hey guys,
I'm doing a simple project for a python scripting class that requires me to export objects in a scene to a new scene through the use of a GUI and save function.
In other words, the user is supposed to be able to click an object, run the script, have the GUI pop up, click export, be prompted to save the scene to a directory and name it, and the file will show up in that location. If the user were to load that new file, it would only be the designated exported object that was selected.
So this is what I have:
import maya.cmds as cmds
def final():
winName="exportObjects"
if ( cmds.window(winName,exists=True)):
cmds.deleteUI(winName)
cmds.window(winName,title='Export Selected Objects to New Scene',w=200,h=50)
cmds.columnLayout(adj=True)
cmds.textFieldButtonGrp('tfb',bl='Export',text='select objects and export to new scene',ed=False,bc='export()')
cmds.showWindow(winName)
def export():
sel=cmds.ls(sl=True)[0]
multipleFilters = "Maya Files (*.ma *.mb);;Maya ASCII (*.ma);;Maya Binary (*.mb);;All Files (*.*)"
cmds.fileDialog2(fileFilter=multipleFilters, dialogStyle=2)
filename=cmds.fileDialog2(q=True, file=True)
cmds.file(rn='%s' %(filename), save=True)
cmds.files(save=True)
final()
And that's what I have. The GUI works fine but I'm completely stumped with the saving process. I understand that the fileDialog2 command simply stores the save information in a variable but I can't figure out how to get Python to actually create the save file. Any help on this would be greaaaatly appreciated. Thank you!