本文整理汇总了Python中maya.cmds.optionVar函数的典型用法代码示例。如果您正苦于以下问题:Python optionVar函数的具体用法?Python optionVar怎么用?Python optionVar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了optionVar函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: deleteCustomOptions
def deleteCustomOptions():
variablePrefix = "ngSkinTools"
for varName in cmds.optionVar(list=True):
if varName.startswith(variablePrefix):
cmds.optionVar(remove=varName)
cmds.windowPref('MirrorWeightsWindow',ra=True)
示例2: getFileName
def getFileName():
base = studioBase.StudioSQL()
loadType = {'Load saved reference load state':'',
'Load all references':'all',
'Load top-level references only':'topOnly',
'Load no references':'none'}
fileData = mop.OpenDialog.openFile()
if fileData[0] and fileData[1] and fileData[2]:
fileName = fileData[1] + '/' + fileData[2]
else:
return False
ref = loadType[fileData[3]]
selective = fileData[4]
print('filename', fileName, ref, 'selective', selective, fileData)
base.setAction('open', fileName)
if selective:
cmds.file(fileName, open=True, buildLoadSettings=True )
num = cmds.selLoadSettings( q=True, numSettings=True)
cmds.optionVar(sv=('preloadRefEdTopLevelFile', fileName))
mel.eval('PreloadReferenceEditor')
else:
if ref:
cmds.file(fileName, o=True, f=True, lrd=ref)
else:
cmds.file(fileName, o=True, f=True)
setRecentFile(fileName)
return True
示例3: loadPrefs
def loadPrefs(self):
"""Load all preferences and create default ones if they do not exists"""
for label in self.preferences:
if cmds.optionVar(exists='pns_' + label):
self.preferences[label] = cmds.optionVar(query='pns_' + label)
else:
cmds.optionVar(intValue=('pns_' + label, self.preferences[label]))
示例4: load
def load(file_path, obj_name, parent_name):
"""Import a file exported from ZBrush.
This is the command sent over the Maya command port from ZBrush.
Parameters
----------
file_path : str
Path to the file that we are importing
obj_name : str
Name of the object being imported
parent_name : str
Name of the parent for the object being imported
"""
file_name = utils.split_file_name(file_path)
_cleanup(file_name)
cmds.file(file_path, i=True,
usingNamespaces=False,
removeDuplicateNetworks=True)
# Set smoothing options if necessary
if cmds.optionVar(ex='gozbruh_smooth') and not cmds.optionVar(q='gozbruh_smooth'):
cmds.displaySmoothness(obj_name, du=0, dv=0, pw=4, ps=1, po=1)
if not cmds.attributeQuery("gozbruhParent", n=obj_name, ex=True):
cmds.addAttr(obj_name, longName='gozbruhParent', dataType='string')
cmds.setAttr(obj_name + '.gozbruhParent', parent_name, type='string')
示例5: select_file
def select_file(self):
""" Maya Open Dialog to select file texture """
self.open_dialog_visible = True
if MTTSettings.value('browserFirstStart'):
image_dir = cmds.optionVar(query='MTT_browserStartFolder')
else:
image_dir = cmds.workspace(query=True,
rootDirectory=True) + cmds.workspace(
fileRuleEntry='sourceImages')
MTTSettings.set_value('browserFirstStart', True)
file_path = cmds.fileDialog2(fileMode=1, startingDirectory=image_dir,
caption='Select a texture',
okCaption='Select')
if file_path:
new_path = file_path[0]
cmds.optionVar(
sv=['MTT_browserStartFolder', os.path.dirname(new_path)])
if MTTSettings.value('forceRelativePath'):
new_path = convert_to_relative_path(new_path)
# relative_path = workspace(projectPath=new_path)
# if relative_path != new_path:
# new_path = '/%s' % relative_path
self.line_edit.setText(new_path)
self.open_dialog_visible = False
self.close()
self.editingFinished.emit()
cmds.showWindow(WINDOW_NAME)
示例6: hw
def hw(*args, **kwargs):
t0 = float(time.time())
try:
verbose = kwargs["verbose"]
except KeyError:
verbose = False
if cmds.optionVar(exists="checkmateVerbosity"):
verbose = cmds.optionVar(query="checkmateVerbosity")
else:
pass
scenefilename = cmds.file(query=True, sn=True, shn=True)
root, ext = os.path.splitext(scenefilename)
fullscenepath = cmds.file(query=True, sn=True, shn=False)
fullscenedirname = os.path.dirname(fullscenepath)
reportname = "".join([root, ext.replace(".", "_")])
img_dir = os.path.join(fullscenedirname, reportname)
print "save HW rendered images to : %s" % img_dir
# before we render, save render globals presets
cmds.nodePreset(save=("defaultRenderQuality", "ttRestorePreviousDefaultRenderViewPreset"))
cmds.nodePreset(save=("defaultRenderGlobals", "ttRestorePreviousDefaultRenderViewPreset"))
cmds.nodePreset(save=("defaultResolution", "ttRestorePreviousDefaultRenderViewPreset"))
# override the user settings
cmds.setAttr("defaultRenderGlobals.imageFormat", 32)
ext = ".png"
# set resolution ot 320x240
cmds.setAttr("defaultResolution.width", 640)
cmds.setAttr("defaultResolution.height", 480)
cmds.setAttr("defaultResolution.deviceAspectRatio", (float(320) / float(240)))
# set file format to png
cmds.setAttr("defaultRenderGlobals.imageFormat", 32)
ext = ".png"
cmds.setAttr("defaultRenderGlobals.outFormatControl", 0) # default name.ext
cmds.setAttr("defaultRenderGlobals.animation", False)
# cmds.setAttr('defaultRenderGlobals.imageFilePrefix', "../<Camera>", type="string")
cmds.setAttr("defaultRenderGlobals.imageFilePrefix", "<Camera>", type="string")
cmds.workspace(fileRule=["images", img_dir])
print "save rendered images to : %s" % img_dir
cmds.hwRender(currentFrame=True, cam="top", edgeAntiAliasing=[2, 4], fullRenderSupport=True)
cmds.hwRender(currentFrame=True, cam="persp", edgeAntiAliasing=[2, 16], fullRenderSupport=True)
cmds.hwRender(currentFrame=True, cam="front", edgeAntiAliasing=[2, 16], fullRenderSupport=True)
cmds.hwRender(currentFrame=True, cam="side", edgeAntiAliasing=[2, 16], fullRenderSupport=True)
# move rendererd images from the default project images dir to the report dir
sourcedir = os.path.join(cmds.workspace(q=True, rd=True), cmds.workspace(fileRuleEntry="images"))
targetdir = img_dir
print "from : ", sourcedir
print "to : ", targetdir
# for img in ['side.png', 'front.png', 'persp.png', 'top.png'] :
# os.rename(os.path.join(sourcedir, img), os.path.join(targetdir, img))
print "%-24s : %.6f seconds" % ("render.hw()", (float(time.time()) - t0))
return img_dir
示例7: toggleModeState
def toggleModeState(OptionSelection,OptionList,OptionVarName,ListOfContainers,forceInt = False):
"""
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DESCRIPTION:
Toggle for turning off and on the visbility of a list of containers
ARGUMENTS:
optionSelection(string) - this should point to the variable holding a (bool) value
optionList(list) - the option selection must be in the optionList
RETURNS:
locatorName(string)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
"""
visOn = OptionList.index(OptionSelection)
if forceInt:
mc.optionVar(iv=(OptionVarName,int(visOn)))
else:
mc.optionVar(sv=(OptionVarName,OptionSelection))
cnt = 0
for Container in ListOfContainers:
if cnt == visOn:
#Container(e=True,vis=True)
setUIObjectVisibility(Container,True)
else:
#Container(e=True,vis=False)
setUIObjectVisibility(Container,False)
cnt+=1
示例8: override_panels
def override_panels(custom_hs_cmd=None, custom_ne_cmd=None):
# check if icons is in maya resources, if not, copy into userBitmapsDir
user_icons_path = cmds.internalVar(userBitmapsDir=True)
mtt_icons_path = os.path.join(os.path.dirname(__file__), 'icons')
maya_icons = os.listdir(user_icons_path)
for ico in MTT_ICONS_NAME:
if ico not in maya_icons:
source_file = os.path.join(mtt_icons_path, ico)
destination_file = os.path.join(user_icons_path, ico)
shutil.copy2(source_file, destination_file)
# create MEL global proc
cmd = mel.createMelWrapper(
override_add_hypershade_panel, types=['string'], returnCmd=True)
mel.eval(cmd)
cmd = mel.createMelWrapper(
override_add_node_editor_panel, types=['string'], returnCmd=True)
mel.eval(cmd)
# edit callback of scripted panel
cmds.scriptedPanelType(
'hyperShadePanel', edit=True,
addCallback='override_add_hypershade_panel')
cmds.scriptedPanelType(
'nodeEditorPanel', edit=True,
addCallback='override_add_node_editor_panel')
# store custom cmd
if custom_hs_cmd:
cmds.optionVar(sv=[VAR_HS_CMD, custom_hs_cmd])
if custom_ne_cmd:
cmds.optionVar(sv=[VAR_NE_CMD, custom_hs_cmd])
示例9: ui
def ui():
'''Launch the UI
'''
mc.optionVar( sv=('colorManagementColorPickerColorSpaceSelection','Display Space') )
win = ColorControlUI()
win.buildMainLayout()
win.finish()
示例10: create_shelf
def create_shelf():
"""
Create the OBB shelf
Raises:
None
Returns:
None
"""
tab_layout = mel.eval('$pytmp=$gShelfTopLevel')
shelf_exists = cmds.shelfLayout('OBB', exists=True)
if shelf_exists:
cmds.deleteUI('OBB', layout=True)
shelf = cmds.shelfLayout('OBB', parent=tab_layout)
for button, kwargs in buttons.items():
img = QtGui.QImage(kwargs['image'])
kwargs['width'] = img.width()
kwargs['height'] = img.height()
cmds.shelfButton(label=button, parent=shelf, **kwargs)
# Fix object 0 error.
shelves = cmds.shelfTabLayout(tab_layout, query=True, tabLabelIndex=True)
for index, shelf in enumerate(shelves):
cmds.optionVar(stringValue=("shelfName%d" % (index+1), str(shelf)))
示例11: doToggleModeState
def doToggleModeState(OptionSelection,OptionList,OptionVarName,ListOfContainers,forceInt = False):
"""
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DESCRIPTION:
This connects to a cgm rework of tabs in maya gui's. Mainly to be used with a form layout is needed
with tabs. Tabs and form layouts don't work well together. This is a work around
ARGUMENTS:
optionSelection(string) - this should point to the variable holding a (int) value
optionList(list) - the option selection must be in the optionList
OptionVarName(string)
ListOfContainers(list) -- list of containers
forceInt -- forces the optionVar to set
RETURNS:
locatorName(string)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
"""
visOn = OptionList.index(OptionSelection)
if forceInt:
mc.optionVar(iv=(OptionVarName,int(visOn)))
else:
mc.optionVar(sv=(OptionVarName,OptionSelection))
for cnt,Container in enumerate(ListOfContainers):
if cnt == visOn:
Container(e=True,vis=True)
#doToggleMenuShowState(Container,True)
else:
Container(e=True,vis=False)
#doToggleMenuShowState(Container,False)
cnt+=1
示例12: __init__
def __init__( self,*args,**kws):
#Check our tool option var for debug mode to set logger level if so
if mc.optionVar(exists = "cgmVar_guiDebug") and mc.optionVar(q="cgmVar_guiDebug"):
log.setLevel(logging.DEBUG)
self.__toolName__ = __toolName__
self.l_allowedDockAreas = ['right', 'left']
self.WINDOW_NAME = cgmSimpleUI.WINDOW_NAME
self.WINDOW_TITLE = cgmSimpleUI.WINDOW_TITLE
self.DEFAULT_SIZE = cgmSimpleUI.DEFAULT_SIZE
#>>> Standard cgm variables
#====================
#self.initializeTemplates()
#>>> Insert our init, overloaded for other tools
#self.insert_init(*args,**kws)
#>>> Menu
#self.setup_Variables()
#self.build_menus()
#>>> Body
#====================
self.build_layoutWrapper(self)
self.show()
示例13: on_highlightModeChange
def on_highlightModeChange( self, *a ):
highlightMode = cmd.optionVar( q='zooTrigHighlighting' )
cmd.optionVar( iv=('zooTrigHighlighting', not highlightMode) )
if highlightMode:
pass
else:
triggered.Triggered().unhighlightAllTriggers()
示例14: override_add_hypershade_panel
def override_add_hypershade_panel(panel):
# create HyperShade with Maya command
if cmds.optionVar(exists=VAR_HS_CMD):
mel.eval('%s("%s")' % (cmds.optionVar(query=VAR_HS_CMD), panel))
else:
mel.eval('addHyperShadePanel("%s")' % panel)
# set HyperShade toolbar current parent (name is hardcoded in mel files)
cmds.setParent('hyperShadeToolbarForm')
# add custom buttons
cmds.separator(height=ICON_SIZE, horizontal=False, style='single')
cmds.iconTextButton(
image='nodeGrapherAddNodes.png',
width=ICON_SIZE,
height=ICON_SIZE,
command=partial(hypershade_add_node, panel)
)
cmds.iconTextButton(
image='nodeGrapherRemoveNodes.png',
width=ICON_SIZE,
height=ICON_SIZE,
command=partial(hypershade_remove_node, panel)
)
cmds.separator(height=ICON_SIZE, horizontal=False, style='single')
cmds.iconTextButton(
image='MTT_CreateNode.png',
width=ICON_SIZE,
height=ICON_SIZE,
command=create_nodes
)
示例15: setToDefault
def setToDefault(*args):
cmds.optionVar( intValue=('ui_DefaultMode', 1) )
cmds.optionVar( intValue=('ui_selectedTabIndex', 1) )
cmds.optionVar( intValue=('ui_debug', 0) )
cmds.optionVar( intValue=('ui_updateMode', 1) )
cmds.optionVar( intValue=('ui_OptionVar', 1) )