Hello,
Is there anyway to set the import options or export options for any file format (mb, fbx, obj, etc) through pymel or python. The only commands I have found are using mel
I know that i can essentially do this - (example) -
pm.mel.FBXExportLights(v=False)
but just wondering if this is the only way to set these options in a script?
Also if I am using pm.openFile() for anything (mb, fbx, obj) the import options would not apply correct? I would need to use the import command?
Solved! Go to Solution.
Hello,
Is there anyway to set the import options or export options for any file format (mb, fbx, obj, etc) through pymel or python. The only commands I have found are using mel
I know that i can essentially do this - (example) -
pm.mel.FBXExportLights(v=False)
but just wondering if this is the only way to set these options in a script?
Also if I am using pm.openFile() for anything (mb, fbx, obj) the import options would not apply correct? I would need to use the import command?
Solved! Go to Solution.
forgot to say that I could only find those import/export options for FBX, are there commands for setting import/export for other file formats like OBJ?
forgot to say that I could only find those import/export options for FBX, are there commands for setting import/export for other file formats like OBJ?
Hi Craig
There are a couple of ways that Maya deals with import/export. The most common is that a developer writes a file translator which allows either import or export (or both) operations of a particular file format.
For example if you look in your Windows > Settings/Preferences > Plug-in Manager you should see a plug-in called OBJexport.mll which is the file translator for Obj files.
File translators take an options string which contains a semi-colon delimited list of arguments which the translator will parse and use in the subsequent import/export operation.
So for example if I wanted to import an obj file and set the options I could do this:
// Import the obj file and set "MultipleObjects" to false file -import -options "mo=0" -pr "C:/MyObject.obj"; // Import the obj and set "Multiple Objects" to true and "Legacy vertex ordering" enabled file -import -options "mo=1;lo=1" -pr "C:/MyObject.obj";
The other method often used is to create a command which exposes a bunch of flags like a normal MEL command. This command will probably still call a file translator in the background, but the way you interface with it is via a command. The FBX import/export system works in this way.
You can see this by loading the plug-in manager again and clicking the small (i) button next to fbxmaya.mll. In the list you will see a load of commands and also a load of translators.
In the first example, figuring out the options strings is the hardest part of this process, as there doesn't seem to be a way to access the options anywhere in an info pane or suchlike apart from the actual import/export window itself. Maybe someone else can offer a suggestion about how to find out the options. Anyway, the way I do it is to simply set the options in the UI and perform the import or export in Maya. After that I simply look command which Maya called in the script window and get the options from that.
You can easily reproduce the above code in python like this:
import maya.cmds as cmds cmds.file("C:/MyObject.obj", i=True, options="mo=1;lo=1", pr=True)
With the FBX method, those two links which you provided are the documentation for the list of flags which you are allowed to set. You can just call those commands via python as you would any other python command. Other command-based file translators should provide their own documentation about the available options they support.
Anyway I hope that helps
Cheers
Mike
Hi Craig
There are a couple of ways that Maya deals with import/export. The most common is that a developer writes a file translator which allows either import or export (or both) operations of a particular file format.
For example if you look in your Windows > Settings/Preferences > Plug-in Manager you should see a plug-in called OBJexport.mll which is the file translator for Obj files.
File translators take an options string which contains a semi-colon delimited list of arguments which the translator will parse and use in the subsequent import/export operation.
So for example if I wanted to import an obj file and set the options I could do this:
// Import the obj file and set "MultipleObjects" to false file -import -options "mo=0" -pr "C:/MyObject.obj"; // Import the obj and set "Multiple Objects" to true and "Legacy vertex ordering" enabled file -import -options "mo=1;lo=1" -pr "C:/MyObject.obj";
The other method often used is to create a command which exposes a bunch of flags like a normal MEL command. This command will probably still call a file translator in the background, but the way you interface with it is via a command. The FBX import/export system works in this way.
You can see this by loading the plug-in manager again and clicking the small (i) button next to fbxmaya.mll. In the list you will see a load of commands and also a load of translators.
In the first example, figuring out the options strings is the hardest part of this process, as there doesn't seem to be a way to access the options anywhere in an info pane or suchlike apart from the actual import/export window itself. Maybe someone else can offer a suggestion about how to find out the options. Anyway, the way I do it is to simply set the options in the UI and perform the import or export in Maya. After that I simply look command which Maya called in the script window and get the options from that.
You can easily reproduce the above code in python like this:
import maya.cmds as cmds cmds.file("C:/MyObject.obj", i=True, options="mo=1;lo=1", pr=True)
With the FBX method, those two links which you provided are the documentation for the list of flags which you are allowed to set. You can just call those commands via python as you would any other python command. Other command-based file translators should provide their own documentation about the available options they support.
Anyway I hope that helps
Cheers
Mike
Thanks! that helps
I did try looking for documentation for the options you can use for the OBJ translator but I could not find anything. Could you point me to where i can find documentation on the options i can use for OBJexporter?
Thanks! that helps
I did try looking for documentation for the options you can use for the OBJ translator but I could not find anything. Could you point me to where i can find documentation on the options i can use for OBJexporter?
Hi Craig
That's actually what I was trying to explain, I don't think there is any documentation unless the individual developer has written some specifically.
The only way I've been able to deduce the options settable in an undocumented file translator (Such as the OBJ one for example) is by doing something like this:
1) Create some objects in your scene
2) File > Export All > [Options]
3) In the export settings you should see a section called "File Type Specific Options".
4) Perform the actual export
5) Open the Window > General Editors > Script Editor
6) Look for the export command which was called in the script history. You should see the options string in there.
For example the following setup:
Resulted in this command to be called
file -force -options "groups=1;ptgroups=1;materials=1;smoothing=1;normals=1" -type "OBJexport" -pr -ea "C:/test.obj";
So we can see the options used were:
groups=1 ptgroups=1 materials=1 smoothing=1 normals=1
And by cross referencing those options with the UI we saw earlier we can quite easily figure out the options which are available.
You can do exactly the same for imports too.
As I said in my last post, there may be a better way to do this, but I don't know it. Perhaps someone else could post here if they do. But I have always been able to work with the above method anyway.
Hope this helps
Cheers
Mike
Hi Craig
That's actually what I was trying to explain, I don't think there is any documentation unless the individual developer has written some specifically.
The only way I've been able to deduce the options settable in an undocumented file translator (Such as the OBJ one for example) is by doing something like this:
1) Create some objects in your scene
2) File > Export All > [Options]
3) In the export settings you should see a section called "File Type Specific Options".
4) Perform the actual export
5) Open the Window > General Editors > Script Editor
6) Look for the export command which was called in the script history. You should see the options string in there.
For example the following setup:
Resulted in this command to be called
file -force -options "groups=1;ptgroups=1;materials=1;smoothing=1;normals=1" -type "OBJexport" -pr -ea "C:/test.obj";
So we can see the options used were:
groups=1 ptgroups=1 materials=1 smoothing=1 normals=1
And by cross referencing those options with the UI we saw earlier we can quite easily figure out the options which are available.
You can do exactly the same for imports too.
As I said in my last post, there may be a better way to do this, but I don't know it. Perhaps someone else could post here if they do. But I have always been able to work with the above method anyway.
Hope this helps
Cheers
Mike
Ohh got it! That's exactly what i needed to know.
Ohh got it! That's exactly what i needed to know.
I am trying to use python or pymel to export fbx file in maya. After getting this mel script for fbx exporting, how can I transfer them to python or pymel so that I can use it in my scripted tool? Thank you!
@Anonymous wrote:Hi Craig
That's actually what I was trying to explain, I don't think there is any documentation unless the individual developer has written some specifically.
The only way I've been able to deduce the options settable in an undocumented file translator (Such as the OBJ one for example) is by doing something like this:
1) Create some objects in your scene
2) File > Export All > [Options]
3) In the export settings you should see a section called "File Type Specific Options".
4) Perform the actual export
5) Open the Window > General Editors > Script Editor
6) Look for the export command which was called in the script history. You should see the options string in there.
For example the following setup:
Resulted in this command to be called
file -force -options "groups=1;ptgroups=1;materials=1;smoothing=1;normals=1" -type "OBJexport" -pr -ea "C:/test.obj";
So we can see the options used were:
groups=1 ptgroups=1 materials=1 smoothing=1 normals=1And by cross referencing those options with the UI we saw earlier we can quite easily figure out the options which are available.
You can do exactly the same for imports too.
As I said in my last post, there may be a better way to do this, but I don't know it. Perhaps someone else could post here if they do. But I have always been able to work with the above method anyway.
Hope this helps
Cheers
Mike
@Anonymous wrote:Hi Craig
That's actually what I was trying to explain, I don't think there is any documentation unless the individual developer has written some specifically.
The only way I've been able to deduce the options settable in an undocumented file translator (Such as the OBJ one for example) is by doing something like this:
1) Create some objects in your scene
2) File > Export All > [Options]
3) In the export settings you should see a section called "File Type Specific Options".
4) Perform the actual export
5) Open the Window > General Editors > Script Editor
6) Look for the export command which was called in the script history. You should see the options string in there.
For example the following setup:
Resulted in this command to be called
file -force -options "groups=1;ptgroups=1;materials=1;smoothing=1;normals=1" -type "OBJexport" -pr -ea "C:/test.obj";
So we can see the options used were:
groups=1 ptgroups=1 materials=1 smoothing=1 normals=1And by cross referencing those options with the UI we saw earlier we can quite easily figure out the options which are available.
You can do exactly the same for imports too.
As I said in my last post, there may be a better way to do this, but I don't know it. Perhaps someone else could post here if they do. But I have always been able to work with the above method anyway.
Hope this helps
Cheers
Mike
I am trying to use python or pymel to export fbx file in maya. After getting this mel script for fbx exporting, how can I transfer them to python or pymel so that I can use it in my scripted tool? Thank you!
@Anonymous wrote:Hi Craig
That's actually what I was trying to explain, I don't think there is any documentation unless the individual developer has written some specifically.
The only way I've been able to deduce the options settable in an undocumented file translator (Such as the OBJ one for example) is by doing something like this:
1) Create some objects in your scene
2) File > Export All > [Options]
3) In the export settings you should see a section called "File Type Specific Options".
4) Perform the actual export
5) Open the Window > General Editors > Script Editor
6) Look for the export command which was called in the script history. You should see the options string in there.
For example the following setup:
Resulted in this command to be called
file -force -options "groups=1;ptgroups=1;materials=1;smoothing=1;normals=1" -type "OBJexport" -pr -ea "C:/test.obj";
So we can see the options used were:
groups=1 ptgroups=1 materials=1 smoothing=1 normals=1And by cross referencing those options with the UI we saw earlier we can quite easily figure out the options which are available.
You can do exactly the same for imports too.
As I said in my last post, there may be a better way to do this, but I don't know it. Perhaps someone else could post here if they do. But I have always been able to work with the above method anyway.
Hope this helps
Cheers
Mike
@Anonymous wrote:Hi Craig
That's actually what I was trying to explain, I don't think there is any documentation unless the individual developer has written some specifically.
The only way I've been able to deduce the options settable in an undocumented file translator (Such as the OBJ one for example) is by doing something like this:
1) Create some objects in your scene
2) File > Export All > [Options]
3) In the export settings you should see a section called "File Type Specific Options".
4) Perform the actual export
5) Open the Window > General Editors > Script Editor
6) Look for the export command which was called in the script history. You should see the options string in there.
For example the following setup:
Resulted in this command to be called
file -force -options "groups=1;ptgroups=1;materials=1;smoothing=1;normals=1" -type "OBJexport" -pr -ea "C:/test.obj";
So we can see the options used were:
groups=1 ptgroups=1 materials=1 smoothing=1 normals=1And by cross referencing those options with the UI we saw earlier we can quite easily figure out the options which are available.
You can do exactly the same for imports too.
As I said in my last post, there may be a better way to do this, but I don't know it. Perhaps someone else could post here if they do. But I have always been able to work with the above method anyway.
Hope this helps
Cheers
Mike
Can't find what you're looking for? Ask the community or share your knowledge.