Porttaus Mayalle Pythonilla. Luominen ehkä pikkaisen nopeampaa, mutta ei juuri eroa. Hidasta on mollemmilla.
import maya.cmds as cmds
from math import sqrt
s = "polySphere1"
fBoxSize = 2.0
fSpacing = 0.2
if (cmds.objectType(s) != "polySphere"):
print "Selection is not sphere!"
else:
fRadius = cmds.polySphere( s, q=True, r=True)
iBoxCount = int( ((fRadius*2.0) / (fBoxSize+fSpacing)) )
fMaxSize = iBoxCount*(fBoxSize+fSpacing)
for x in range(0,iBoxCount+1):
for y in range(0,iBoxCount+1):
for z in range(0,iBoxCount+1):
p = [0.0, 0.0, 0.0]
p[0] = (x * (fBoxSize + fSpacing)) - ( fMaxSize / 2.0 )
p[1] = (y * (fBoxSize + fSpacing)) - ( fMaxSize / 2.0 )
p[2] = (z * (fBoxSize + fSpacing)) - ( fMaxSize / 2.0 )
if (sqrt(p[0]*p[0] + p[1]*p[1] + p[2]*p[2])) < fRadius:
b = cmds.polyCube()
sp = cmds.xform( "pSphere1", q=True, t=True, ws=True )
sp[0] += p[0]
sp[1] += p[1]
sp[2] += p[2]
cmds.xform( t=sp, ws=True )