Hi everyone!
I generally program Unity3D related stuff, I’m still pretty new to Maya’s python API.
What I’m trying to do is to get the currently selected face normals average:
What I need to achieve
What I achieved until now is an instance of a cube positioned according to the Move Manipulator.
import maya.cmds as cmds
import re #regular expression
# get current position of the move manipulator
pos = cmds.manipMoveContext('Move', q=True, p=True)
# get the current selection
selection = cmds.ls(sl=True)
# trying to get the face normal angles of the current selection
polyInfo = cmds.polyInfo(selection, fn=True)
polyInfoArray = re.findall(r"[\w.-]+", polyInfo[0]) # convert the string to array with regular expression
polyInfoX = float(polyInfoArray[2])
polyInfoY = float(polyInfoArray[3])
polyInfoZ = float(polyInfoArray[4])
print str(polyInfoX) + ', ' + str(polyInfoY) + ', ' + str(polyInfoZ)
target = cmds.polyCube()
cmds.move(pos[0], pos[1], pos[2], target)
Now what I only need is to rotate the cube to the face average normals of the selection
Please, any thoughts about this?
Maya does have any method to give me those angles? I tried to rotate using polyInfo with face normals, but I think I’m missing something…