コード例 #1
0
	def checkout(self):
		curfilepath = cmd.file(query=True, sceneName=True)
		if not curfilepath == '':
			cmd.file(save=True, force=True)

		toCheckout = self.get_asset_path()
		
		try:
			destpath = amu.checkout(toCheckout, True)
		except Exception as e:
			print str(e)
			if not amu.checkedOutByMe(toCheckout):
				cmd.confirmDialog(  title          = 'Can Not Checkout'
                                   , message       = str(e)
                                   , button        = ['Ok']
                                   , defaultButton = 'Ok'
                                   , cancelButton  = 'Ok'
                                   , dismissString = 'Ok')
				return
			else:
				destpath = amu.getCheckoutDest(toCheckout)

		toOpen = os.path.join(destpath, self.get_filename(toCheckout)+'.mb')
		# open the file
		if os.path.exists(toOpen):
			cmd.file(toOpen, force=True, open=True)#, loadReferenceDepth="none")
		else:
			# create new file
			cmd.file(force=True, new=True)
			cmd.file(rename=toOpen)
			cmd.viewClipPlane('perspShape', ncp=0.01)
			cmd.file(save=True, force=True)
		
		self.close_dialog()
コード例 #2
0
def go():
    filePath = cmds.file(q=True, sceneName=True)
    toCheckin = os.path.join(amu.getUserCheckoutDir(),
                             os.path.basename(os.path.dirname(filePath)))
    toCheckout = amu.getCheckinDest(toCheckin)
    maya_checkin.checkin()
    try:
        destpath = amu.checkout(toCheckout, True)
    except Exception as e:
        print str(e)
        if not amu.checkedOutByMe(toCheckout):
            cmd.confirmDialog(title='Can Not Checkout',
                              message=str(e),
                              button=['Ok'],
                              defaultButton='Ok',
                              cancelButton='Ok',
                              dismissString='Ok')
            return
        else:
            destpath = amu.getCheckoutDest(toCheckout)
    filename = os.path.basename(os.path.dirname(
        toCheckout)) + '_' + os.path.basename(toCheckout) + '.mb'
    toOpen = os.path.join(destpath, filename)
    # open the file
    if os.path.exists(toOpen):
        cmds.file(toOpen, force=True, open=True)  #, loadReferenceDepth="none")
    else:
        # create new file
        cmds.file(force=True, new=True)
        cmds.file(rename=toOpen)
        cmds.viewClipPlane('perspShape', ncp=0.01)
        cmds.file(save=True, force=True)
コード例 #3
0
    def checkout(self):
        curfilepath = cmd.file(query=True, sceneName=True)
        if not curfilepath == '':
            cmd.file(save=True, force=True)

        toCheckout = self.get_asset_path()

        try:
            destpath = amu.checkout(toCheckout, True)
        except Exception as e:
            print str(e)
            if not amu.checkedOutByMe(toCheckout):
                cmd.confirmDialog(title='Can Not Checkout',
                                  message=str(e),
                                  button=['Ok'],
                                  defaultButton='Ok',
                                  cancelButton='Ok',
                                  dismissString='Ok')
                return
            else:
                destpath = amu.getCheckoutDest(toCheckout)

        toOpen = os.path.join(destpath, self.get_filename(toCheckout) + '.mb')
        # open the file
        if os.path.exists(toOpen):
            cmd.file(toOpen, force=True,
                     open=True)  #, loadReferenceDepth="none")
        else:
            # create new file
            cmd.file(force=True, new=True)
            cmd.file(rename=toOpen)
            cmd.viewClipPlane('perspShape', ncp=0.01)
            cmd.file(save=True, force=True)

        self.close_dialog()
コード例 #4
0
def go():
    filePath = cmds.file(q=True, sceneName=True)
    toCheckin = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filePath)))
    toCheckout = amu.getCheckinDest(toCheckin) 
    maya_checkin.checkin()
    try:
        destpath = amu.checkout(toCheckout, True)
    except Exception as e:
        print str(e)
        if not amu.checkedOutByMe(toCheckout):
            cmd.confirmDialog(  title          = 'Can Not Checkout'
                               , message       = str(e)
                               , button        = ['Ok']
                               , defaultButton = 'Ok'
                               , cancelButton  = 'Ok'
                               , dismissString = 'Ok')
            return
        else:
            destpath = amu.getCheckoutDest(toCheckout)
    filename = os.path.basename(os.path.dirname(toCheckout))+'_'+os.path.basename(toCheckout)+'.mb'
    toOpen = os.path.join(destpath, filename)
    # open the file
    if os.path.exists(toOpen):
        cmds.file(toOpen, force=True, open=True)#, loadReferenceDepth="none")
    else:
        # create new file
        cmds.file(force=True, new=True)
        cmds.file(rename=toOpen)
        cmds.viewClipPlane('perspShape', ncp=0.01)
        cmds.file(save=True, force=True)
コード例 #5
0
def maya_camera_clipping():
    cmds.viewClipPlane(
        "frontShape", ncp="1", fcp="100000.0"
    )  # To change the clipping planes, change the numbers inbetween the " " to what you need
    cmds.viewClipPlane(
        "perspShape", ncp="1",
        fcp="100000.0")  # ncp = near clip plane // fcp = far clip plane
    cmds.viewClipPlane("sideShape", ncp="1", fcp="100000.0")
    cmds.viewClipPlane("topShape", ncp="1", fcp="100000.0")
    cmds.delete(constructionHistory=True
                )  # Delete this if you don't want to delete history
    om.MGlobal.displayWarning(
        "Cameras Updated")  # Displays warning to confirm cameras have changed
コード例 #6
0
ファイル: maya_checkout.py プロジェクト: yazici/papa-tools
	def checkout(self):

		# If it's not a file that hasn't been saved before, save it.
		curfilepath = cmd.file(query=True, sceneName=True)
		if not curfilepath == '':
			cmd.file(save=True, force=True)

		itemToCheckout = str(self.current_item.text())
		try:
			filePath = facade.checkout(itemToCheckout, True, self.context.name)
		except Exception as e:
			print str(e)
			if not facade.checkedOutByMe(itemToCheckout, self.context.name):
				cmd.confirmDialog(  title          = 'Can Not Checkout'
                                   , message       = str(e)
                                   , button        = ['Ok']
                                   , defaultButton = 'Ok'
                                   , cancelButton  = 'Ok'
                                   , dismissString = 'Ok')
				return
			else:
				filePath = facade.getCheckoutDest(itemToCheckout, self.context.name)

		# Adding the file path together so we can open the file.
		userFilePath = facade.getFilepath(filePath, itemToCheckout, self.context.name)
		toOpen = userFilePath + ".mb"
		print "maya filePath", toOpen

		# # open the file
		if os.path.exists(toOpen):
			cmd.file(toOpen, force=True, open=True)#, loadReferenceDepth="none")
		else:
			# create new file - for new assets
			cmd.file(force=True, new=True)
			cmd.file(rename=toOpen)
			cmd.viewClipPlane('perspShape', ncp=0.01)
			cmd.file(save=True, force=True)
		
		self.close_dialog()
コード例 #7
0
def go():
    filePath = cmds.file(q=True, sceneName=True)
    # Need to grab the asset name and asset type so we can check it out later on.
    assetType = facade.getAssetType(filePath)
    assetName = facade.getAssetName(filePath)
    # print "assetType: ", assetType
    # print "assetName: ", assetName
    maya_checkin.checkin()

    try:
        destpath = facade.checkout(assetName, True, assetType)
    except Exception as e:
        print str(e)
        if not facade.checkedOutByMe(assetName, assetType):
            cmd.confirmDialog(title='Can Not Checkout',
                              message=str(e),
                              button=['Ok'],
                              defaultButton='Ok',
                              cancelButton='Ok',
                              dismissString='Ok')
            return
        else:
            destpath = facade.getCheckoutDest(assetName, assetType)

    filename = facade.getFilepath(destpath, assetName, assetType)
    filename = filename + ".mb"
    toOpen = os.path.join(destpath, filename)
    # open the file
    if os.path.exists(toOpen):
        cmds.file(toOpen, force=True, open=True)  #, loadReferenceDepth="none")
    else:
        # create new file
        cmds.file(force=True, new=True)
        cmds.file(rename=toOpen)
        cmds.viewClipPlane('perspShape', ncp=0.01)
        cmds.file(save=True, force=True)
コード例 #8
0
def doFileAnalysis(infile,*args):
    print '\ninfile: %s' % (infile)
    print 'project: %s' % (cmds.workspace(q=1,fn=1))
    cmds.file(infile,o=1,f=1)
    # first: if this is not a mayaBinary file, save it as one.
    scenePath = infile
    if os.path.splitext(infile)[-1] != '.mb':
        # remove all unknown nodes and save as MB
        unk = cmds.ls(type='unknown')
        if unk:
            for i in unk:
                try:
                    cmds.lockNode(i,lock=0)
                    cmds.delete(i)
                except:
                    pass
        scenePath = os.path.splitext(infile)[0]+'.mb'
        cmds.file(rename=scenePath)
        cmds.file(s=1,f=1,type='mayaBinary')
    meshes = []
    surfaces = []
    meshes = cmds.ls(type='mesh',l=1)
    surfaces = cmds.ls(type='nurbsSurface',l=1)
    # create temp camera
    cam = cmds.camera()
    cmds.setAttr(cam[0]+'.rx',-35)
    cmds.setAttr(cam[0]+'.ry',45)
    meshXforms = []
    if meshes:
        for mesh in meshes:
            xf = cmds.listRelatives(mesh,p=1,f=1)[0]
            meshXforms.append(xf)
    if surfaces:
        for surface in surfaces:
            xf = cmds.listRelatives(surface,p=1,f=1)[0]
            meshXforms.append(xf)
    meshXforms = [f for f in meshXforms if cmds.getAttr(f+'.visibility') == 1]
    if not meshXforms:
        # nothing here, throw an error
        cmds.quit(ec=86,f=1)
    cmds.select(meshXforms)
    # set active resolution before fitting.
    cmds.setAttr('defaultResolution.aspectLock',0)
    cmds.setAttr('defaultResolution.width',720)
    cmds.setAttr('defaultResolution.height',405)
    cmds.setAttr('defaultResolution.pixelAspect',1)
    cmds.setAttr('defaultResolution.deviceAspectRatio',1.778)
    cmds.viewFit(cam[1],f=0.9)
    cmds.viewClipPlane(cam[1],acp=1)
    cmds.select(cl=1)
    allCams = cmds.ls(type='camera')
    for c in allCams:
        cmds.setAttr(c+'.renderable',0)
    cmds.setAttr(cam[1]+'.renderable',1)
    engine = cmds.sets(renderable=1,noSurfaceShader=1,em=1)
    mat = cmds.shadingNode('surfaceShader',asShader=1)
    cmds.connectAttr(mat+'.outColor',engine+'.surfaceShader')
    aotex = cmds.shadingNode('mib_amb_occlusion',asTexture=1)
    cmds.connectAttr(aotex+'.outValue',mat+'.outColor')
    cmds.setAttr(aotex+'.samples',32)
    # create a new temporary render layer and add all objects
    rlayer = cmds.createRenderLayer(n='tempLayer',g=1,mc=1)
    # assign AO shader to all meshes and surfaces
    if meshes:
        cmds.sets(meshes,e=1,fe=engine)
    if surfaces:
        cmds.sets(surfaces,e=1,fe=engine)
    # get all existing file textures and add the paths to a list
    textures = []
    fileNodes = cmds.ls(type='file')
    for node in fileNodes:
        tex = cmds.getAttr(node+'.fileTextureName')
        textures.append(tex.strip().replace('\n',''))
    # set mental ray as the current renderer and set up output settings
    cmds.setAttr('defaultRenderGlobals.currentRenderer','mentalRay',type='string')
    # to prevent overwriting other images with the same name, use the unix timestamp as the image name.
    rand_imageFilePrefix = str(int(time.time()))
    mel.eval('miCreateDefaultNodes();')
    cmds.setAttr('defaultRenderGlobals.imageFormat',8)
    cmds.setAttr('defaultRenderGlobals.outFormatControl',0)
    cmds.setAttr('defaultRenderGlobals.useFrameExt',0)
    cmds.setAttr('defaultRenderGlobals.animation',0)
    cmds.setAttr('defaultRenderGlobals.useMayaFileName',1)
    cmds.setAttr('defaultRenderGlobals.imageFilePrefix',rand_imageFilePrefix,type='string')
    mel.eval('miCreateDefaultNodes();')
    cmds.setAttr('miDefaultOptions.rayTracing',1)
    cmds.setAttr('miDefaultOptions.maxSamples',2)
    cmds.setAttr('miDefaultOptions.minSamples',0)
    cmds.setAttr('miDefaultOptions.maxReflectionRays',1)
    cmds.setAttr('miDefaultOptions.finalGather',0)
    cmds.setAttr('miDefaultOptions.filter',2)
    # get output filename
    tempProject = cmds.workspace(q=1,fn=1)
    outFile = os.path.join(tempProject,'images',rlayer,rand_imageFilePrefix+'.jpg')
    # disable all render layers except rlayer
    layers = cmds.ls(type='renderLayer')
    for layer in layers:
        cmds.setAttr(layer+'.renderable',0)
    cmds.setAttr(rlayer+'.renderable',1)
    ren = cmds.Mayatomr(r=1,camera=cam[1],x=720,y=405,l=rlayer,rv=5)
    st = 'screenshot written to %s' % (outFile)
    print(st)
    return infile,outFile,textures,scenePath,ren
