I have few thousand planar footprints generated from curve data exported from Microstation.
Because of the way the curves were drawn some of the face normals point Y-UP (what i want) while others point down in negative Y axis (what i dont want)
In order to not have to go in and manually check and reverse normal direction for thousands of footprints i wonder if anyone knows of a script that does this?
Or knows the MEL or Python syntax for making a looop that iterates through the polygonal geometry in the scene, or a selection list and sets the normals for all the selected geometry to point Y-UP..
I’m sure this can be done with 2 lines of MEL, but for fun:
import maya.OpenMaya as om
import maya.cmds as cmds
sl = om.MSelectionList()
om.MGlobal.getActiveSelectionList(sl) for i in xrange(sl.length()): dp = om.MDagPath()
sl.getDagPath(i,dp)
dp.extendToShape() try: fn = om.MFnMesh(dp)
nv = om.MVector() for pix in xrange(fn.numPolygons()): fn.getPolygonNormal(pix, nv)
su = om.MScriptUtil()
su.createFromDouble(0)
p = su.asDoublePtr()
nv.get(p)
nVecY = om.MScriptUtil.getDoubleArrayItem(p,1) if (nVecY < 0): cmds.polyNormal(dp.fullPathName(),nm=3)
except RuntimeError: pass
Replies: 2
Thank you.
I ended up doinng it mannually by activating backfaceCulling in viewport and selecting the faces pointing in negative Y and flipping the normal.....I am sure this script will come in handy one day:)
I ended up doinng it mannually by activating backfaceCulling in viewport and selecting the faces pointing in negative Y and flipping the normal.....I am sure this script will come in handy one day:)