-
-
Save SEVEZ/20ab256c96f52a57858ccb3fac4e288f to your computer and use it in GitHub Desktop.
Dice It script for maya
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def Dicer(xmany, ymany, zmany): | |
| cs = cmds.ls(sl=True) | |
| cpc = cmds.objectCenter(cs, gl=True) | |
| cpcx = cpc[0] | |
| cpcy = cpc[1] | |
| cpcz = cpc[2] | |
| bb = cmds.exactWorldBoundingBox(cs) | |
| cxmax = bb[0] | |
| cxmin = bb[3] | |
| cymax = bb[1] | |
| cymin = bb[4] | |
| czmax = bb[2] | |
| czmin = bb[5] | |
| if (xmany > 0): | |
| xincrement = (cxmax - cxmin) / xmany | |
| xranger = xfrange(cxmin, cxmax, xincrement) | |
| for xlocation in xranger: | |
| cmds.polyCut(cutPlaneRotate = [0, 90, 0], cutPlaneCenter = [xlocation, cpcy, cpcz]) | |
| if (zmany > 0): | |
| zincrement = (czmax - czmin) / zmany | |
| zranger = xfrange(czmin, czmax, zincrement) | |
| for zlocation in zranger: | |
| cmds.polyCut(cutPlaneRotate = [0, 0, 90], cutPlaneCenter = [cpcx, cpcy, zlocation]) | |
| if (ymany > 0): | |
| yincrement = (cymax - cymin) / ymany | |
| yranger = xfrange(cymin, cymax, yincrement) | |
| for ylocation in yranger: | |
| print ylocation | |
| cmds.polyCut(cutPlaneRotate = [90, 90, 0], cutPlaneCenter = [cpcx, ylocation, cpcz]) | |
| def xfrange(start, stop, step): | |
| old_start = start #backup this value | |
| digits = int(round(log(10000, 10)))+1 #get number of digits | |
| magnitude = 10**digits | |
| stop = int(magnitude * stop) #convert from | |
| step = int(magnitude * step) #0.1 to 10 (e.g.) | |
| if start == 0: | |
| start = 10**(digits-1) | |
| else: | |
| start = 10**(digits)*start | |
| data = [] #create array | |
| #calc number of iterations | |
| end_loop = int((stop-start)//step) | |
| if old_start == 0: | |
| end_loop += 1 | |
| acc = start | |
| for i in xrange(0, end_loop): | |
| data.append(acc/magnitude) | |
| acc += step | |
| return data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment