Results 1 to 5 of 5

Thread: Maya export selection issues

  1. #1
    Banned
    Join Date
    May 2011
    Posts
    3

    Default Maya export selection issues



    Iím having an issue scripting out exporting selected objects from Maya.

    The first problem is, that it wonít export selected objects until I manually export selected first before running the script (If I don't run this manually first it will export out the whole scene not just the selected).

    Second issue is if I export out a lot of objects from one scene, I run into the memory issue that Maya is so well known for and it ends up crashing.

    Do you know of any exporting selection thru the API? I've tried MEL, Python and Pymel but they all cause the same issues (because they are all wrappers around the MEL function).


    #Here is some sample code I have if it helps
    import pymel as pm

    def exportTARGShapes(path, blendNode="blendShape1"):
    if not path:
    path = pm.fileDialog(m=0, dm="*.ma")

    if path:
    numTargets=len(pm.getAttr(blendNode+".w"))

    for iterator in range(numTargets):
    originalName=pm.aliasAttr("%s.w[%i]"%(blendNode,iterator), q=True)

    try:
    pm.setAttr(blendNode+"."+originalName, 1)
    dup = pm.duplicate("geoToExportGroup")
    dup = pm.rename(dup, originalName)
    pm.parent(dup, w=True)
    pm.select(dup)
    pm.exportSelected("C:/Documents and Settings/user/Desktop/exportFolder/%s.ma"%originalName,
    constructionHistory=False,
    constraints=False,
    expressions=False,
    shader=False)
    pm.delete(dup)
    pm.refresh()
    pm.setAttr(blendNode+"."+originalName, 0)
    except:
    pass

    Thanks for any help.
    Last edited by Floid Parkins; 05-10-2011 at 08:00 PM.

  2. #2
    I Code Art djTomServo's Avatar
    Join Date
    Jul 2008
    Location
    Santa Clara, CA
    Posts
    485

    Default

    Quote Originally Posted by Floid Parkins View Post
    The first problem is, that it wonít export selected objects until I manually export selected first before running the script
    You're not actually selecting anything in the script, which is probably what's going on there. Before you run this:

    Code:
    dup = pm.duplicate("geoToExportGroup")
    dup = pm.rename(dup, originalName)
    You need to grab a selection somewhere.
    Seth - The Original Develifter
    About.me

  3. #3
    Banned
    Join Date
    May 2011
    Posts
    3

    Default

    I am doing a selection a couple of lines down from what you posted.

    dup = pm.duplicate("geoToExportGroup")
    dup = pm.rename(dup, originalName)
    pm.parent(dup, w=True)
    pm.select(dup)


    This script does work as intended but only after I export selected manually first.

  4. #4
    I Code Art djTomServo's Avatar
    Join Date
    Jul 2008
    Location
    Santa Clara, CA
    Posts
    485

    Default

    Ok, so your script assumes the presence of a group called "geoToExportGroup", didn't catch that. That being the case, what does your scene look like? It's kinda tricky to debug a script that's so name/scene dependent without actually knowing what's going on in the scene. Also, try except:pass isn't doing you any favors. While you're debugging, get rid of it or write a real exception handler.
    Last edited by djTomServo; 05-10-2011 at 10:32 PM.
    Seth - The Original Develifter
    About.me

  5. #5
    Banned
    Join Date
    May 2011
    Posts
    3

    Default

    Sorry for the long delay on responding. I was on paternity leave for the last 2 weeks.

    So I found the fix to problem #1. The reason I couldn't export out until I had done a manual export is because I wasn't setting the type to "mayaAscii" . The second problem with running out of memory when exporting out 60-100 files from a scene I still can't figure out, but am chalking that up to a Maya bug.

    #original code
    pm.exportSelected("%s\\%s.ma"%(path, originalName),
    constructionHistory=False,
    constraints=False,
    expressions=False,
    shader=False,
    force=True)

    #fixed code
    pm.exportSelected("%s\\%s.ma"%(path, originalName),
    constructionHistory=False,
    constraints=False,
    expressions=False,
    shader=False,
    type="mayaAscii",
    force=True)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •