Home Technical Talk

Maya 2016 Python: Moving frozen objects to 0,0,0 to export them.

I'm a 2nd year student at the University of Hertfordshire, and I am currently pulling my hair out because I can't seem to find a way to get my code to work. I'm creating a tool, for my coding class so it has to be in python, that will export everything in my Maya scene as FBX files that will be translated at the world point of 0,0,0.


I'm currently having a problem with the frozen objects in my scene. Unfrozen objects are selected and moved to 0,0,0 , however frozen objects stay where they are, which is kind of correct in terms of moving to 0,0,0. I need the frozen objects to become unfrozen so they can move to the world point of 0,0,0.

I'm sorry if that doesn't make sense, because I hardly understand it myself. If anyone knows how to unfreeze a previously frozen object in a scene so it goes back to moving in world space rather than local space in python script, that would be great.

Replies

  • sprunghunt
    Options
    Offline / Send Message
    sprunghunt polycounter
    you mean objects with frozen transforms? I don't think you can move those to zero - the pivot has been moved to zero when the transforms were frozen. 
  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    Try quering the xform of one of the pivots iirc. Might have been scale or rotational pivot. Sorry dont have maya on hand. O and use the world space flag. 
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    I do it same way Haiddasalami mentions. Check out the Pivot section under the transform node(not the shape that is). It retains the original values in the rotation/scale pivots. There are other hacky ways to do it, but this one I find to be the easiest and cleanest. If for some reason you would have 0,0,0 rotate/scale pivots you could create a dummy transform node like a group, it will be created in origo, point constrain the object to that new transform node with Maintain Offset off and voila!

    import maya.cmds as cmds

    myObj = cmds.ls(sl=True)[0]
    myObjRP = cmds.xform(myObj, q=True, ws=True, rp=True)
    myOffset = [x * -1 for x in myObjRP]
    cmds.xform(myObj, ws=True, t=myOffset)
    cmds.makeIdentity(apply=True, t=True, r=True, s=True, n=False, pn=True)
  • Deadly Nightshade
    Options
    Offline / Send Message
    Deadly Nightshade polycounter lvl 10
    https://dl.dropboxusercontent.com/u/106392535/unFreezeTranslate.py
    Run that before you export to fix any offset problems due to frozen translate values. Objects that have been frozen outside of the origin, will be moved back to the origin, frozen there, and then moved back to their initial position.

    Polycount dev: Why is there no [CODE]-tag?
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    Or the align command for that matter, but you would still need a reference object in origo.
Sign In or Register to comment.