So it turns out that if you slam your head against your keyboard for long enough, Python starts to make just a slight bit of sense. Below are the results of my labors. Enjoy them while I go find a bucket of Tylenol:
"""
Quinn's Maya to UDK Units Calculator!
Just select a mesh and run this to see how big your mesh will be in feet on the X, Y, and Z axis in UDK!!
"""
# Import the Maya Command List.
import maya.cmds as cmds
# The selected object is True.
selected = cmds.ls(sl=True)\
# Query the object's dimension data.
xmin, ymin, zmin, xmax, ymax, zmax = cmds.xform(selected[0], q=True, ws=True, bb=True)
# Get the XYZ length in Maya Units.
width = abs(xmax - xmin)
height = abs(ymax - ymin)
depth = abs(zmax - zmin)
# Divide said numbers by 16. (Which gives you their length in UDK Units)
udkWidth = width / 16
udkHeight = height / 16
udkDepth = depth / 16
# Display the results in a polite, easy-to-read fashion!
print '\n', 'In UDK, this mesh is..', '\n', '\n', udkWidth, ' Unreal Units(feet) on the X Axis!', '\n', '\n', udkHeight, ' Unreal Units(feet) on the Y Axis!', '\n', '\n', udkDepth, ' Unreal Units(feet) on the Z Axis!'
__________
And here's the other one:
__________
'''
This script deletes unknown nodes from a scene even if they are locked!
'''
# Imports the Maya commands.
import maya.cmds as mc
# Imports the system.
import sys
# Unknowns equal nodes specified by Maya as 'unknown'
unknowns = mc.ls(type='unknown')
# Now, if they are unknown..
if unknowns:
# Unlock the locked unknown nodes.
mc.lockNode(unknowns, lock=0)
# Delete those nodes.
mc.delete(unknowns)
# Set any new unknown nodes that (for some reason) might be created to unknown.
unknowns = mc.ls(type='unknown')
# If there are no unknown nodes in the scene, write:
if not unknowns:
sys.stdout.write('All unknown nodes have been deleted!')
# Otherwise, if there STILL ARE unknown nodes in the scene, write:
else:
sys.stdout.write('How odd, somehow not all the unknown nodes were deleted..')
# If there are no unknown nodes in the scene to begin with, write:
else:
sys.stdout.write('lol, you silly! There are no unknown nodes in this scene!')
__________
Ah, sweet, sweet progress! Until next time!
No comments:
Post a Comment