Skip to content

Instantly share code, notes, and snippets.

@patwooky
Last active June 5, 2018 05:26
Show Gist options
  • Save patwooky/ae8527a423da0f93ea4faba0b47a9640 to your computer and use it in GitHub Desktop.
Save patwooky/ae8527a423da0f93ea4faba0b47a9640 to your computer and use it in GitHub Desktop.
Maya PyMel - create planes at rotation pivot of each selected object
from pymel.core import *
def makeCards(myAxis=(1,0,0), divs=(2,2), wh=[20, 20]):
'''
create planes at rotation pivot of each selected object
select objects to create planes at their rotation pivots, then run this script
myAxis - <list3> the axis which the planes will be oriented
divs - <list2> divisions in with and height axes of created planes
wh - <list2> width and height units of created planes
future improvements:
make each card take on the size of the obj, in terms of their width and height
'''
locsList = []
for piece in ls(sl=True):
thisLoc = spaceLocator(n='%s_loc'%piece.shortName())
# thisPlane will be a list2 obj: [transformNode, polyPlaneNode]
thisPlane = polyPlane(n='%s_card'%piece.shortName(), axis=myAxis, w=wh[0], h=wh[1], sx=divs[0], sy=divs[1])
parent(thisPlane[0], thisLoc)
locsList.append(thisLoc)
xform(thisLoc, ws=True, t=xform(piece, q=True, ws=True, a=True, rp=True))
group(locsList, n='cards_grp')
return
makeCards(wh=[150000, 80000])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment