top of page

Newton's Cradle

Created with python in Maya

User Guide

Run this script to create a small scene of a record table, some records, and a newton's cradle animation.  The script also creates lights and a camera for the scene. The animation on the newton's cradle is created using expressions. The album covers are linked to files (included in the download from this page) and can be sorted by arranging the numbers in the for loop.

Script

######################### Newton Cradle Animation #############################
##
## Create Newton Cradle and Animate it, Create Scene
##
## Created by Abby O'Malley
## Follow me on instagram! @aabrbty
## Reach out for questions/comments!
##
###############################################################################
import maya.cmds as cmds

##### Reset #####
PFX = "newt_"
if cmds.objExists(f"{PFX}*"):
  cmds.delete(f"{PFX}*")
   
##### Globals #####    
size = 1
height = size*5
frameh = size*5.3
tlength = height*.73  

def cleanup(obj):
  cmds.select(obj)
  cmds.DeleteHistory()
  cmds.FreezeTransformations()

def cradle():
#### BASE ####
  cmds.polyCylinder(n= f"{PFX}base", sa=30, sh=3)
  cmds.move(0,-1,0, f"{PFX}base.scalePivot", f"{PFX}base.rotatePivot")
  cmds.move(0,1,0)
  cmds.scale(size*6,size*.1,size*6)
  cmds.select(f"{PFX}base.f[0:59]")
  cmds.polyExtrudeFacet(ltz=.3)
       ### Bevel ###
  cleanup(PFX+"base")
  cmds.polyBevel(f"{PFX}base.f[122:151]", offset = .02,segments = 2)
  cmds.polyBevel(f"{PFX}base.f[91]", offset = .02,segments = 2)    
  cleanup(f"{PFX}base")       
#### FRAME ####
  for i in range (0,2):
       j = i+1
       cmds.polyCylinder(n= f"{PFX}leg_{j}", sa=12, sh=50)
       cmds.move(0,-1,0, f"{PFX}leg_{j}.scalePivot", f"{PFX}leg_{j}.rotatePivot")
       cmds.scale(size*.2,frameh,size*.2)
       if i == 0:
           nrp= -1
       else:
           nrp= 1    
       cmds.move((size*3.5)*nrp,1,(size*4.184)*nrp)
       ### DEFORM ###
       cmds.nonLinear(type="bend", curvature=90, n=f"{PFX}bend0{j}")      
       cmds.rotate(0,90*nrp,0)       
       cmds.scale(.3,.3,.3,r=1)       
       cmds.move((size*3.5)*nrp,frameh*1.85,(size*4.3)*nrp)       
       cmds.setAttr (f"{PFX}bend0{j}.curvature", 180)
       cmds.setAttr (f"{PFX}bend0{j}.lowBound", 0)
       cmds.setAttr (f"{PFX}bend0{j}.highBound", 10)
       cmds.select(f"{PFX}leg_{j}")
       cmds.DeleteHistory()
       cmds.FreezeTransformations()     
       ### Top part and Bevel ###
       cmds.polyExtrudeFacet(f"{PFX}leg_{j}.f[601]", ltz=size*7.5)
       cmds.polyBevel(f"{PFX}leg_{j}.f[601]", offset = 0.1,segments = 3)
       cleanup(f"{PFX}leg_{j}")
#### STRINGS ####                             
  for i in range (0,10):
       if i <= 4:
           ### Left String ###
           ballsz = size*.745
           offset = (size*-2.9)+(i*(ballsz*1.972)) #location +  separation
           cmds.polyCylinder(n = f"{PFX}L_string_{i+1}", sa=10)
           cmds.move(0,-1,0, f"{PFX}L_string_{i+1}.scalePivot", f"{PFX}L_string_{i+1}.rotatePivot")
           cmds.scale(size*.03,height*.82,size*.03)
           cmds.move(size*3.5,height*2.2, offset)
           cmds.rotate(-155.3,90,0)  
           ### Balls ###
           cmds.polySphere(n=f"{PFX}ball_{i+1}", sa=18, sh=18)
           cmds.scale(ballsz,ballsz,ballsz)
           cmds.move(0,size*1.8,offset)
           cmds.parent(f"{PFX}ball_{i+1}", f"{PFX}L_string_{i+1}")
       else:
           ### Right String ###
           j = (i+1)-6
           offset = (size*-2.9)+(j*(ballsz*1.972)) #location +  separation
           cmds.polyCylinder(n = f"{PFX}R_string_{j+1}", sa=10)
           cmds.move(0,-1,0, f"{PFX}R_string_{j+1}.scalePivot", f"{PFX}R_string_{j+1}.rotatePivot")
           cmds.scale(size*.03,height*.82,size*.03)
           cmds.move(size*-3.5,height*2.2, offset)
           cmds.rotate(155.3,90,0)
           cmds.parent(f"{PFX}R_string_{j+1}", f"{PFX}L_string_{j+1}")
  cleanup(f"{PFX}L_string*")   

def animation():
  cmds.expression(object = f"{PFX}L_string_1", s = f"{PFX}L_string_1.rotateX = clamp(-.15,90, sin(frame/35)*-80)")
  cmds.expression(object = f"{PFX}L_string_2", s = f"{PFX}L_string_2.rotateX = clamp(-.15,.15, sin((frame)/35)*-80)")
  cmds.expression(object = f"{PFX}L_string_3", s = f"{PFX}L_string_3.rotateX = clamp(-.15,.15, sin((frame)/35)*-80)")
  cmds.expression(object = f"{PFX}L_string_4", s = f"{PFX}L_string_4.rotateX = clamp(-.15,.15, sin((frame)/35)*-80)")                             
  cmds.expression(object = f"{PFX}L_string_5", s = f"{PFX}L_string_5.rotateX = clamp(-90,.15, sin(frame/35)*-80)")

def animspin():
  cmds.parent(f"{PFX}L_string*",f"{PFX}leg_1")
  cmds.parent(f"{PFX}leg*", f"{PFX}base")
  cmds.select(f"{PFX}base")
  cmds.setKeyframe(at="rotateY",v=0, t=1)
  cmds.setKeyframe(at="rotateY", v=180, t=200)
  cmds.selectKey(f"{PFX}base",t=(0,200),add=True, k=True)
  cmds.keyTangent(itt= "linear", ott= "linear")
   
def enviornment():
#### Record Player ####
  cmds.polyCube(n= f"{PFX}recp_01")
  cmds.move(0,-.5,0, f"{PFX}recp_01.scalePivot", f"{PFX}recp_01.rotatePivot")
  sclY = size*2
  cmds.scale(size*16,sclY,size*16)
  cmds.move(0,-sclY+.5,0)
  cleanup(f"{PFX}recp_01")
  cmds.polyBevel(f"{PFX}recp_01.f[1]",offset= .2, segments = 2)
  cmds.polyBevel(f"{PFX}recp_01.f[0]",offset= .05, segments = 1)
  ### Buttons ###
  for b in range (0,4):
       cmds.polyCylinder(n= f"{PFX}recp_but_{b+1}", sa=16)
       cmds.rotate(0,0,90)
       if b <= 2:
           cmds.scale(.6,.2,.6)
           cmds.move(8,-1,(-5+b*2))
           cleanup(f"{PFX}recp_but_{b+1}")
           cmds.polyBevel(f"{PFX}recp_but_{b+1}.f[16]",offset= .06, segments = 2)
       elif b == 3:
           cmds.scale(.4,.2,.4)
           cmds.move(8,-1,5.8)
           cleanup(f"{PFX}recp_but_{b+1}")
           cmds.polyBevel(f"{PFX}recp_but_{b+1}.f[16]",offset= .06, segments = 2)      
#### Table Time ####
  for t in range (0,2):
       cmds.polyCube(n= f"{PFX}desk_0{t+1}")
       cmds.move(0,-.5,0, f"{PFX}desk_0{t+1}.scalePivot", f"{PFX}desk_0{t+1}.rotatePivot")
       sclY = size*2
       cmds.scale(size*19.5,sclY,size*56.5)
       cmds.move(0,-3.5+(t*-9),-12)  
  cmds.polyCube(n= f"{PFX}desk_03")
  cmds.move(0,-.5,0, f"{PFX}desk_03.scalePivot", f"{PFX}desk_03.rotatePivot")
  cmds.move(0,-12,-39.25)
  cmds.scale(size*19.5,10,sclY)
  ### table hole ###
  cmds.duplicate(f"{PFX}desk_01", n=f"{PFX}desk_hole")
  cmds.select(f"{PFX}desk_hole")
  cmds.scale(14,3,21)
  cmds.move(0,-4,-24.5)
  cmds.polyCBoolOp(f"{PFX}desk_01",f"{PFX}desk_hole",op=2, cls =1)
  cleanup("polySurface1")
  cmds.rename(f"{PFX}desk_01")
  ### Records ###
  for r in range (0,5):     
       cmds.polyCube(n= f"{PFX}record_0{r+1}")
       cmds.move(0,-.5,0, f"{PFX}record_0{r+1}.scalePivot", f"{PFX}record_0{r+1}.rotatePivot")
       cmds.scale(.2,20,20)
       cmds.polyBevel(f"{PFX}record_0{r+1}.f[0:3]",offset= .005, segments = 2)  
       if r ==0:
           cmds.move(-6.1+(r*1.7),-10.5,-24.5)
           cmds.rotate(0,0,5+(r*3.6))
       elif r ==1:
           cmds.move(-6.3+(r*2.15),-10.5,-24.9)
           cmds.rotate(0,0,10)            
       elif r ==2:
           cmds.move(-6.5+(r*2.3),-10.5,-24.05)
           cmds.rotate(0,0,15.7)
       elif r == 3:
           cmds.move(-6.6+(r*1.7),-10.5,-24.5)
           cmds.rotate(0,0,16.2)
       elif r ==4:
           cmds.move(-7+(r*2.01),-10.5,-24.9)
           cmds.rotate(0,0,22.7)
  ### Legs ###
  for g in range(0,2):
       cmds.polyCylinder(n=f"{PFX}desk_leg_0{g+1}")
       cmds.move(0,-1,0, f"{PFX}desk_leg_0{g+1}.scalePivot", f"{PFX}desk_leg_0{g+1}.rotatePivot")
       cmds.rotate(0,0,-180)
       if g == 0:
           nrp= -1
       else:
           nrp= 1   
       cmds.move(7*nrp,-12,12)
       cmds.scale(1,11,1)
       cmds.select(f"{PFX}desk_leg_0{g+1}.f[21]")
       cmds.scale(.5,.5,.5, r=True, p= (nrp*7 ,-35 ,12))
       cleanup(f"{PFX}desk_leg_0{g+1}")   
  cmds.duplicate(f"{PFX}desk_leg_01",f"{PFX}desk_leg_02")  
  cmds.select(f"{PFX}desk_leg_01",f"{PFX}desk_leg_02")
  cmds.move(0,0,-47.5)
#### WALLS ####
  ### Wall 1 ###
  cmds.polyCube(n=f"{PFX}wall_01")
  cmds.move(0,-.5,0, f"{PFX}wall_01.scalePivot",f"{PFX}wall_01.rotatePivot")
  cmds.move(-13.5 ,-34,-15.5)
  cmds.scale(2,100,113)
  ### Wall 2 ###
  cmds.polyCube(n=f"{PFX}wall_02")
  cmds.move(0,-.5,0, f"{PFX}wall_02.scalePivot",f"{PFX}wall_02.rotatePivot")
  cmds.move(43 ,-34,40)
  cmds.scale(115,100,2)
       ## Window ##
  cmds.duplicate(f"{PFX}wall_02", n=f"{PFX}window_01")
  cmds.move(14.75,-1,40)
  cmds.scale(32,47,3)
  cmds.polyCBoolOp(f"{PFX}wall_02",f"{PFX}window_01",op=2, cls =1)    
  cleanup("polySurface1")
  cmds.rename(f"{PFX}wall_02")
       ## window frame ##
  cmds.polyCube(n=f"{PFX}windFrame_01")
  cmds.move(0,-.5,0, f"{PFX}windFrame_01.scalePivot",f"{PFX}windFrame_01.rotatePivot")    
  cmds.move(14.75,-1,40)
  cmds.scale(32,47,3.5)    
  cmds.polyBevel(f"{PFX}windFrame_01.f[2]",f"{PFX}windFrame_01.f[0]",offset= .05, segments = 1)
  cmds.delete(f"{PFX}windFrame_01.f[8]",f"{PFX}windFrame_01.f[10]")
  cleanup(f"{PFX}windFrame_01")
  cmds.polyBridgeEdge(f"{PFX}windFrame_01.e[3:4]",f"{PFX}windFrame_01.e[9:10]",f"{PFX}windFrame_01.e[21:22]",f"{PFX}windFrame_01.e[18]",f"{PFX}windFrame_01.e[13]",dv=0, taper=1)
  cmds.scale(1,1,.5,f"{PFX}windFrame_01.f[12:15]")
  cmds.polyExtrudeFacet(f"{PFX}windFrame_01.f[8:11]", ltz=1.5)
  cmds.polyExtrudeFacet(f"{PFX}windFrame_01.f[17:18]",f"{PFX}windFrame_01.f[20]",f"{PFX}windFrame_01.f[23]", ltz=.5)
  cleanup(f"{PFX}windFrame_01")   
       ## window glass ##
  cmds.polyCube(n=f"{PFX}windGlass_01")
  cmds.move(0,-.5,0, f"{PFX}windGlass_01.scalePivot",f"{PFX}windGlass_01.rotatePivot")    
  cmds.move(14.75,-1,40)
  cmds.scale(32,47,.2)    
  ### Floor (Wall 3) ###
  cmds.polyCube(n=f"{PFX}wall_03")
  cmds.move(0,-.5,0, f"{PFX}wall_03.scalePivot",f"{PFX}wall_03.rotatePivot")
  cmds.move(43 ,-36,-15.5)
  cmds.scale(115,2,113)
  ### Celing (Wall 4) ###
  cmds.duplicate(f"{PFX}wall_03", n=f"{PFX}wall_04")
  cmds.move(43,66,-15.5)  
#### Outside Plane ####
  cmds.polyPlane(n= f"{PFX}outside")
  cmds.move(27.4,11,74)
  cmds.rotate(-90,0,-180)
  cmds.scale(117,117,117)
   
def textures():
  #>>> BASE TXT <<<#
  baseTXT= cmds.shadingNode('aiStandardSurface',n = f"{PFX}baseTXT", asShader=True)
  cmds.select(PFX+"base")
  cmds.hyperShade( assign=baseTXT)   
  cmds.setAttr (f"{PFX}baseTXT.baseColor", 0, 0, 0)
  cmds.setAttr (f"{PFX}baseTXT.metalness", .644)
  cmds.setAttr (f"{PFX}baseTXT.specularRoughness", .304)
  cmds.setAttr (f"{PFX}baseTXT.specularIOR", 1.916)
  cmds.setAttr (f"{PFX}baseTXT.specularAnisotropy", 0.5)
  cmds.setAttr (f"{PFX}baseTXT.subsurface", .079)
  cmds.setAttr (f"{PFX}baseTXT.subsurfaceColor",.75,1,.99)       
  #>>> FRAME TXT <<<#
  frameTXT = cmds.shadingNode('aiStandardSurface',n = f"{PFX}frameTXT", asShader=True)
  cmds.select(f"{PFX}leg*")
  cmds.hyperShade( assign=frameTXT )
  cmds.setAttr (f"{PFX}frameTXT.baseColor",.541,.215,.345)
  cmds.setAttr (f"{PFX}frameTXT.specularColor",.657,.400,.502)
  cmds.setAttr (f"{PFX}frameTXT.specularRoughness",.595)
  cmds.setAttr (f"{PFX}frameTXT.specularIOR",1.272)
  #>>> STRING TXT <<<#
  stringTXT = cmds.shadingNode('aiStandardSurface',n = f"{PFX}stringTXT", asShader=True)
  cmds.select(f"{PFX}L_string*",f"{PFX}R_string*")
  cmds.hyperShade( assign=stringTXT )
  cmds.setAttr (f"{PFX}stringTXT.baseColor",.188,.188,.188)
  cmds.setAttr (f"{PFX}stringTXT.metalness",.315)
  cmds.setAttr (f"{PFX}stringTXT.specularColor",.202,.202,.202)
  cmds.setAttr (f"{PFX}stringTXT.specularRoughness",.685)    
  #>>> BALL TXT <<<#
  ballTXT = cmds.shadingNode('aiStandardSurface',n = f"{PFX}ballTXT", asShader=True)
  cmds.select(f"{PFX}ball*")
  cmds.hyperShade( assign=ballTXT )
  cmds.setAttr (f"{PFX}ballTXT.baseColor", .957, .780, .329)
  cmds.setAttr (f"{PFX}ballTXT.metalness", 1)
  cmds.setAttr (f"{PFX}ballTXT.specularRoughness", 0)
  cmds.setAttr (f"{PFX}ballTXT.specularAnisotropy", 0.5)
  #>>> RECPLAYER TXT <<<#
  recpTXT = cmds.shadingNode('aiStandardSurface',n = f"{PFX}recpTXT", asShader=True)
  cmds.select(f"{PFX}recp_01")
  cmds.hyperShade( assign=recpTXT )
  cmds.setAttr (f"{PFX}recpTXT.baseColor", .835,.521,.537)
  cmds.setAttr (f"{PFX}recpTXT.specularColor",.657,.400,.502)
  cmds.setAttr (f"{PFX}recpTXT.specularRoughness",.595)
  cmds.setAttr (f"{PFX}recpTXT.specularIOR",1.272)
  #>>> RECPLAYER Buttons TXT <<<#
  recpButTXT = cmds.shadingNode("aiStandardSurface",n=f"{PFX}recpButTXT",asShader=True)
  cmds.select(f"{PFX}recp_but*")
  cmds.hyperShade(assign= recpButTXT)
  cmds.setAttr (f"{PFX}recpButTXT.baseColor", 0.107, 0.022, 0.107)
  cmds.setAttr (f"{PFX}recpButTXT.specularColor",.657,.400,.502)
  cmds.setAttr (f"{PFX}recpButTXT.specularRoughness",.595)
  cmds.setAttr (f"{PFX}recpButTXT.specularIOR",1.272)
  #>>> RECPLAYER Records TXT <<<#  
  for a in range (0,5):  
       recpRecTXT = cmds.shadingNode("aiStandardSurface",n=f"{PFX}recpRecTXT_0{a+1}",asShader=True)
       cmds.shadingNode('file',n=f"{PFX}recname", asTexture=True)
       cmds.rename(f"{PFX}recname", f"{PFX}recfile0{a+1}")
       recshadeGRP = cmds.sets(n=f"{PFX}recSet0{a+1}",renderable=True,noSurfaceShader=True,empty=True)
       if a == 0:
           axis = "E:\VSFX_160\VSFX160_Maya\sourceimages\ albm_axis02.png"
           cmds.setAttr(f"{PFX}recfile0{a+1}.fileTextureName", axis, type='string')
       elif a == 1:
           tbhc = "E:\VSFX_160\VSFX160_Maya\sourceimages\ albm_tbhc02.png"
           cmds.setAttr(f"{PFX}recfile0{a+1}.fileTextureName", tbhc, type='string')
       elif a == 2:
           mord = "E:\VSFX_160\VSFX160_Maya\sourceimages\ albm_mord02.png"
           cmds.setAttr(f"{PFX}recfile0{a+1}.fileTextureName", mord, type='string')
       elif a == 4:
           dune = "E:\VSFX_160\VSFX160_Maya\sourceimages\ albm_dune02.png"
           cmds.setAttr(f"{PFX}recfile0{a+1}.fileTextureName", dune, type='string')   
       elif a == 3:
           cbat = "E:\VSFX_160\VSFX160_Maya\sourceimages\ albm_cbat02.png"
           cmds.setAttr(f"{PFX}recfile0{a+1}.fileTextureName", cbat, type='string')    
       cmds.connectAttr(f"{PFX}recfile0{a+1}.outColor",f"{PFX}recpRecTXT_0{a+1}.baseColor")
       cmds.connectAttr(f"{PFX}recpRecTXT_0{a+1}.outColor",f"{PFX}recSet0{a+1}.surfaceShader")
       cmds.setAttr(f"{PFX}recpRecTXT_0{a+1}.specularRoughness",0.343)
       cmds.setAttr(f"{PFX}recpRecTXT_0{a+1}.specularIOR",2.021)
       cmds.select(f"{PFX}record_0{a+1}")
       cmds.hyperShade(assign= recpRecTXT)
  #>>> TABLE TXT <<<#
  tableTXT= cmds.shadingNode("aiStandardSurface",n=f"{PFX}tableTXT",asShader=True)
  fileNode = cmds.shadingNode('file',n=f"{PFX}file01", asTexture=True)
  fileNode2 = cmds.shadingNode('file',n=f"{PFX}file02", asTexture=True)
  p2d = cmds.shadingNode("place2dTexture", n=f"{PFX}p2d01",asUtility=True)
  bump2d = cmds.shadingNode("bump2d",n=f"{PFX}bump01",ar=True)
  shading_group = cmds.sets(n=f"{PFX}set01",renderable=True,noSurfaceShader=True,empty=True)
  woodFile = "E:\VSFX_160\VSFX160_Maya\sourceimages\wood_table_purp.png"
  woodtxtFile = "E:\VSFX_160\VSFX160_Maya\sourceimages\wood_table_001_rough_4k.jpg"
  cmds.setAttr(fileNode + '.fileTextureName', woodFile, type='string')
  cmds.setAttr(fileNode2 + '.fileTextureName', woodtxtFile, type='string')
  cmds.connectAttr(f"{PFX}p2d01.outUV",f"{PFX}file02.uvCoord")
  cmds.connectAttr(f"{PFX}file02.outAlpha",f"{PFX}bump01.bumpValue")
  cmds.connectAttr(f"{PFX}bump01.outNormal",f"{PFX}tableTXT.normalCamera")
  cmds.connectAttr(f"{PFX}tableTXT.outColor",f"{PFX}set01.surfaceShader")
  cmds.connectAttr(f"{PFX}file01.outColor",f"{PFX}tableTXT.baseColor")    
  cmds.setAttr(f"{PFX}tableTXT.specular",0.524)
  cmds.setAttr(f"{PFX}tableTXT.specularColor",1,.787,.737,type="double3")
  cmds.setAttr(f"{PFX}tableTXT.specularRoughness",0.671)
  cmds.setAttr(f"{PFX}tableTXT.specularIOR",1.574)
  cmds.setAttr(f"{PFX}tableTXT.subsurface",.042)
  cmds.setAttr(f"{PFX}tableTXT.subsurfaceColor",.056,.029,.022,type="double3")
  cmds.select(f"{PFX}desk*")
  cmds.hyperShade(assign= tableTXT)       
  #>> WALLS TXT <<#
  wallsTXT = cmds.shadingNode("aiStandardSurface",n=f"{PFX}wallsTXT",asShader=True)
  cmds.select(f"{PFX}wall_01",f"{PFX}wall_02")
  cmds.hyperShade(assign= wallsTXT)
  cmds.setAttr(f"{PFX}wallsTXT.baseColor",.198,.366,.314)
  cmds.setAttr(f"{PFX}wallsTXT.specularRoughness", .536)
  cmds.setAttr(f"{PFX}wallsTXT.specularIOR", 1.232)
  cmds.shadingNode("stucco",n=f"{PFX}stuccoBump", asShader=True)  
  cmds.shadingNode("place3dTexture",n=f"{PFX}place3dTXT", au=True)
  cmds.shadingNode("bump3d", n=f"{PFX}bump01", au=True)
  cmds.connectAttr(f"{PFX}place3dTXT.worldInverseMatrix[0]", f"{PFX}stuccoBump.placementMatrix")   
  cmds.connectAttr(f"{PFX}stuccoBump.outAlpha",f"{PFX}bump01.bumpValue", f=True)
  cmds.connectAttr(f"{PFX}bump01.outNormal","newt_wallsTXT.normalCamera", f=True)
  cmds.setAttr(f"{PFX}stuccoBump.channel1",.006,0,0,type="double3")
  cmds.setAttr(f"{PFX}stuccoBump.channel2",0,0,.02,type="double3")
  cmds.delete(f"{PFX}place3dTXT")
  #>>> WALLS Celing TXT <<<#
  wallsCelTXT = cmds.shadingNode("aiStandardSurface",n=f"{PFX}wallsCelTXT",asShader=True)
  cmds.select(f"{PFX}wall_04")
  cmds.hyperShade(assign= wallsCelTXT)
  cmds.setAttr(f"{PFX}wallsCelTXT.baseColor",0.783, 0.753, 0.761)
  cmds.setAttr(f"{PFX}wallsCelTXT.specularRoughness", .536)
  cmds.setAttr(f"{PFX}wallsCelTXT.specularIOR", 1.232)
  #>>> WALLS Floor TXT <<<#
  wallsFlrTXT = cmds.shadingNode("aiStandardSurface",n=f"{PFX}wallsFlrTXT",asShader=True)
  cmds.select(f"{PFX}wall_03")
  cmds.hyperShade(assign= wallsFlrTXT)
  cmds.setAttr(f"{PFX}wallsFlrTXT.baseColor",0.084,.041,.022)
  cmds.setAttr(f"{PFX}wallsFlrTXT.specularRoughness", .536)
  cmds.setAttr(f"{PFX}wallsFlrTXT.specularIOR", 1.232)
  #>>> WIINDOW Frame TXT <<<#
  windFrameTXT = cmds.shadingNode('aiStandardSurface',n = f"{PFX}windFrameTXT", asShader=True)
  cmds.select(f"{PFX}windFrame_01")
  cmds.hyperShade( assign=windFrameTXT )
  cmds.setAttr (f"{PFX}windFrameTXT.baseColor",.978,.961,.8)
  cmds.setAttr (f"{PFX}windFrameTXT.specularColor",1,1,1)
  cmds.setAttr (f"{PFX}windFrameTXT.specularRoughness",.252)
  cmds.setAttr (f"{PFX}windFrameTXT.specularIOR",1.426)
  #>> WINDOW Glass TXT <<#
  glassTXT = cmds.shadingNode('aiStandardSurface',n = f"{PFX}glassTXT", asShader=True)
  cmds.select(f"{PFX}windGlass_01")
  cmds.hyperShade( assign=glassTXT)    
  cmds.setAttr(f"{PFX}glassTXT.metalness",0)
  cmds.setAttr(f"{PFX}glassTXT.specularRoughness", 0.06)
  cmds.setAttr(f"{PFX}glassTXT.specularIOR", 1.5)
  cmds.setAttr(f"{PFX}glassTXT.transmission", 1)
  #>>> Outside Plane <<<#
  outsTXT = cmds.shadingNode("aiStandardSurface", n=f"{PFX}outsTXT",asShader=True)
  outsfileNode = cmds.shadingNode('file',n=f"{PFX}outsFile", asTexture=True)
  outsNodeGRP = cmds.sets(n=f"{PFX}outsSet01",renderable=True,noSurfaceShader=True,empty=True)
  outs = "E:\VSFX_160\VSFX160_Maya\sourceimages\ parkimg.jpeg"
  cmds.setAttr(f"{PFX}outsFile.fileTextureName", outs, type='string')      
  cmds.connectAttr(f"{PFX}outsFile.outColor",f"{PFX}outsTXT.baseColor")
  cmds.connectAttr(f"{PFX}outsTXT.outColor",f"{PFX}outsSet01.surfaceShader")
  cmds.select(f"{PFX}outside")
  cmds.hyperShade(assign= outsTXT)
   
def lights():
  import mtoa.utils as mutils
  ### Outside Area Light 01 ###
  mutils.createLocator('aiAreaLight', asLight=True)
  area01 = cmds.rename('aiAreaLight1', f"{PFX}areaLight01")
  cmds.select(f"{PFX}areaLight01")
  cmds.move(19.03,27.383,74.753)
  cmds.rotate(-15.749,12.344,-1.913)
  cmds.scale(100,100,100)
  cmds.setAttr(f"{PFX}areaLightShape1.color", 1,0.943,.853)
  cmds.setAttr(f"{PFX}areaLightShape1.exposure", 16.361)
  cmds.setAttr(f"{PFX}areaLightShape1.intensity", 2)
  cmds.setAttr(f"{PFX}areaLightShape1.aiSamples", 10)
  ### Inside Area Light 02 ###
  mutils.createLocator('aiAreaLight', asLight=True)
  area01 = cmds.rename('aiAreaLight1', f"{PFX}areaLight02")
  cmds.select(f"{PFX}areaLight02")
  cmds.move(14.959,-6.115,-7.787)
  cmds.rotate(22.737,92.459,37.033)
  cmds.scale(31.741,6.54,100)
  cmds.setAttr(f"{PFX}areaLightShape2.color", 0.718, 0.739691, 1)
  cmds.setAttr(f"{PFX}areaLightShape2.exposure", 9.633)
  cmds.setAttr(f"{PFX}areaLightShape2.intensity", 1.250)
  cmds.setAttr(f"{PFX}areaLightShape2.aiSamples", 10)
  ### Inside Area Light 03 ##
  mutils.createLocator('aiAreaLight', asLight=True)
  area01 = cmds.rename('aiAreaLight1', f"{PFX}areaLight03")
  cmds.select(f"{PFX}areaLight03")
  cmds.move(48.355,64.689,-23.559)
  cmds.rotate(-90,0,0)
  cmds.scale(50.429,44.314,26.975)
  cmds.setAttr(f"{PFX}areaLightShape3.color", 0.931, 0.923, 1)
  cmds.setAttr(f"{PFX}areaLightShape3.exposure", 11.840)
  cmds.setAttr(f"{PFX}areaLightShape3.intensity", 1.938)  
  cmds.setAttr(f"{PFX}areaLightShape3.aiSamples", 10)
  cmds.setAttr(f"{PFX}areaLightShape3.aiSpecular", 10)
  ### Lamp Light 01 ###
  cmds.pointLight(n=f"{PFX}lampLight_01")
  cmds.move(1.161,19.865,-45.844)
  cmds.setAttr(f"{PFX}lampLight_01.intensity",.668)
  cmds.setAttr(f"{PFX}lampLight_01.aiExposure",10.664)
  cmds.setAttr(f"{PFX}lampLight_01.color",1, 0.577, 0.577)
  cmds.setAttr(f"{PFX}lampLight_01.aiSamples", 10)

def rendCam ():
  cmds.camera(n=f"{PFX}rendCAM", fl=50, hfa=1.417, vfa=.945, fs=5.6, coi=21.401)
  cmds.move(58.805, 20.161, -55.336)
  cmds.rotate(-11.321, -225.671, .0324)
  cmds.scale(2.61, 2.61, 2.61)
  cmds.setAttr("defaultArnoldRenderOptions.AASamples",2)
  cmds.setAttr ("defaultArnoldRenderOptions.GIDiffuseSamples", 6)
   
                                 
def main():
  cradle()
  animation()
  animspin()
  enviornment()
  textures()
  lights()
  rendCam()
   
main()    

bottom of page