def edit_grid(unit=None, *args, **kwargs): # Default size = 12.0 spacing = 5.0 divisions = 5.0 if unit == 'centimeters': size = 12.0 spacing = 5.0 divisions = 5.0 elif unit == 'meters': size = 30.4800 * 5.0 spacing = 30.4800 divisions = 1.0 elif unit == 'inches': size = 2.54 * 12.0 spacing = 2.54 divisions = 1.0 elif unit == 'feet': size = 30.48 * 5.0 spacing = 30.48 divisions = 1.0 cmds.grid(size=size, spacing=spacing, divisions=divisions) return
def _adjustGridScale(self, amount, *args): """ Increase or decrease the grid scale by amount. This is not the grid spacing. """ gridSize = cmds.grid(q=True, size=True) cmds.grid(size=gridSize + amount)
def gridSizeChange(direction, amount): currentGridSize = cmds.grid(query=True, size=True) if direction == 'up': cmds.grid(size=(currentGridSize + amount)) consolePrint("Grid has grown", "") elif direction == 'down': cmds.grid(size=(currentGridSize - amount)) consolePrint("Grid has shrunk", "")
def Reset(self): # Reset to default # Set linear units to cm cmds.currentUnit(linear='cm') # Change grid size to 1000 length and width, 10 grids every line, and 1 subdivision cmds.grid(size=12, spacing=5, d=5) cmds.optionVar(fv=("gridDivisions", 5)) cmds.optionVar(fv=("gridSize", 12)) cmds.optionVar(fv=("gridSpacing", 5))
def setGridRugbyBugsDefault(): #set correct grid units and display settings cmds.grid(spacing = 5, divisions = 5, size = 10) cmds.displayColor( 'gridHighlight', 12, dormant=True ) cmds.displayColor( 'grid', 3, dormant=True ) #Turn grid on by default gridState = cmds.grid( toggle=True, q=True ) if not(gridState): cmds.grid( toggle = True ) #Print to console instead of script editor sys.__stdout__.write('Successfully set Rugby Bugs standard grid deferred\n')
def setup_scene_viewport_playblast(shotName): mc.grid(toggle=0) mc.setAttr("defaultResolution.width",960) mc.setAttr("defaultResolution.height",540) if mc.objExists(shotName): mc.setAttr('%s_camShape.displayGateMask' %(shotName), True) mc.setAttr('%s_camShape.displayResolution' %(shotName), True) mc.setAttr('%s_camShape.displayGateMaskOpacity' %(shotName), 1) mc.setAttr('%s_camShape.displayGateMaskColor' %(shotName), 0, 0, 0, type='double3') mc.setAttr('%s_camShape.overscan' %(shotName),1.0)
def Startup(self): # Set linear units to cm cmds.currentUnit(linear='cm') # Change grid size to 1000 length and width, 10 grids every line, and 1 subdivision cmds.grid(size=500, spacing=10, d=1) cmds.optionVar(fv=("gridDivisions", 1)) cmds.optionVar(fv=("gridSize", 500)) cmds.optionVar(fv=("gridSpacing", 10)) # Make a reference cube that is 1/1/1 cmds.polyCube(sx=1, sy=1, sz=1, h=100, w=100, d=100) cmds.CenterPivot()
def toggleGrid(): panel = mc.getPanel(withFocus=True) ptype = mc.getPanel(typeOf=panel) # if in UV Editor toggle the according grid there if ptype == 'scriptedPanel' and panel.startswith('polyTexturePlacementPanel'): state = mc.textureWindow(panel, q=True, tgl=True) mc.textureWindow(panel, e=True, tgl=not state) # else use these 2 grid toggelling methods to switch it for sure elif ptype == 'modelPanel': state = True if mc.grid(q=True, toggle=True) or mc.modelEditor(panel, q=True, grid=True): state = False mc.grid(toggle=state) mc.modelEditor(panel, e=True, grid=state)
def snapshot(outputPath, width=400, height=None, hud=False, grid=False): if height is None: height = width outputExt = os.path.splitext(outputPath)[1].lower().lstrip('.') formatNum = KNOWN_FORMATS.get(outputExt) if formatNum is None: raise ValueError( "input image had unrecognized extension: {}".format(outputExt)) # if given relative path, make it relative to current dir (the test # temp base), rather than the workspace dir outputPath = os.path.abspath(outputPath) # save the old output image format oldFormat = cmds.getAttr("defaultRenderGlobals.imageFormat") # save the hud setting oldHud = cmds.headsUpDisplay(q=1, layoutVisibility=1) # save the grid setting oldGrid = cmds.grid(q=1, toggle=1) # save the old view transform oldViewTransform = cmds.colorManagementPrefs(q=1, viewTransformName=1) # do these in a separate try/finally from color management, because # color management seems a bit more finicky cmds.setAttr("defaultRenderGlobals.imageFormat", 32) cmds.headsUpDisplay(layoutVisibility=hud) cmds.grid(toggle=grid) try: # Doing this would be more direct: # cmds.colorManagementPrefs(e=1, outputTarget="playblast", # outputTransformName="Raw") # ... but it causes maya-2018.3 to crash. It seems to be fixed in 2019.0. cmds.colorManagementPrefs(e=1, viewTransformName="Raw") try: cmds.playblast(cf=outputPath, viewer=False, format="image", frame=cmds.currentTime(q=1), offScreen=1, widthHeight=(width, height), percent=100) finally: cmds.colorManagementPrefs(e=1, viewTransformName=oldViewTransform) finally: cmds.setAttr("defaultRenderGlobals.imageFormat", oldFormat) cmds.headsUpDisplay(layoutVisibility=oldHud) cmds.grid(toggle=oldGrid)
def set_grid_default(): #set correct grid units and display settings cmds.grid(spacing=5, divisions=5, size=10) cmds.displayColor('gridHighlight', 12, dormant=True) cmds.displayColor('grid', 3, dormant=True) #Turn grid on by default gridState = cmds.grid(toggle=True, q=True) if not (gridState): cmds.grid(toggle=True) #Print to console instead of script editor sys.__stdout__.write('Successfully set standard grid deferred\n') #Dividerline sys.__stdout__.write(DIVIDERLINE)
def _changeGrid(self, gSize, gSpacing, gDivisions, gcGridA, gcGridHl, gcGrid, fClipping, nClipping, trans, *args): """ Sets several grid settings Color: gridAxis, gridHighlight, grid Distance: nearClipPlan, farClipPlan Camera: X,Y,Z """ cmds.grid(size=gSize, spacing=gSpacing, divisions=gDivisions) cmds.displayColor('gridAxis', gcGridA, q=True, dormant=True) cmds.displayColor('gridHighlight', gcGridHl, q=True, dormant=True) cmds.displayColor('grid', gcGrid, q=True, dormant=True) cmds.setAttr('perspShape.farClipPlane', fClipping) cmds.setAttr('perspShape.nearClipPlane', nClipping) cmds.setAttr('top.translateY', trans) cmds.setAttr('front.translateZ', trans) cmds.setAttr('side.translateX', trans) cmds.viewSet(home=True, animate=True)
def setup(self): ''' Setup some scene attributes we want to be common to all Spinifex car scenes TODO: make width over height as float ''' # Check if we haven't done this before if cmds.objExists('vraySettings.setupSceneHasBeenRun'): # Check that everything is setup correctly before continuing. dialogMessage = 'setupScene has already been run. Do you wish to continue? Some of your render settings will be reset.' result = cmds.confirmDialog( title='spck', message=dialogMessage, button=['YES','NO'], defaultButton='NO', cancelButton='NO', dismissString='NO' ) if result == 'NO' : print("Aborted. We\'ve done this before...\n") print 'Maybe hit undo? Your render settings just got reset by pressing the shelf button, regardless. I\'ll fix this bug one day.\n' return else: # Check that everything is setup correctly before continuing. dialogMessage = 'Have you set up your workspace.mel?' result = cmds.confirmDialog( title='spck', message=dialogMessage, button=['YES','NO'], defaultButton='YES', cancelButton='NO', dismissString='NO' ) if result == 'NO' : print('Go setup your workspace and run again.\n') return # Units for working in metric and 30fps cmds.currentUnit (linear='cm') cmds.currentUnit (angle='deg') cmds.currentUnit (time='ntsc') cmds.grid ( size = 1000, spacing= 100, divisions = 10, olp = 'edge' , plp = 'axis') # Load VRAY if not active cmds.loadPlugin ('vrayformaya', quiet=True) cmds.pluginInfo ('vrayformaya', edit=True, autoload=True) cmds.setAttr ('defaultRenderGlobals.ren', 'vray', type='string') #cmds.evalDeferred ( 'self.createBaseRenderSettings()' , lowestPriority=True ) print('Scene Setup Success.\n')
def new_scene(force=True): """ Open new scene. Set all scene variables and options correctly. """ axis = os.getenv("UPAXIS") units = os.getenv("UNITS") # Force new open if force: cmds.file(f=force, new=1) else: mel.eval('saveChanges("file -f -new")') cmds.file(f=force, new=1) # Up Axis if cmds.upAxis(q=1, axis=1).capitalize() != axis.capitalize(): cmds.upAxis(axis=axis, rv=1) # FPS intFps=int(os.getenv("FPS")) fps=fps_val(intFps) cmds.currentUnit(time=fps, ua=0) # Units cmds.currentUnit(l=units) # Set Clipping Planes cmds.setAttr("perspShape.nearClipPlane", 0.001) cmds.setAttr("perspShape.farClipPlane", 1000) cmds.setAttr("sideShape.nearClipPlane", 0.001) cmds.setAttr("sideShape.farClipPlane", 1000) cmds.setAttr("topShape.nearClipPlane", 0.001) cmds.setAttr("topShape.farClipPlane", 1000) cmds.setAttr("frontShape.nearClipPlane", 0.001) cmds.setAttr("frontShape.farClipPlane", 1000) # Grid if units == "meter": cmds.grid(size=10, divisions=5, sp=5) elif units == "centimeter": cmds.grid(size=100, divisions=50, sp=5) elif units == "millimeter": cmds.grid(size=1000, divisions=500, sp=5) # Set timeline to first frame cmds.currentTime(1) cmds.playbackOptions(aet=100, min=1, max=100) # Fit view cmds.viewFit(an=1, all=1)
def restoreGrid(): global gridVisible cmds.grid(toggle=gridVisible)
import maya.cmds as cmds # Enables polygon borders and sets the edge width to 4 # cmds.polyOptions(np=True, db=True, sb=4) # Sets Undo amount to infinite # cmds.undoInfo(infinity=True) # Makes the viewcube visible # cmds.viewManip(visible=True) cmds.optionVar(iv=('viewCubeShowCube', 1)) # Sets the Z axis to be up # cmds.upAxis(ax='z', rv=True) # Sets the near and far clip for the persp view camera # cmds.setAttr('perspShape.nearClipPlane', 1) cmds.setAttr('perspShape.farClipPlane', 100000) # Sets the near and far clip for the top view camera # cmds.setAttr('topShape.nearClipPlane', 1) cmds.setAttr('topShape.farClipPlane', 100000) # Sets the near and far clip for the front view camera # cmds.setAttr('frontShape.nearClipPlane', 1) cmds.setAttr('frontShape.farClipPlane', 100000) # Sets the near and far clip for the side view camera # cmds.setAttr('sideShape.nearClipPlane', 1) cmds.setAttr('sideShape.farClipPlane', 100000) # To change the grid spacing and subdivisions # cmds.grid(spacing=16, d=1) # To change the grid length and width # cmds.grid(size=512) # Turns off the What's New Highlight Settings window at startup cmds.whatsNewHighlight(showStartupDialog=False) # Sets the view back to default. The same as if you were to hit the home button on the viewcube cmds.viewSet('persp', animate=True, home=True)
def run(max_Iteration, size): """ Generates a visualization of a region of the Apollonean Gasket by printing spheres in space in Maya Parameters: max_Iteration - maximum number of cubes to print size - the size of our printing canvas """ # Initialize scene cmds.file(new=True, force=True) cmds.lookThru('top') cmds.grid(toggle=False) # Setup window for progress bar window = cmds.window() cmds.columnLayout() progressControl = cmds.progressBar(maxValue=max_Iteration, width=300) cmds.showWindow(window) # Initialize fractal variables s = math.sqrt(3.0) def f(z): return 3.0 / (1.0 + s - z) - (1.0 + s) / (2.0 + s) ifs = [ "f(z)", "f(z) * complex(-1.0, s) / 2.0", "f(z) * complex(-1.0, -s) / 2.0" ] xa = -0.6 xb = 0.9 ya = -0.75 yb = 0.75 z = complex(0.0, 0.0) # Create shader to paint spheres with shader = cmds.shadingNode("blinn", asShader=True, name="shader" + str(1)) attr = shader + ".color" cmds.setAttr(attr, 1, 1, 1) # Draw max_Iteration number of spheres for i in range(max_Iteration): # Compute z and kx, ky z = eval(ifs[random.randint(0, 2)]) kx = int((z.real - xa) / (xb - xa) * (size - 1)) ky = int((z.imag - ya) / (yb - ya) * (size - 1)) # Update progress bar cmds.progressBar(progressControl, edit=True, step=1) # If kx and kz are within our drawing canvas draw sphere: if kx >= 0 and kx < size and ky >= 0 and ky < size: cmds.polySphere(n="sp" + str(i)) cmds.move(kx, 0, ky) cmds.scale(0.5, 0.5, 0.5) cmds.hyperShade(assign="shader" + str(1)) # Update viewport cmds.viewFit('top', all=True) cmds.dolly('top', os=1.5) cmds.refresh() # Update progress bar and viewport cmds.progressBar(progressControl, edit=True, step=1) cmds.refresh() cmds.toggleWindowVisibility(window)
def setGridDivisions(which, units): cmds.grid(divisions=which) cmds.intField('unityMultiplier', edit=True, value=units) cmds.intField('udkMultiplier', edit=True, value=units) cmds.intField('cryengineMultiplier', edit=True, value=units) consolePrint("Grid square size changed to ", units)
def sceneSetup(): cmds.currentUnit(linear="m") cmds.setAttr("perspShape.nearClipPlane", 0.001) cmds.setAttr("perspShape.farClipPlane", 10000) cmds.grid(size=10, spacing=5.0, d=5) cmds.currentUnit(time='ntscf')
__author__ = 'primm' import maya.cmds as cmds maxSize = 2048 divisions = maxSize/4 _spacing = 2048 cmds.grid(size=maxSize, spacing=_spacing, d=divisions)
def run(max_iteration, size, c): """ Generates a visualization of the Mandelbrot set by printing cubes in space in Maya Parameters: max_Iteration - maximum number of cubes to print size - the size of our printing canvas c - complex variable of the formula z = z*z + c, which affects the result """ # Initialize scene cmds.file(new=True, force=True) cmds.lookThru('top') cmds.grid(toggle=False) # Setup window for progress bar window = cmds.window() cmds.columnLayout() progressControl = cmds.progressBar(maxValue=size**2, width=300) cmds.showWindow(window) # Create shades of grey to paint cubes with based on depth for i in range(max_iteration + 1): shader = cmds.shadingNode("blinn", asShader=True, name="shader" + str(i)) attr = shader + ".color" cmds.setAttr(attr, i / float(max_iteration), i / float(max_iteration), i / float(max_iteration)) # Set center of complex plane x_center = c.real y_center = c.imag # Run through the grid of our canvas size (size X size) for i in range(size): for j in range(size): # Re-evaluate c according to current 'pixel' to be drawn c = complex(x_center + 4.0 * float(i - size / 2) / size, y_center + 4.0 * float(j - size / 2) / size) # Initialize z and number of iterations z = 0 + 0j iteration = 0 # While z is within our space boundaries and we have not exceeded our maximum iteration: while (abs(z) <= 2.0 and iteration < max_iteration): z = z**2 + c # Re-evaluate z, based on formula z = z*z + c iteration += 1 # Draw appropriate cube in space cmds.polyCube(n="cube" + str(i) + str(j)) cmds.move(i, 0, j) cmds.hyperShade(assign="shader" + str(iteration)) # Update progress bar and viewport cmds.progressBar(progressControl, edit=True, step=1) cmds.viewFit('top', all=True) cmds.dolly('top', os=1.5) cmds.refresh() # Update progress bar and viewport cmds.progressBar(progressControl, edit=True, step=1) cmds.refresh() cmds.toggleWindowVisibility(window)
def changeGridSettings(set, s, sp, div, ncp, fcp, gac, ghc, gc, trans): cmds.displayColor('gridAxis', gac, c=True, dormant=True) cmds.displayColor('gridHighlight', ghc, c=True, dormant=True) cmds.displayColor('grid', gc, c=True, dormant=True) cmds.setAttr('perspShape.farClipPlane', fcp) cmds.setAttr('perspShape.nearClipPlane', ncp) cmds.setAttr('topShape.farClipPlane', fcp) cmds.setAttr('topShape.nearClipPlane', ncp) cmds.setAttr('sideShape.farClipPlane', fcp) cmds.setAttr('sideShape.nearClipPlane', ncp) cmds.setAttr('frontShape.farClipPlane', fcp) cmds.setAttr('frontShape.nearClipPlane', ncp) cmds.setAttr('top.translateY', trans) cmds.setAttr('front.translateZ', trans) cmds.setAttr('side.translateX', trans) # sets Unity grid settings if set == "unity": # shows unity division text and buttons, hides others cmds.rowColumnLayout('unityDivUnits', edit=True, visible=True) cmds.rowColumnLayout('udkDivUnits', edit=True, visible=False) cmds.rowColumnLayout('cryengineDivUnits', edit=True, visible=False) cmds.rowColumnLayout('unityDivButtons', edit=True, visible=True) cmds.rowColumnLayout('udkDivButtons', edit=True, visible=False) cmds.rowColumnLayout('cryengineDivButtons', edit=True, visible=False) # sets division text default cmds.intField('unityMultiplier', edit=True, value=100) # sets grid, prints to console, sets camera, and sets Maya units to centimeters cmds.grid(size=s, spacing=sp, divisions=div) consolePrint("Unity grid activated", "") mel.eval("viewSet -animate `optionVar -query animateRollViewCompass` -home;") mel.eval('currentUnit -linear "cm";') #sets UDK grid settings elif set == "udk": # shows udk division text and buttons, hides others cmds.rowColumnLayout('unityDivUnits', edit=True, visible=False) cmds.rowColumnLayout('udkDivUnits', edit=True, visible=True) cmds.rowColumnLayout('cryengineDivUnits', edit=True, visible=False) cmds.rowColumnLayout('unityDivButtons', edit=True, visible=False) cmds.rowColumnLayout('udkDivButtons', edit=True, visible=True) cmds.rowColumnLayout('cryengineDivButtons', edit=True, visible=False) # sets division text default cmds.intField('udkMultiplier', edit=True, value=16) # sets grid, prints to console, sets camera, and sets Maya units to centimeters cmds.grid(size=s, spacing=sp, divisions=div) consolePrint("UDK grid activated", "") mel.eval("viewSet -animate `optionVar -query animateRollViewCompass` -home;") mel.eval('currentUnit -linear "cm";') #sets CryEngine grid settings elif set == "cryengine": # shows cryengine division text and buttons, hides others cmds.rowColumnLayout('unityDivUnits', edit=True, visible=False) cmds.rowColumnLayout('udkDivUnits', edit=True, visible=False) cmds.rowColumnLayout('cryengineDivUnits', edit=True, visible=True) cmds.rowColumnLayout('unityDivButtons', edit=True, visible=False) cmds.rowColumnLayout('udkDivButtons', edit=True, visible=False) cmds.rowColumnLayout('cryengineDivButtons', edit=True, visible=True) # sets division text default cmds.intField('cryengineMultiplier', edit=True, value=100) # sets grid, prints to console, sets camera, and sets Maya units to centimeters cmds.grid(size=s, spacing=sp, divisions=div) consolePrint("CryEngine grid activated", "") mel.eval("viewSet -animate `optionVar -query animateRollViewCompass` -home;") mel.eval('currentUnit -linear "cm";') #restores Maya grid settings elif set == "maya": # hides all division text and buttons cmds.rowColumnLayout('unityDivUnits', edit=True, visible=False) cmds.rowColumnLayout('udkDivUnits', edit=True, visible=False) cmds.rowColumnLayout('cryengineDivUnits', edit=True, visible=False) cmds.rowColumnLayout('unityDivButtons', edit=True, visible=False) cmds.rowColumnLayout('udkDivButtons', edit=True, visible=False) cmds.rowColumnLayout('cryengineDivButtons', edit=True, visible=False) # sets grid, prints to console, sets camera, and sets Maya units to centimeters cmds.grid(size=s, spacing=sp, divisions=div) consolePrint("Maya grid restored", "") mel.eval("viewSet -animate `optionVar -query animateRollViewCompass` -home;") mel.eval('currentUnit -linear "cm";')
def playblast(filename="C:/Users/jhwan/Desktop/test1.avi", stName='amoogae'): basedir = os.path.dirname(os.path.realpath(__file__)) imagePlaneFile = os.path.join(basedir, 'logo.png') #check existing huds allHuds = cmds.headsUpDisplay(lh=True) allHudInfo = {} for hud in allHuds: hudInfo = {} if cmds.headsUpDisplay(hud, visible=True, q=True): if not cmds.headsUpDisplay(hud, preset=True, q=True) == 'noPreset': hudInfo['section'] = cmds.headsUpDisplay(hud, section=True, q=True) hudInfo['block'] = cmds.headsUpDisplay(hud, block=True, q=True) hudInfo['preset'] = cmds.headsUpDisplay(hud, preset=True, q=True) allHudInfo[hud] = hudInfo #remove existing hudes for hud in allHuds: cmds.headsUpDisplay(hud, rem=True) try: cmds.headsUpDisplay('HUDFrame', section=8, block=0, blockAlignment='center', dataWidth=40, preset='currentFrame') except: pass try: cmds.headsUpDisplay('HUDFocalLength', section=6, block=0, blockAlignment='center', dataWidth=40, preset='focalLength') except: pass try: cmds.headsUpDisplay('HUDStudentName', section=7, block=0, blockAlignment='center', dataWidth=40, label=stName) except: pass # adding logo currentCam = cmds.lookThru(q=True) imgPlane = cmds.imagePlane(camera=currentCam, fileName=imagePlaneFile) # check for grid isGridOn = False if cmds.grid(toggle=True, q=True): cmds.grid(toggle=False) isGridOn = True cmds.playblast(filename=filename, format='avi', sequenceTime=0, clearCache=1, viewer=1, showOrnaments=1, fp=4, percent=100, compression="MS-CRAM", quality=100, widthHeight=(1280, 720)) # back to original if cmds.headsUpDisplay('HUDFrame', exists=True): cmds.headsUpDisplay('HUDFrame', remove=True) if cmds.headsUpDisplay('HUDFocalLength', exists=True): cmds.headsUpDisplay('HUDFocalLength', remove=True) if cmds.headsUpDisplay('HUDStudentName', exists=True): cmds.headsUpDisplay('HUDStudentName', remove=True) #delete logo cmds.delete(imgPlane) if isGridOn: cmds.grid(toggle=True) import pprint pprint.pprint(allHudInfo) #recover huds for hud in allHudInfo.keys(): try: cmds.headsUpDisplay(hud, section=allHudInfo[hud]['section'], block=allHudInfo[hud]['block'], blockAlignment='center', preset=allHudInfo[hud]['preset']) except: cmds.headsUpDisplay(hud, section=allHudInfo[hud]['section'], block=allHudInfo[hud]['block'], blockAlignment='center')
def __init__(self): base.currentUnit(linear='meter') base.grid(size=12, spacing=5, divisions=5) print os.path.dirname(os.path.realpath(__file__)) self.BuildUI()
def snapshot(outputPath, width=400, height=None, hud=False, grid=False, camera=None): if height is None: height = width outputExt = os.path.splitext(outputPath)[1].lower().lstrip('.') formatNum = KNOWN_FORMATS.get(outputExt) if formatNum is None: raise ValueError( "input image had unrecognized extension: {}".format(outputExt)) # if given relative path, make it relative to current dir (the test # temp base), rather than the workspace dir outputPath = os.path.abspath(outputPath) # save the old output image format oldFormat = cmds.getAttr("defaultRenderGlobals.imageFormat") # save the hud setting oldHud = cmds.headsUpDisplay(q=1, layoutVisibility=1) # save the grid setting oldGrid = cmds.grid(q=1, toggle=1) # save the old view transform oldColorTransform = cmds.colorManagementPrefs(q=1, outputTarget="playblast", outputTransformName=1) # Some environments use legacy synColor transforms with 2022 and above. # Find whether the color config should be Raw or Raw legacy # However depending on the MAYA_COLOR_MANAGEMENT_SYNCOLOR env var or the loaded # configs, this may be under a different names. So procedurally find it. colorTransforms = cmds.colorManagementPrefs(q=1, outputTransformNames=True) if "Raw" in colorTransforms: newColorTransform = "Raw" elif "Raw (legacy)" in colorTransforms: newColorTransform = "Raw (legacy)" else: # RAW should be reliably raw-like in most configs, so find the first ending in RAW newColorTransform = [ c for c in colorTransforms if c.startswith("Raw ") ] if newColorTransform: newColorTransform = newColorTransform[0] else: raise RuntimeError( "Could not find Raw color space in available color transforms") # Some environments have locked color policies that prevent changing color policies # so we must disable and restore this accordingly. lockedColorTransforms = os.environ.get( "MAYA_COLOR_MANAGEMENT_POLICY_LOCK") == '1' if lockedColorTransforms: os.environ['MAYA_COLOR_MANAGEMENT_POLICY_LOCK'] = '0' # Find the current model panel for playblasting # to make sure the desired camera is set, if any panel = mayaUtils.activeModelPanel() oldCamera = cmds.modelPanel(panel, q=True, cam=True) if camera: cmds.modelEditor(panel, edit=True, camera=camera) # do these in a separate try/finally from color management, because # color management seems a bit more finicky cmds.setAttr("defaultRenderGlobals.imageFormat", formatNum) cmds.headsUpDisplay(layoutVisibility=hud) cmds.grid(toggle=grid) try: cmds.colorManagementPrefs(e=1, outputTarget="playblast", outputTransformName=newColorTransform) try: cmds.playblast(cf=outputPath, viewer=False, format="image", frame=cmds.currentTime(q=1), offScreen=1, widthHeight=(width, height), percent=100) finally: cmds.colorManagementPrefs(e=1, outputTarget="playblast", outputTransformName=oldColorTransform) finally: cmds.setAttr("defaultRenderGlobals.imageFormat", oldFormat) cmds.headsUpDisplay(layoutVisibility=oldHud) cmds.grid(toggle=oldGrid) if lockedColorTransforms: os.environ['MAYA_COLOR_MANAGEMENT_POLICY_LOCK'] = '1' if camera: cmds.lookThru(panel, oldCamera)
def toggle_grid(value, *args, **kwargs): return cmds.grid(toggle=value)
def do(): mc.currentUnit(l='m') mc.grid(s=10, d=1, sp=1)
#Assignment2.py import maya.cmds as cmds import random #set the grid cmds.grid(s=40) #set the random seed random.seed(1024) #H2O O = cmds.polySphere(r=1, n='O', ax = [0,0,0]); H1 = cmds.polySphere(r=0.8, n='H1', ax=[0,0,0]); H2 = cmds.polySphere(r=0.8, n='H2', ax=[0,0,0]); cmds.move(0.0,0.0,1,H1, r=True) cmds.move(0.0,0.0,-1,H2, r=True) cmds.xform(H1, piv=[0,0,0], ws=True) cmds.xform(H2, piv=[0,0,0], ws=True) cmds.rotate(0,'60',0, H1); #group O, H1, H2 as a water molecule H2O = cmds.group( empty=True, name='H2O' ) cmds.parent(H1,H2,O,H2O) cmds.addAttr(longName="expansion", shortName="exp", attributeType='double', min=0, max=100, defaultValue=100, keyable=True) #set the move along center of each two atoms locatorGrpName=cmds.group(empty=True, name='expansion_locator_grp#') cords=cmds.getAttr('H1.translate')[0] locatorName=cmds.spaceLocator(position=cords, name='H1_loc')[0] cmds.xform( locatorName, centerPivots=True)
#Mike Marra #Intial Maya Setup for UDK Script #Sets up the preferences commonly used in Maya for working with UDK import maya.cmds as cmds # Enables polygon borders and sets the edge width to 4 # cmds.polyOptions(np=True, db=True, sb=4) # Sets Undo amount to infinite # cmds.undoInfo(infinity=True) # Makes the viewcube visible # cmds.viewManip(visible=True) cmds.optionVar(iv=('viewCubeShowCube', 1)) # Sets the Z axis to be up # cmds.upAxis(ax='z', rv=True) # Sets the near and far clip for the persp view camera # cmds.setAttr('perspShape.nearClipPlane', 1) cmds.setAttr('perspShape.farClipPlane', 100000) # Sets the near and far clip for the top view camera # cmds.setAttr('topShape.nearClipPlane', 1) cmds.setAttr('topShape.farClipPlane', 100000) # Sets the near and far clip for the front view camera # cmds.setAttr('frontShape.nearClipPlane', 1) cmds.setAttr('frontShape.farClipPlane', 100000) # Sets the near and far clip for the side view camera # cmds.setAttr('sideShape.nearClipPlane', 1) cmds.setAttr('sideShape.farClipPlane', 100000) # To change the grid spacing and subdivisions # cmds.grid(spacing=16, d=1) # To change the grid length and width # cmds.grid(size=512)
def hideGrid(): global gridVisible gridVisible = cmds.optionVar(q="showGrid") cmds.grid(toggle=0)
def changeGridSettings(set, s, sp, div, ncp, fcp, gac, ghc, gc, trans): cmds.displayColor('gridAxis', gac, c=True, dormant=True) cmds.displayColor('gridHighlight', ghc, c=True, dormant=True) cmds.displayColor('grid', gc, c=True, dormant=True) cmds.setAttr('perspShape.farClipPlane', fcp) cmds.setAttr('perspShape.nearClipPlane', ncp) cmds.setAttr('topShape.farClipPlane', fcp) cmds.setAttr('topShape.nearClipPlane', ncp) cmds.setAttr('sideShape.farClipPlane', fcp) cmds.setAttr('sideShape.nearClipPlane', ncp) cmds.setAttr('frontShape.farClipPlane', fcp) cmds.setAttr('frontShape.nearClipPlane', ncp) cmds.setAttr('top.translateY', trans) cmds.setAttr('front.translateZ', trans) cmds.setAttr('side.translateX', trans) # sets Unity grid settings if set == "unity": # shows unity division text and buttons, hides others cmds.rowColumnLayout('unityDivUnits', edit=True, visible=True) cmds.rowColumnLayout('udkDivUnits', edit=True, visible=False) cmds.rowColumnLayout('cryengineDivUnits', edit=True, visible=False) cmds.rowColumnLayout('unityDivButtons', edit=True, visible=True) cmds.rowColumnLayout('udkDivButtons', edit=True, visible=False) cmds.rowColumnLayout('cryengineDivButtons', edit=True, visible=False) # sets division text default cmds.intField('unityMultiplier', edit=True, value=100) # sets grid, prints to console, sets camera, and sets Maya units to centimeters cmds.grid(size=s, spacing=sp, divisions=div) consolePrint("Unity grid activated", "") mel.eval( "viewSet -animate `optionVar -query animateRollViewCompass` -home;" ) mel.eval('currentUnit -linear "cm";') #sets UDK grid settings elif set == "udk": # shows udk division text and buttons, hides others cmds.rowColumnLayout('unityDivUnits', edit=True, visible=False) cmds.rowColumnLayout('udkDivUnits', edit=True, visible=True) cmds.rowColumnLayout('cryengineDivUnits', edit=True, visible=False) cmds.rowColumnLayout('unityDivButtons', edit=True, visible=False) cmds.rowColumnLayout('udkDivButtons', edit=True, visible=True) cmds.rowColumnLayout('cryengineDivButtons', edit=True, visible=False) # sets division text default cmds.intField('udkMultiplier', edit=True, value=16) # sets grid, prints to console, sets camera, and sets Maya units to centimeters cmds.grid(size=s, spacing=sp, divisions=div) consolePrint("UDK grid activated", "") mel.eval( "viewSet -animate `optionVar -query animateRollViewCompass` -home;" ) mel.eval('currentUnit -linear "cm";') #sets CryEngine grid settings elif set == "cryengine": # shows cryengine division text and buttons, hides others cmds.rowColumnLayout('unityDivUnits', edit=True, visible=False) cmds.rowColumnLayout('udkDivUnits', edit=True, visible=False) cmds.rowColumnLayout('cryengineDivUnits', edit=True, visible=True) cmds.rowColumnLayout('unityDivButtons', edit=True, visible=False) cmds.rowColumnLayout('udkDivButtons', edit=True, visible=False) cmds.rowColumnLayout('cryengineDivButtons', edit=True, visible=True) # sets division text default cmds.intField('cryengineMultiplier', edit=True, value=100) # sets grid, prints to console, sets camera, and sets Maya units to centimeters cmds.grid(size=s, spacing=sp, divisions=div) consolePrint("CryEngine grid activated", "") mel.eval( "viewSet -animate `optionVar -query animateRollViewCompass` -home;" ) mel.eval('currentUnit -linear "cm";') #restores Maya grid settings elif set == "maya": # hides all division text and buttons cmds.rowColumnLayout('unityDivUnits', edit=True, visible=False) cmds.rowColumnLayout('udkDivUnits', edit=True, visible=False) cmds.rowColumnLayout('cryengineDivUnits', edit=True, visible=False) cmds.rowColumnLayout('unityDivButtons', edit=True, visible=False) cmds.rowColumnLayout('udkDivButtons', edit=True, visible=False) cmds.rowColumnLayout('cryengineDivButtons', edit=True, visible=False) # sets grid, prints to console, sets camera, and sets Maya units to centimeters cmds.grid(size=s, spacing=sp, divisions=div) consolePrint("Maya grid restored", "") mel.eval( "viewSet -animate `optionVar -query animateRollViewCompass` -home;" ) mel.eval('currentUnit -linear "cm";')
def sceneSetup(): cmds.currentUnit(linear="m") cmds.setAttr("perspShape.nearClipPlane", 0.001) cmds.setAttr("perspShape.farClipPlane", 10000) cmds.grid(size=10, spacing=5.0, d=5) cmds.currentUnit( time='ntscf' )
def run(max_iteration, size, c): """ Generates a visualization of the Julia set by printing cubes in space in Maya Parameters: max_Iteration - maximum number of cubes to print size - the size of our printing canvas c - constant complex variable of the formula z = z*z + c, which affects the result """ # Initialize scene cmds.file(new=True, force=True) cmds.lookThru('top') cmds.grid(toggle=False) # Setup window for progress bar window = cmds.window() cmds.columnLayout() progressControl = cmds.progressBar(maxValue=size**2, width=300) cmds.showWindow(window) # Create shades of grey to paint cubes with based on depth for i in range(max_iteration + 1): shader = cmds.shadingNode("blinn", asShader=True, name="shader" + str(i)) attr = shader + ".color" cmds.setAttr(attr, i / float(max_iteration), i / float(max_iteration), i / float(max_iteration)) # Specify real and imaginary range of image re_min, re_max = -2.0, 2.0 im_min, im_max = -2.0, 2.0 scX = (abs(re_min) + abs(re_max)) / size scZ = (abs(im_min) + abs(im_max)) / size # Generate evenly spaced values over real and imaginary ranges real_range = numpy.arange(re_min, re_max, (re_max - re_min) / size) imag_range = numpy.arange(im_max, im_min, (im_min - im_max) / size) # Run through the grid of our canvas size (size X size) for im in imag_range: for re in real_range: # Initialize z (according to complex plane) and number of iterations z = complex(re, im) iteration = 0 # While z is within our space boundaries and we have not exceeded our maximum iteration: while abs(z) < 10 and iteration < max_iteration: z = z * z + c iteration += 1 # Draw appropriate cube in space cmds.polyCube(n="cube" + str(im) + str(re)) cmds.move(im, 0, re) cmds.scale(scX, 0.1, scZ) cmds.hyperShade(assign="shader" + str(iteration)) # Update progress bar and viewport cmds.progressBar(progressControl, edit=True, step=1) cmds.viewFit('top', all=True) cmds.dolly('top', os=1.5) cmds.refresh() # Update progress bar and viewport cmds.progressBar(progressControl, edit=True, step=1) cmds.refresh() cmds.toggleWindowVisibility(window)
def run(max_Iteration, size): """ Generates a visualization of the Barnsley Fern by printing spheres in space in Maya Parameters: max_Iteration - maximum number of cubes to print size - the size of our printing canvas """ # Initialize scene cmds.file(new = True, force = True) cmds.lookThru( 'top' ) cmds.grid(toggle=False) # Setup window for progress bar window = cmds.window() cmds.columnLayout() progressControl = cmds.progressBar(maxValue=max_Iteration, width=300) cmds.showWindow(window) # Create shader to paint spheres with shader=cmds.shadingNode("blinn",asShader=True, name = "shader" + str(1)) attr = shader + ".color" cmds.setAttr (attr, 1,1,1) # Setup matrix A containing appropriate affine transformations A=[] mat=[[0.0,0.0,0.0,0.16,0.0,0.0,0.01], [0.85,0.04,-0.04,0.85,0.0,1.6,0.85], [0.2,-0.26,0.23,0.22,0.0,1.6,0.07], [-0.15,0.28,0.26,0.24,0.0,0.44,0.07]] # Set starting point (x,y) = (0,0) x=0.0 y=0.0 # Draw max_Iteration number of spheres for iteration in range(max_Iteration): # Select random transformation to compute p=random.random() if p <= mat[0][6]: i=0 elif p <= mat[0][6] + mat[1][6]: i=1 elif p <= mat[0][6] + mat[1][6] + mat[2][6]: i=2 else: i=3 # Compute above transformation: x0 = x * mat[i][0] + y * mat[i][1] + mat[i][4] y = x * mat[i][2] + y * mat[i][3] + mat[i][5] x = x0 # Draw corresponding sphere in space cmds.polySphere(n="sp"+str(iteration)) cmds.move(size*x,0,-size*y) cmds.scale(0.5,0.5,0.5) cmds.hyperShade(assign="shader"+str(1)) # Update progress bar and viewport cmds.progressBar(progressControl, edit=True, step=1) cmds.viewFit( 'top', all=True ) cmds.dolly( 'top', os=1.5 ) cmds.refresh() # Update progress bar and viewport cmds.progressBar(progressControl, edit=True, step=1) cmds.refresh() cmds.toggleWindowVisibility(window)
def main(): cmds.currentUnit(l='cm') cmds.currentUnit(t='ntsc') cmds.upAxis(ax='z') cmds.grid(reset=True) cmds.grid(s=500, d=4, sp=100, dab=True, ddl=True, dpl=True)
def grid(*args, **kwargs): res = cmds.grid(*args, **kwargs) if not kwargs.get('query', kwargs.get('q', False)): res = _factories.maybeConvert(res, _general.PyNode) return res
def run(max_Iteration, size): """ Generates a visualization of the Sierpinski triangle by printing cubes in space in Maya Parameters: max_Iteration - maximum number of cubes to print size - the size of our printing canvas """ # Initialize scene cmds.file(new=True, force=True) cmds.lookThru('top') cmds.grid(toggle=False) # Setup window for progress bar window = cmds.window() cmds.columnLayout() progressControl = cmds.progressBar(maxValue=max_Iteration, width=300) cmds.showWindow(window) # Create shader to paint spheres with shader = cmds.shadingNode("blinn", asShader=True, name="shader" + str(1)) attr = shader + ".color" cmds.setAttr(attr, 1, 1, 1) # Calculates the midpoint of point1 and point2 and returns result def midpoint(point1, point2): return [(point1[0] + point2[0]) / 2, (point1[1] + point2[1]) / 2] # Set starting point for Sierpinski algorithm curr_point = [0, 0] # Define an equilateral triangle in space v1 = [0, 0] v2 = [1, 0] v3 = [.5, np.sqrt(3) / 2] # Draw max_Iteration number of spheres for i in range(max_Iteration): val = randint(0, 2) # Select random vertex of our equilateral triangle # Calculate midpoint of above vertex and our current point: if val == 0: curr_point = midpoint(curr_point, v1) if val == 1: curr_point = midpoint(curr_point, v2) if val == 2: curr_point = midpoint(curr_point, v3) # Draw corresponding sphere in space cmds.polySphere(n="sp" + str(i)) cmds.move(size * curr_point[0], 0, size * curr_point[1]) cmds.scale(0.5, 0.5, 0.5) cmds.hyperShade(assign="shader" + str(1)) # Update progress bar and viewport cmds.progressBar(progressControl, edit=True, step=1) cmds.viewFit('top', all=True) cmds.dolly('top', os=1.5) cmds.refresh() # Update progress bar and viewport cmds.progressBar(progressControl, edit=True, step=1) cmds.refresh() cmds.toggleWindowVisibility(window)
def SAVEPOSE(listPoseWidget, home): poseSettings = "" pathContainer = "" customFile = py.file(home + "CUSTOM.json", q=1, ex=1) if (customFile == 1): with open(home + 'CUSTOM.json', 'r') as f: line = json.load(f) primaryColor = [] secondaryColor = [] secondaryFont = "smallFixedWidthFont" i = 0 while (i < 3): primaryColor.append(float(line['PRIMARY UI COLOR'].split(",")[i])) secondaryColor.append(float(line['SECONDARY UI COLOR'].split(",")[i])) i += 1 ############################################################################### # DETERMINES THE VALIDITY OF THE PREVIOUSLY SELECTED # ############################################################################### rigControllers = [] selections = py.ls(sl=1) i = 0 while (i < len(selections)): RiGGiE = py.listAttr(selections[i], st=["RiGGiE"], r=1) WiGGiE = py.listAttr(selections[i], st=["WiGGiE"], r=1) if (isinstance(RiGGiE, list) == 1 or isinstance(WiGGiE, list) == 1): rigControllers.append(selections[i]) i += 1 if (rigControllers != []): nameSpace = "" if (":" in rigControllers[0]): name = rigControllers[0].split(":")[-1] nameSpace = rigControllers[0][0:(len(rigControllers[0]) - len(name))] else: name = rigControllers[0] ############################################################################### # FIND ALL CONTROLLERS IN FIRST SELECTION # ############################################################################### outputControllers = [] masterCenter = name.replace("_L_", "_M_").replace("_R_", "_M_") masterName = masterCenter.replace( masterCenter.split("_")[2], "master") masterController = nameSpace + masterName.replace( masterName.split("_")[-1], "CTRL") outputItems = py.listRelatives(masterController, ad=1, pa=1) outputControllerShapes = [s for s in outputItems if "CTRL" in s] outputShapes = [s for s in outputItems if "Shape" in s] outputItems = list(set(outputControllerShapes) - set(outputShapes)) i = 0 while (i < len(outputItems)): RiGGiE = py.listAttr(outputItems[i], st=["RiGGiE"], r=1) WiGGiE = py.listAttr(outputItems[i], st=["WiGGiE"], r=1) if (isinstance(RiGGiE, list) == 1 or isinstance(WiGGiE, list) == 1): outputControllers.append(outputItems[i]) i += 1 outputControllers.insert(0, masterController) ############################################################################### # GATHER CONTROLLERS AND THEIR ATTRIBUTES AND VALUES THEN STORE IN STRING # ############################################################################### dialog = py.promptDialog(t="Pose Name", m="What kind of pose is this?", b=["OK", "CANCEL"], db="OK", cb="CANCEL", ds="OK") poseName = py.promptDialog(text=1, q=1) try: poseName.decode('ascii') except: poseName = "?" if (dialog != "CANCEL" and len(poseName) > 0 and "?" not in poseName and "/" not in poseName): poseName = poseName.replace("_POSE", "") i = 0 while (i < len(outputControllers)): controller = outputControllers[i][len(nameSpace):] poseSettings = poseSettings + controller + "--" attribute = py.listAttr(outputControllers[i], k=1) rotationOrder = py.listAttr(outputControllers[i], st=["ROTATE_ORDER"], r=1) if (isinstance(rotationOrder, list) == 1 and isinstance(attribute, list) == 1): attribute.append("ROTATE_ORDER") if (isinstance(attribute, list) == 1): ii = 0 while (ii < len(attribute)): poseSettings = poseSettings + attribute[ii] + "=" value = py.getAttr(outputControllers[i] + "." + attribute[ii]) poseSettings = poseSettings + str(value) + "," ii += 1 poseSettings = poseSettings + "\r\n" i += 1 #DETERMINE LOCAL OR GLOBAL PATH FOR POSE TO BE SAVED TO globalPosePath = "R:/Jx4/tools/dcc/maya/scripts/poseLibrary/" localPosePath = line['POSE (PATH)'] if (os.path.isdir(globalPosePath) == 1 and line['LOCAL POSE'] == 0 and line['GLOBAL POSE'] == 1): dialogPassword = py.promptDialog(t="Save Global Pose", m="What is the password?", b=["OK", "CANCEL"], db="OK", cb="CANCEL", ds="OK") passwordAttempt = py.promptDialog(text=1, q=1) try: passwordAttempt.decode('ascii') except: passwordAttempt = "?" if (dialogPassword != "CANCEL" and passwordAttempt.lower() == "kendrick"): posePath = globalPosePath else: posePath = localPosePath else: posePath = localPosePath if (line['LOCAL POSE'] == 1 or (line['GLOBAL POSE'] == 1 and posePath == globalPosePath)): if (localPosePath != globalPosePath): input = open(posePath + "p_" + poseName + "_POSE.txt", "w+") outline = input.writelines(poseSettings) input.close() else: posePath = "none" print '"Please check the LOCAL PATH (or GLOBAL PATH) on." - HiGGiE' py.headsUpMessage( '"Please check the LOCAL PATH (or GLOBAL PATH) on." - HiGGiE', t=2) if (localPosePath == globalPosePath): posePath = "none" print '"LOCAL PATH cannot be the same as the GLOBAL PATH!" - HiGGiE' py.headsUpMessage( '"LOCAL PATH cannot be the same as the GLOBAL PATH!" - HiGGiE', t=2) ############################################################################### # UPDATE UI WITH NEW LIST # ############################################################################### if (posePath != "none"): globalTextFiles = [] localTextFiles = [] if (os.path.isdir(globalPosePath) == 1 and line['GLOBAL POSE'] == 1): globalTextFiles = glob.glob(globalPosePath + "*_POSE.txt") if (os.path.isdir(localPosePath) == 1 and line['LOCAL POSE'] == 1): localTextFiles = glob.glob(localPosePath + "*_POSE.txt") textFiles = globalTextFiles + localTextFiles i = 0 while (i < len(textFiles)): pathContainer = pathContainer + textFiles[i].replace( "\\", "/") pathContainer = pathContainer + "," i += 1 os.remove(home + "CUSTOM.json") line['POSE FILES (FULL NAME)'] = pathContainer presets = line with open(home + 'CUSTOM.json', 'w+') as f: json.dump(presets, f, sort_keys=False, indent=4) #TAKE SCREEN CAP ToggleViewAxis() mel.eval("setCameraNamesVisibility(0);") gridStatus = 0 if (py.grid(tgl=1, q=1) == 1) else 1 py.grid(tgl=gridStatus) currentCamera = py.lookThru(q=1) translations = list(py.getAttr(currentCamera + ".t")[0]) centerOfInterest = py.getAttr(currentCamera + ".centerOfInterest") py.setAttr(currentCamera + "Shape.cameraScale", 1) FrameSelected() py.setAttr(currentCamera + "Shape.cameraScale", 0.25) thumbnailFormat = py.getAttr( "defaultRenderGlobals.imageFormat") py.setAttr("defaultRenderGlobals.imageFormat", 32) currentFrame = py.currentTime(q=1) #START: APPLY BACKGROUND COLOR scaleValue = 10000 shader = py.shadingNode("blinn", asShader=1) shaderGRP = py.sets(renderable=1, noSurfaceShader=1, empty=1) py.connectAttr('%s.outColor' % shader, '%s.surfaceShader' % shaderGRP) background = py.polyCube()[0] py.hyperShade(assign=shader) py.polyNormal(background, normalMode=0, userNormalMode=0, ch=1) py.parentConstraint(selections, background, mo=0, w=1) py.setAttr(background + ".s", scaleValue, scaleValue, scaleValue) if (posePath == localPosePath): py.setAttr(shader + ".incandescence", 0.0771, 0.2296, 0.2901, type="double3") else: py.setAttr(shader + ".incandescence", 0.4318, 0.2022, 0.2022, type="double3") py.setAttr(shader + ".color", 0, 0, 0, type="double3") py.setAttr(shader + ".eccentricity", 0) py.select(selections, r=1) #END: APPLY BACKGROUND COLOR py.playblast(frame=currentFrame, format="image", cf=posePath + "p_" + poseName + "_POSE.png", wh=[100, 200], p=100, v=0) py.delete(background, shader) py.setAttr("defaultRenderGlobals.imageFormat", thumbnailFormat) py.setAttr(currentCamera + "Shape.cameraScale", 1) py.setAttr(currentCamera + "Shape.centerOfInterest", centerOfInterest) py.setAttr(currentCamera + ".t", translations[0], translations[1], translations[2]) gridStatus = 0 if (py.grid(tgl=1, q=1) == 1) else 1 py.grid(tgl=gridStatus) ToggleViewAxis() #ADD ITEMS TO GRID thumbnailSize = [100, 180] poseList = line['POSE FILES (FULL NAME)'].split(",") listPoseWidget.clear() i = 0 while (i < len(poseList)): if (len(poseList[i]) > 0 and py.file(poseList[i], q=1, ex=1) == 1): if (py.file(poseList[i].replace(".txt", ".png"), q=1, ex=1) == 1): name = poseList[i].split("/")[-1].split( ".")[0].split("_POSE")[0].replace("p_", "", 1) thumbnailItem = qt.QListWidgetItem(name) thumbnailImage = qt.QIcon() thumbnailImage.addPixmap( qt.QPixmap( _fromUtf8(poseList[i].replace( ".txt", ".png"))), qt.QIcon.Normal, qt.QIcon.Off) thumbnailItem.setIcon(thumbnailImage) listPoseWidget.addItem(thumbnailItem) i += 1 py.headsUpMessage('"Successfully saved your ' + poseName + ' pose to: ' + posePath + '" - HiGGiE', t=3) elif (dialog != "CANCEL" and len(poseName) > 0 and ("?" in poseName or "/" in poseName)): print '"You must type a valid name (English only and no "_")." - HiGGiE' py.headsUpMessage( '"You must type a valid name (English only and no "_")." - HiGGiE', t=10) else: print '"You must select a valid rig controller." - HiGGiE' py.headsUpMessage('"You must select a valid rig controller." - HiGGiE', t=2)
__author__ = 'primm' import maya.cmds as cmds maxSize = 2048 divisions = maxSize / 4 _spacing = 2048 cmds.grid(size=maxSize, spacing=_spacing, d=divisions)