exportSelected in cmds.file

2,497 views
Skip to first unread message

Mahmoodreza Aarabi

unread,
Jul 20, 2016, 4:49:15 AM7/20/16
to Python Programming for Autodesk Maya

Hello guys

Please take a look at this and guide me.

Situation:

We have a FinalModel that is referenced in a scene for rig. In the rig scene, meshes get skin and rigging stuffs.
after that i want to save the scene using code (Here using Pyblish’s Plugin) that use this code:

cmds.file(path,
      force=True,
      typ="mayaAscii",
      exportSelected=True,
      preserveReferences=True,
      shader=True,
      expressions=False,
      constructionHistory=True)
Problem:

The code will save the selected group in a new file and their connections in a new .ma file fine, but when we open the scene meshes does not show their shaders and just show us wireframe, while, meshes have materials connected to ShadingGroup.
This event happen when i export selection manually with maya menu.

make sense?

thanks

Sumant Shenoy

unread,
Jul 20, 2016, 5:16:43 AM7/20/16
to python_in...@googlegroups.com
this may work 
select the objects or top group
cmds.file(rename=path+filename.ma)
cmds.file(type="mayaAscii",exportSelected=True,preserveReferences=True,shader=True,expressions=False,constructionHistory=True)

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/87371f12-d4e8-4e4f-9ea0-46e7cc28814e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mahmoodreza Aarabi

unread,
Jul 20, 2016, 5:20:39 AM7/20/16
to python_in...@googlegroups.com
Hey Sumant
thanks for answer.
i test rename flag of file, but it does not give path, just can i give it a new name, i think to a new way to use save flag instead of exportSelected.

but i want to know why export selecting in maya ruin our shaders, you know?


For more options, visit https://groups.google.com/d/optout.



--


Bests,
madoodia

Mahmoodreza Aarabi

unread,
Jul 21, 2016, 1:56:50 AM7/21/16
to python_in...@googlegroups.com

Hey again
i test this snippet but this does not work:

from maya import cmds
dir_path = 'C:/test/test.ma'
cmds.file(rename=dir_path)
cmds.file(s=True, f=True, typ="mayaAscii")

and gave this error:
# Error: RuntimeError: file <maya console> line 3: An invalid path was specified. #

any idea?!

--


Bests,
madoodia

Mahmoodreza Aarabi

unread,
Jul 21, 2016, 3:11:22 AM7/21/16
to python_in...@googlegroups.com

I think using exportAll will solve the problem

cmds.file(path,
      force=True,
      typ="mayaAscii",
      exportAll=True,
      preserveReferences=True,
      shader=True,
      expressions=False,
      constructionHistory=True)
--


Bests,
madoodia

Cesar Saez

unread,
Jul 21, 2016, 6:44:30 AM7/21/16
to python_in...@googlegroups.com
If I recall correctly, windows paths uses \ instead of /... try replacing the path by: dir_path = r"C:\test\test.ma"
Notice the r character before starting the string, this means it's a raw string (\ is a escape character), if you don't want to use a raw string you will need to use something like "C:\\test\\test.ma".

Cheers!

Mahmoodreza Aarabi

unread,
Jul 21, 2016, 6:54:56 AM7/21/16
to python_in...@googlegroups.com
You are right, but this is not affect the code
rename just get new name not new path
i used exportAll flag and it works fine

btw, thanks for the point

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--


Bests,
madoodia
Reply all
Reply to author
Forward
0 new messages