PDA

View Full Version : Exporting OBJ with Python


olson
10-13-2009, 06:36 PM
Does this Python look right to you? Trying to export an OBJ from the selected objects. I know it can be done through the menu but I want to use this in another script but can't even get it to work by itself.

import maya.cmds as cmds
cmds.file("C:/test.obj",es=True,typ="OBJ")

This is the output from the script editor. Created a cube, selected it, ran the Python script, got a generic error that doesn't say why it failed.

CreatePolygonCube;
setToolTo CreatePolyCubeCtx;
polyCube -ch on -o on -w 5.975262 -h 7.111771 -d 8.669797 -cuv 4 ;
// Result: pCube1 polyCube1 //
select -r pCube1 ;
import maya.cmds as cmds
cmds.file("C:/test.obj",es=True,typ="OBJ")
# Error: Could not save file.
# Traceback (most recent call last):
# File "<maya console>", line 2, in <module>
# RuntimeError: Could not save file.
# #

The save location has all the correct permissions and I can save files there through the menu. Any help would be greatly appreciated!

uiron
10-14-2009, 03:51 PM
cmds.file("c:/something.obj",pr=1,typ="OBJexport",es=1,
op="groups=0; ptgroups=0; materials=0; smoothing=0; normals=0")

olson
10-14-2009, 05:17 PM
cmds.file("c:/something.obj",pr=1,typ="OBJexport",es=1,
op="groups=0; ptgroups=0; materials=0; smoothing=0; normals=0")


Thanks for the help! I'll look up those options and give it a shot. Cheers!

CGTalk Moderation
10-14-2009, 05:17 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.