# import random module, documentation is here:import random
# select the objectselection = cmds.ls(sl=True)[0]# calculate how many edges this object havemaxRandomValue = cmds.polyEvaluate(edge=True)
# select the random edges of the object selectedcmds.select("{}.e[{}]".format(selection, random.randint(0,maxRandomValue)))
# printprint "{} is selected".format(cmds.ls(sl=True)[0])
from maya import mel
mel.eval("ConvertSelectionToEdges;")mel.eval("PolySelectConvert 2;")mel.eval("PolySelectConstraint -m 2;")mel.eval("PolySelectConstraint -r true;")mel.eval("PolySelectConstraint -rr 0.20;")mel.eval("polySelectSp -loop;")
import random
def randomEdgeSelection(obj, randomEdgeCount):
# calculate how many edges this object have
maxRandomValue = cmds.polyEvaluate(edge=True)
# random edges count can not be grater the edges in the poly
if randomEdgeCount > maxRandomValue:
cmds.error("randomEdgeCount can not be grator then maxRandomValue")
edgeIndex = []
for i in range(randomEdgeCount):
# select the random edges of the object selected
edgeIndex.append(random.randint(0, maxRandomValue))
edges = []
for index in edgeIndex:
edges.append("{0}.e[{1}]".format(obj, index))
cmds.select(edges)
randomEdgeSelection(cmds.ls(sl=True)[0], 20)
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/53235f73-0223-4e2c-807e-eb65306e5f3b%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/53235f73-0223-4e2c-807e-eb65306e5f3b%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/b4e44ad0-69cf-43ce-b8ba-d95cbcf2dbbao%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/53235f73-0223-4e2c-807e-eb65306e5f3b%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.