Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone, I am working on a plug-in with a percentage decreasing curve, but it does not seem to be in the order of 1-100, is there a problem?
import random
import maya.cmds as cmds
import maya.mel as mel
def run():
percentage = cmds.intSliderGrp("intsample", q=True, value=True)
objs = cmds.ls(sl=True)
if len(objs) == 1:
all_childs = cmds.listRelatives(objs[0])
else:
all_childs = objs
indeces = []
i = 0
while i < int(len(all_childs) * percentage):
index = int(round(random.uniform(0, len(all_childs) - 1)))
if index not in indeces:
indeces.append(index)
else:
i -= 1
i += 1
for each in indeces:
cmds.delete(all_childs[each])
objs = cmds.ls(sl=True)
if len(objs) == 1:
all_childs = cmds.listRelatives(objs[0])
else:
all_childs = objs
print ('Remains:', len(all_childs))
else:
mel.eval('print("Please Enter A number for Percentage!")')
cmds.window( title='Del_curve')
cmds.columnLayout()
cmds.intSliderGrp("intsample", h=30, f=1, l='%:', min=1, max=100, value=1, cw=(50, 120), dc="run()")
cmds.showWindow()
Solved! Go to Solution.