Introduction to Maya - Modeling Fundamentals Vol 1
This course will look at the fundamentals of modeling in Maya with an emphasis on creating good topology. We'll look at what makes a good model in Maya and why objects are modeled in the way they are.
# 1 07-05-2012 , 10:28 PM
G-Man's Avatar
Subscriber
Join Date: May 2004
Location: Bowling Green. Kentucky U.S.A.
Posts: 810

New Script REquest

Is there a script that i haven't found That allows for Mass obj export to separate files?

I need something that will allow me to export every combined poly object to a separate obj file with the file named what the part is named in the scene.

Preferably it would be setup so that it worked not on the overall file, but an export selected option

Example i have a ship I've modeled it up and the parts are laid out like " Ship Hull" ..."ShipGun"..."Ship cockpit"

So forth and so on.

I want to be able to select the parts, click a mel or python button and have each one export as obj to a folder i specify with the file named the same as the Combined poly object is named.

When i get ready to Take a model form Maya into magics, i have to export each individual part of the file needed as a separate part in magics, ( magics takes every file you pull into it and creates it as a single part) To a new separate file. I cannot export strait to STL because Maya has some strange issue that causes a direct export to get all wonky with the size of the part, even after history is deleted, transforms are frozen, what ever. cannot figure out a way around it other then to Export the parts to obj, then export that to STL file. So, when i have to export 40-50 files or more for a model to be prototyped, a mass export script would be killer. Even better if i could select the file type, allowing me to import all the obj files into a single scene, and redo the mass export with the stl file type selected.

Thanks
George

# 2 08-05-2012 , 12:48 AM
ctbram's Avatar
Moderator
Join Date: Jan 2004
Location: Michigan, USA
Posts: 2,998
I am confused. Do you want one file (obj) for each of the combined parts or are you selecting a bunch of combined parts and want one obj for each combined part?


"If I have seen further it is by standing on the shoulders of giants." Sir Isaac Newton, 1675
# 3 08-05-2012 , 02:08 AM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
Easy enough to write one.

Code:
global proc batchOBJExport(string $exportPath)
{
    string $sel[] = `ls -sl`;
    
    for ($obj in $sel)
    {
        select $obj;
        file -force -options "groups=1;ptgroups=1;materials=1;smoothing=1;normals=1" -typ "OBJexport" -pr -es ($exportPath + "/" + $obj + ".obj");
    }
}
Example run: batchOBJExport("/Users/gman/desktop/objs")


Imagination is more important than knowledge.
# 4 08-05-2012 , 02:44 AM
ctbram's Avatar
Moderator
Join Date: Jan 2004
Location: Michigan, USA
Posts: 2,998
Great timing ND this is what I had come up with...

It's the same basic idea just used the current work space (project) as the path and it's not a procedure.

Code:
string $sel[] = `ls -sl`;
string $workspace = `workspace -q -fullName`;
for ($obj in $sel)
{
   print("Exporting: " + $obj + "to " + $workspace + "/"  + $obj + ".obj\n");
   select $obj;
   file -force -options "groups=1;ptgroups=1;materials=1;smoothing=1;normals=1" -typ "OBJexport" -pr -es ($workspace + "/"  + $obj + ".obj");
}


"If I have seen further it is by standing on the shoulders of giants." Sir Isaac Newton, 1675
# 5 08-05-2012 , 03:00 AM
ctbram's Avatar
Moderator
Join Date: Jan 2004
Location: Michigan, USA
Posts: 2,998
ND I modified it so that you could either enter an export path or use the current workspace by passing a empty string of the export path. Is there some form of method overloading in mel such that I could simply make a batchExportOBJ() and batchExportOBJ(string path)? Is that something I'd have to write in python for method overloading?

Code:
global proc batchExportOBJ(string $exportPath)
{
    string $sel[] = `ls -sl`;
    
    if ($exportPath == "")
        $exportPath = `workspace -q -fullName`;
        
    for ($obj in $sel)
    {
       print("Exporting: " + $obj + " to " + $exportPath + "/"  + $obj + ".obj\n");
       select $obj;
       file -force -options "groups=1;ptgroups=1;materials=1;smoothing=1;normals=1" -typ "OBJexport" -pr -es ($exportPath + "/"  + $obj + ".obj");
    }
    
    select -r $sel;
}


"If I have seen further it is by standing on the shoulders of giants." Sir Isaac Newton, 1675

Last edited by ctbram; 08-05-2012 at 03:05 AM.
# 6 08-05-2012 , 03:52 AM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
You'd need to use Python.


Imagination is more important than knowledge.
# 7 08-05-2012 , 03:54 AM
G-Man's Avatar
Subscriber
Join Date: May 2004
Location: Bowling Green. Kentucky U.S.A.
Posts: 810
You guys Rock.
Now, can we do a Batch import script?
And, IF we can do a batch import, can we also do a batch export for STL files?

George

# 8 08-05-2012 , 04:00 AM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
Sure, use something like the following to get the files in a given directory, then go through each found file, and import it.

Code:
getFileList -folder "/Users/gman/Desktop/" -filespec "*.obj";


Imagination is more important than knowledge.
# 9 06-03-2014 , 01:29 AM
Registered User
Join Date: Mar 2014
Posts: 3

Maya 2014 Batch Import Export of Obj Files

Hi all. I'm new to Maya and new to the forums. I'm using Maya 2014 and I'm working on a porting project which involves the importing and exporting of a series of .obj files. I found an old Mel script from Creative Crash || here || .

It appears to do what I need, but I haven't been able to get it to work yet. Will someone help me out by testing this mel script to verify it works?

Here's a download link to the original mel script and a set of test objs :
https://www.dropbox.com/sh/wto4ca02puldx9h/GHIotB_GTY

Thanks for your help in advance, and cheers. user added image

- Unhurdof


Last edited by Unhurdof; 06-03-2014 at 01:40 AM.
# 10 06-03-2014 , 02:07 AM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
Hi Unhurdof, what exactly are you trying to do? That script doesn't export obj's over time.


Imagination is more important than knowledge.
# 11 06-03-2014 , 02:13 AM
Registered User
Join Date: Mar 2014
Posts: 3
Thanks for the reply. Not sure what you mean by 'over time', but I'd just like to import and maybe later export a group of obj files at once.

# 12 06-03-2014 , 03:19 AM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
You can select multiple obj files in your OS, then drag them into the viewport to load them in at once.


Imagination is more important than knowledge.
# 13 06-03-2014 , 03:41 AM
Registered User
Join Date: Mar 2014
Posts: 3
Ah, thanks NextDesign. That's just what I was looking for. Thanks a ton. Cheers! user added image

Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads