Community
Maya Programming
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya SDK topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

import and export options

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
Craig_Lamorte
8317 Views, 6 Replies

import and export options

Craig_Lamorte
Advocate
Advocate

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

 

https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2016/ENU/Maya/fil...

https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2016/ENU/Maya/fil...

 

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?

 

0 Likes

import and export options

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

 

https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2016/ENU/Maya/fil...

https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2016/ENU/Maya/fil...

 

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?

 

6 REPLIES 6
Message 2 of 7

Craig_Lamorte
Advocate
Advocate

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?

0 Likes

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?

Message 3 of 7
Anonymous
in reply to: Craig_Lamorte

Anonymous
Not applicable

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

0 Likes

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

Message 4 of 7
Craig_Lamorte
in reply to: Anonymous

Craig_Lamorte
Advocate
Advocate

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?

0 Likes

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?

Message 5 of 7
Anonymous
in reply to: Craig_Lamorte

Anonymous
Not applicable
Accepted solution

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:

 

options.jpg

 

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

 

 

0 Likes

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:

 

options.jpg

 

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

 

 

Message 6 of 7
Craig_Lamorte
in reply to: Anonymous

Craig_Lamorte
Advocate
Advocate

Ohh got it!  That's exactly what i needed to know.

0 Likes

Ohh got it!  That's exactly what i needed to know.

Message 7 of 7
Anonymous
in reply to: Anonymous

Anonymous
Not applicable

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:

 

options.jpg

 

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

 

 



@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:

 

options.jpg

 

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

 

 


 

0 Likes

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:

 

options.jpg

 

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

 

 



@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:

 

options.jpg

 

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

 

 


 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report