Mel to python help!

Mel to python help!

Anonymous
Not applicable
817 Views
1 Reply
Message 1 of 2

Mel to python help!

Anonymous
Not applicable

Hey i just need help translating my scipt from mel to python,  only really undderstand mel so any help would be great! thanks

-

source dagMenuProc;

int $lowAngle = 30;

int $highAngle = 150;

//Change the object back to object mode, just in case it wasn’t already

toggleSelMode;

changeSelectMode -object;

//Store the object that is selected

string $curSel[] = `ls -sl`;

//Select all edges and store in an Array list

doMenuComponentSelectionExt($curSel[0], "edge", 0);

int $edgecount[] = `polyEvaluate -e $curSel[0]`;

select ($curSel[0] +".e [0:" + ($edgecount[0] - 1) + "]");

//Constrain that selection to only edges of a certain Angle

polySelectConstraint -m 3 -a on -t 0x8000 -ab $lowAngle $highAngle;

//Remove the selection constraint so everything back to normal

polySelectConstraint -m 0;

print ("Hard edges between " + $lowAngle + " and " + $highAngle + " degrees have been selected");

0 Likes
818 Views
1 Reply
Reply (1)
Message 2 of 2

trs_andre
Collaborator
Collaborator

Does this help?

 

import pymel.core as pm
pm.mel.source('dagMenuProc')
lowAngle=30
highAngle=150
#Change the object back to object mode, just in case it wasnt already
pm.mel.toggleSelMode()
pm.mel.changeSelectMode('-object')
#Store the object that is selected
curSel=pm.ls(sl=1)
#Select all edges and store in an Array list
pm.mel.doMenuComponentSelectionExt(curSel[0], "edge", 0)
edgecount=pm.polyEvaluate(curSel[0], e=1)
pm.select(curSel[0] + ".e [0:" + str((edgecount[0] - 1)) + "]")
#Constrain that selection to only edges of a certain Angle
pm.polySelectConstraint(a=True, ab=(lowAngle, highAngle), m=3, t=0x8000)
#Remove the selection constraint so everything back to normal
pm.polySelectConstraint(m=0)
print "Hard edges between " + str(lowAngle) + " and " + str(highAngle) + " degrees have been selected"

André Moreira

Game Developer / Technical Artist

LinkedIn

0 Likes