コード例 #9
0
                 cmds.setAttr('root.scalePivot', 0, 0, 0, type="double3")
                 cmds.setAttr('root.rotate', 90, 0, 180 - float(tokens[1]), type="double3")
                 cmds.makeIdentity( 'root' , apply=True, translate=True, rotate=True, scale=True, n=0)
            lands_counter+=1
    if tokens[0]=="SpotLight:" :
            node_name = "lightmast_%d" % light_masts
            cmds.createNode( 'transform', n=node_name , p='root')
            light_masts +=1
            cmds.setAttr( node_name + '.translateX', float(tokens[3]))
            cmds.setAttr( node_name + '.translateY', float(tokens[4]))
            cmds.setAttr( node_name + '.translateZ', float(tokens[5]))
            cmds.setAttr( node_name + '.rotate', -45, 0, 0, type="double3")
            cmds.setAttr( node_name + '.displayLocalAxis', 1)
    if tokens[0]=="SECTOR:" :
            node_name = "sector_%d" % sectors
            cmds.createNode( 'transform', n=node_name  , p='root')
            sectors +=1
            cmds.setAttr( node_name + '.translateX', float(tokens[2]))
            cmds.setAttr( node_name + '.translateY', float(tokens[3]))
            cmds.setAttr( node_name + '.translateZ', float(tokens[5]))
            cmds.setAttr( node_name + '.rotate', 0, 0, float(tokens[4]), type="double3")
            cmds.setAttr( node_name + '.displayLocalAxis', 1)	

cmds.viewClipPlane( 'perspShape', acp=True, fcp=100000.0 )
#cmds.selectType( q=True, cv=True )
#nodes = cmds.ls( geometry=True )
#cmds.group( nodes, n='root')



コード例 #10
0
ファイル: scn_import.py プロジェクト: flylong0204/test_osg
                              scale=True,
                              n=0)
        lands_counter += 1
    if tokens[0] == "SpotLight:":
        node_name = "lightmast_%d" % light_masts
        cmds.createNode('transform', n=node_name, p='root')
        light_masts += 1
        cmds.setAttr(node_name + '.translateX', float(tokens[3]))
        cmds.setAttr(node_name + '.translateY', float(tokens[4]))
        cmds.setAttr(node_name + '.translateZ', float(tokens[5]))
        cmds.setAttr(node_name + '.rotate', -45, 0, 0, type="double3")
        cmds.setAttr(node_name + '.displayLocalAxis', 1)
    if tokens[0] == "SECTOR:":
        node_name = "sector_%d" % sectors
        cmds.createNode('transform', n=node_name, p='root')
        sectors += 1
        cmds.setAttr(node_name + '.translateX', float(tokens[2]))
        cmds.setAttr(node_name + '.translateY', float(tokens[3]))
        cmds.setAttr(node_name + '.translateZ', float(tokens[5]))
        cmds.setAttr(node_name + '.rotate',
                     0,
                     0,
                     float(tokens[4]),
                     type="double3")
        cmds.setAttr(node_name + '.displayLocalAxis', 1)

cmds.viewClipPlane('perspShape', acp=True, fcp=100000.0)
#cmds.selectType( q=True, cv=True )
#nodes = cmds.ls( geometry=True )
#cmds.group( nodes, n='root')
コード例 #11
0
'''
written by Emily Pollacchi
  	file name create_background_rings
  	Copyright (C) 2016 by Emily Pollacchi
  	[email protected]
'''

import maya.cmds as mc

#change perspective clip plane
mc.viewClipPlane("perspShape", farClipPlane = 100000)

#set up naming loop

matteNames = ("g_foreground", "g_midground", "g_background")

inc = 0

#create rings

for ring in range(3):
    
    newRing = mc.polyCylinder(n = matteNames[inc], sx=24, sy=3, sz=0, radius=3000, h=2000)
    mc.move(340, y=True)
    mc.polyNormal(nm=0)
        
    inc = inc + 1

#adjust the scale
mc.setAttr("polyCylinder2.radius", 3440)
mc.setAttr("polyCylinder3.radius", 3880)