Call for Submission
NAB 2012 Best of the Best Show Reel
Submit your work today!
  • 1/3
You are here: Forum Home / Autodesk® Maya® / MEL / Maya Scripting Question
  RSS 2.0 ATOM  

Maya Scripting Question
Rate this thread
 
36675
 
Permlink of this thread   Subscribe to this thread
avatar
  • lubitel
  • Posted: 13 November 2009 10:39 AM
  • Total Posts: 6
  • Joined: 11 October 2006 03:02 AM

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..

Thank you in advance



Replies: 0
avatar
  • cgrebeld
  • Posted: 15 November 2009 06:54 AM

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(pixnv)
            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
/img/forum/dark/default_avatar.png

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:)

l

Author: lubitel

Replied: 15 November 2009 08:59 AM  
/img/forum/dark/default_avatar.png

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:)

l

Author: lubitel

Replied: 15 November 2009 06:24 PM  




   
  Settings Choose Theme color: