jul...@valkov.com
unread,Aug 24, 2016, 2:50:57 PM8/24/16Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Python Programming for Autodesk Maya
I am rather new to both python and maya. I'm trying to build a tool to create a skybox, so I have already created the cube and inverted its normals, but i can't seem to find how to apply a texture to it. All help is appreciated. Thank you.
Here is my code:
import maya.cmds as cmds
from os import listdir
def makeSphere(*args):
cmds.polySphere( n='mySphere', sx=100, sy=100)
return
def makeCube(*args):
cmds.polyCube( sx=5, sy=5, sz=5 )
return
def makeCylinder(*args):
cmds.polyCylinder(n='myCylinder', sx=5, sy=5, sz=5)
return
def makeCone(*args):
cmds.polyCone( sx=10, sy=15, sz=5, r=20, h=10)
return
def makePlane(*args):
cmds.polyPlane( sx=10, sy=15, w=15, h=20)
return
def makeTorus(*args):
cmds.polyTorus( sx=8, sy=16, r=10, sr=1 )
return
def makePrism(*args):
cmds.polyPrism ( sc=10, sh=15, w=20)
return
def makePyramid(*args):
cmds.polyPyramid( sc=10, sh=15, ns=5, w=20)
return
def makePipe(*args):
cmds.polyPipe( sh=10, h=20 )
return
def makeHelix(*args):
cmds.polyHelix(r=1, d=1, cuv=0)
return
def makeSoccerball(*args):
cmds.polyPrimitive( r=1, l=0.4036, pt=0)
return
def makePlatonicSolids(*args):
cmds.polyPlatonicSolid( r=2, l=2, st=1)
return
def importModel(*args):
filename = cmds.fileDialog2(fileMode=1, caption="Import model")
cmds.file( filename[0], i=True );
return
def makeSkybox(*args):
cmds.polyCube( sx=100, sy=100, sz=100, name = "skybox" )
# cmds.polyCut(deleteFaces = True, cuttingDirection = "y", cutPlaneCenter = (0, 0, 0) )
cmds.polyNormal('skybox', nm = 0)
filename = cmds.fileDialog2(fileMode=1, caption="Import texture")
#cmds.polyProjection('skybox', type = 'Spherical' ,uvSetName= filename[0])
cmds.file( filename[0], i=True, applyTo = "skybox")
#image_skybox = input("Please input the full file location of the desired image to be applied to your skybox: ")
#cmds.image(image = image_skybox)
return
winID = "kevsFrameWin"
if cmds.window(winID, exists=True):
cmds.deleteUI(winID)
# Create the window
cmds.window(winID,t="frames")
# Create a 'container' Layout to keep our frames in
rootLayout = cmds.columnLayout()
# Create a frame layout. Note that I am not declaring a
# variable here as frameLayout are only supposed to
# support a single child, and our child will be another
# layout... So we really want to reference the child
# rather then the frameLayout parent anyway.
cmds.frameLayout( label="Top frame" )
# Generate a child Layout inside the frame.
# declare a variable here as it will allow us to reference
# contents inside our frame (within this layout).
frameOne = cmds.columnLayout()
cmds.button( label='Sphere', command=makeSphere)
cmds.button( label='Cube', command=makeCube)
cmds.button( label='Cylinder', command=makeCylinder)
cmds.button( label='Cone', command=makeCone)
cmds.button( label='Plane', command=makePlane)
cmds.button( label='Torus', command=makeTorus)
cmds.button( label='Prism', command=makePrism)
cmds.button( label='Pyramid', command=makePyramid)
cmds.button( label='Pipe', command=makePipe)
cmds.button( label='Helix', command=makeHelix)
cmds.button( label='Soccerball', command=makeSoccerball)
cmds.button( label='Platonic Solid', command=makePlatonicSolids)
cmds.button( label='Skybox', command=makeSkybox)
cmds.button( label='Browse to import models', command=importModel)
# Jump back to our root container Layout to add a new Frame
# If we were to use the '..' approach, we would need *2* of
# them to get back to the root.
#
# '..' back to the frame parent, then '..' to the root parent
cmds.setParent(rootLayout)
# Display the UI
cmds.showWindow(winID)