本文整理汇总了Python中maya.cmds.loadPlugin函数的典型用法代码示例。如果您正苦于以下问题:Python loadPlugin函数的具体用法?Python loadPlugin怎么用?Python loadPlugin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了loadPlugin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadPlugins
def loadPlugins():
pluginList = ['redshift4maya.mll', 'Mayatomr.mll']
for plugin in pluginList:
if cmds.pluginInfo( plugin, q=1, l=1 ): continue
try:cmds.loadPlugin( plugin )
except:pass
示例2: enableaPlugin
def enableaPlugin(filename):
extDict = {'win64':'mll','mac':'bundle','linux':'so','linux64':'so'}
os = cmds.about(os=True)
ext = extDict[os]
version = cmds.about(v=True)[:4]
pluginName = 'deltaMushToSkinCluster_%s' % version
fileFullName = '%s.%s' % (pluginName,ext)
rootPath = getParentPath(currentFileDirectory())
pluginsPath = rootPath+'/plug-ins/'
pluginFilePath = pluginsPath+fileFullName
pluginStr = mel.eval('getenv "MAYA_PLUG_IN_PATH";')+';'+pluginsPath
mel.eval('putenv "MAYA_PLUG_IN_PATH" "%s";' % pluginStr)
with open(filename,'a+') as f:
state = True
for line in f.readlines():
if re.findall(fileFullName,line):
state = False
if state:
f.write(r'evalDeferred("autoLoadPlugin(\"\", \"%s\", \"%s\")");' % (fileFullName,pluginName))
if not cmds.pluginInfo( pluginFilePath, query=True, autoload=True):
cmds.pluginInfo( pluginFilePath, edit=True, autoload=True)
if not cmds.pluginInfo(pluginFilePath,query=True,loaded=True):
cmds.loadPlugin(pluginFilePath)
示例3: setTool_hardSkinWeightBrush
def setTool_hardSkinWeightBrush( evt=0 ):
appendPluginPath()
_cmdStr = """global string $tf_skinSmoothPatin_selection[];
global proc tf_smoothBrush( string $context )
{
artUserPaintCtx -e -ic "tf_init_smoothBrush"
-svc "tf_set_smoothBrushValue"
-fc "" -gvc "" -gsc "" -gac "" -tcc "" $context;
}
global proc tf_init_smoothBrush( string $name )
{
string $sel[] = `ls -sl -fl`;
string $obj[] = `ls -sl -o`;
sgSmoothWeightCommand $obj;
}
global proc tf_set_smoothBrushValue( int $slot, int $index, float $val )
{
sgSmoothWeightCommand -h 1 -i $index -w $val;
}
ScriptPaintTool;
artUserPaintCtx -e -tsc "tf_smoothBrush" `currentCtx`;"""
if not cmds.pluginInfo( 'sgSmoothWeightCommand', q=1, l=1 ):
cmds.loadPlugin( 'sgSmoothWeightCommand' )
mel.eval( _cmdStr )
示例4: testExportWithAssemblyAndMesh
def testExportWithAssemblyAndMesh(self):
"""
Tests exporting a Maya file with a root prim containing an assembly
and a mesh.
"""
cmds.file(os.path.abspath('KindTestAssemblyAndMesh.ma'), open=True,
force=True)
cmds.loadPlugin('pxrUsd')
# Should fail due to the mesh.
usdFilePath = os.path.abspath('KindTestAssemblyAndMesh.usda')
with self.assertRaises(RuntimeError):
cmds.usdExport(mergeTransformAndShape=True,
file=usdFilePath,
kind='assembly')
# Should be 'component' because of the mesh
usdFilePath = os.path.abspath('KindTestAssemblyAndMesh.usda')
cmds.usdExport(mergeTransformAndShape=True,
file=usdFilePath)
stage = Usd.Stage.Open(usdFilePath)
self.assertTrue(stage)
rootPrim = stage.GetPrimAtPath('/KindTest')
self.assertTrue(Kind.Registry().IsA(Usd.ModelAPI(rootPrim).GetKind(),
'component'))
示例5: testExportWithKindAttrAndKindFlag
def testExportWithKindAttrAndKindFlag(self):
"""
Tests exporting a Maya file with both USD_kind custom attributes and
using the usdExport -kind flag; there should be an error if the USD_kind
is not derived from the kind specified in the -kind flag.
"""
cmds.file(os.path.abspath('KindTestUsdKindAttr.ma'), open=True, force=True)
cmds.loadPlugin('pxrUsd')
usdFilePath = os.path.abspath('KindTestUsdKindAttr.usda')
with self.assertRaises(RuntimeError):
cmds.usdExport(mergeTransformAndShape=True,
file=usdFilePath,
kind='assembly')
cmds.usdExport(mergeTransformAndShape=True,
file=usdFilePath,
kind='model')
stage = Usd.Stage.Open(usdFilePath)
self.assertTrue(stage)
rootPrim = stage.GetPrimAtPath('/KindTest')
self.assertTrue(Kind.Registry().IsA(Usd.ModelAPI(rootPrim).GetKind(),
'component'))
rootPrim2 = stage.GetPrimAtPath('/KindTest2')
self.assertTrue(Kind.Registry().IsA(Usd.ModelAPI(rootPrim2).GetKind(),
'assembly'))
示例6: setUpClass
def setUpClass(cls):
standalone.initialize('usd')
cmds.loadPlugin('pxrUsd')
usdFile = os.path.abspath('UsdImportColorSetsTest.usda')
cmds.usdImport(file=usdFile, shadingMode='none',
excludePrimvar='ExcludeMe')
示例7: setup_scene
def setup_scene(name=sys.argv[1]):
# imports shirt, scales to fit, converts to ncloth
try:
cmds.loadPlugin("objExport")
except:
pass
mel.eval('file -f -options "mo=1" -ignoreVersion -typ "OBJ" -o "%s";' \
% name)
try:
mel.eval('rename "Mesh" "shirt";')
except:
pass
# scale shirt to fit
create_table()
if (fold_num == 0):
bbx = cmds.xform("shirt", q=True, bb=True, ws=True)
s_x_len = abs(bbx[3] - bbx[0])
s_y_len = abs(bbx[4] - bbx[1])
global GLOBAL_SCALE
if (s_x_len >= s_y_len):
GLOBAL_SCALE = s_x_len/(SHIRT_SCALE * TABLE_SIZE)
else:
GLOBAL_SCALE = s_y_len/(SHIRT_SCALE * TABLE_SIZE)
cmds.select("shirt")
cmds.move(0, 0.0001, 0, relative = True)
cmds.scale(GLOBAL_SCALE, GLOBAL_SCALE, GLOBAL_SCALE, "table", centerPivot = True)
shirt_to_nCloth()
create_camera()
示例8: load_plugins_deferred
def load_plugins_deferred():
#plugin_list
plugin_list = ['vrayformaya.mll',
'rrSubmit_Maya_8.5+.py',
'helga_asset_metadata.py',
'helga_shots_metadata.py',
'AnimSchoolPicker.mll',
'LBrush']
#iterate plugin_list and load
for plugin_name in plugin_list:
try:
if not(cmds.pluginInfo(plugin_name , query = True, loaded = True)):
try:
cmds.loadPlugin(plugin_name)
#Print to console instead of script editor
sys.__stdout__.write('->Successfully loaded ' +plugin_name +' deferred\n')
except:
sys.__stdout__.write('->Error loading ' +plugin_name +' deferred\n')
else:
sys.__stdout__.write('->Skipped loading ' +plugin_name +' deferred. Plugin was already loaded\n')
except:
sys.__stdout__.write('->Error loading ' +plugin_name +' deferred\n')
#Dividerline
sys.__stdout__.write(DIVIDERLINE)
示例9: _gather_exported_alembic_info_
def _gather_exported_alembic_info_():
cmds.loadPlugin("AbcImport.mll", quiet=True)
template_obj, fields, tk = _get_shotgun_fields_from_file_name_()
if not pm.objExists("animatedAlembicGroup"):
pm.createNode("transform", name="animatedAlembicGroup")
temp, fields, tk = _get_shotgun_fields_from_file_name_()
masterAlembicTemplate = tk.templates["master_alembic_cache"]
alembicFolder = libFile.get_parent_folder(masterAlembicTemplate.apply_fields(fields))
# Get all the abc files
exported_alemblic_info = {}
if libFile.exists(alembicFolder):
for alembicFile in libFile.listfiles(alembicFolder, "abc"):
alembicFilePath = libFile.join(alembicFolder, alembicFile)
# Edited by Chet
# Project Kitten Witch 25 May 2016
# ========================================================
# Old code that was causing the list of alembics to build
# niceName = alembicFile.split(".")[0].split("_")[]
niceName = alembicFile.split(".")[0]
niceName = niceName.split("_")
niceName = " ".join(niceName[1:])
exported_alemblic_info[niceName] = alembicFilePath
return exported_alemblic_info
示例10: main
def main(argv = None):
print "Initializing..."
# Load Plugin
cmds.loadPlugin("AbcImport.mll")
# Get current dir
basedir = os.getcwd()
os.chdir(basedir)
# Create new file
cmds.file(basedir + "/" + "null.mb", o=True, force=True)
# Create empty scenes
createNewScenes()
# Load Alembics in every scene
for file in os.listdir("."):
if file.endswith(".mb") and file != "null.mb":
print "Opening " + file
cmds.file(basedir+'/'+file, o=True, force=True)
importAbcInFolder()
cmds.file(save=True)
quit()
示例11: cmdFunction
def cmdFunction(*args):
for pluginName in plugin_names:
cmds.loadPlugin(pluginName)
if ui_mel is not None:
mel.eval(ui_mel)
if ui_python is not None:
ui_python()
示例12: reloadAndReopen
def reloadAndReopen( self, *args ):
codePath = cmds.textField( self.fld_codePath, q=1, tx=1 )
plugPath = cmds.textField( self.fld_plugPath, q=1, tx=1 )
srcName = cmds.textField( self.fld_srcName, q=1, tx=1 )
dstName = cmds.textField( self.fld_dstName, q=1, tx=1 )
srcPath = ( codePath + '/' + srcName ).replace( '\\', '/' )
dstPath = ( plugPath + '/' + dstName ).replace( '\\', '/' )
currentSceneName = cmds.file( q=1, sceneName=1 )
cmds.file( new=1, f=1 )
cmds.unloadPlugin( dstName )
shutil.copy2( srcPath, dstPath )
print "Copy From : ", srcPath
print "Past To : ", dstPath
if not currentSceneName: currentSceneName = tempPluginTestPath
try:cmds.file( currentSceneName, f=1, options="v=0;", o=1 )
except:cmds.file( rename = currentSceneName )
cmds.loadPlugin( dstName )
self.textFieldSaveCommand()
示例13: initializePlugin
def initializePlugin(obj):
plugin = OpenMayaMPx.MFnPlugin(obj)
try:
plugin.registerNode(
ms_environment_nodeTypeName,
ms_environment_nodeTypeId,
ms_environment_nodeCreator,
ms_environment_nodeInitializer,
OpenMayaMPx.MPxNode.kLocatorNode,
)
except:
sys.stderr.write("Failed to register node: %s" % ms_environment_nodeTypeName)
try:
plugin.registerNode(
ms_renderSettings_nodeTypeName,
ms_renderSettings_nodeTypeId,
ms_renderSettings_nodeCreator,
ms_renderSettings_nodeInitializer,
)
except:
sys.stderr.write("Failed to register node: %s\n" % ms_renderSettings_nodeTypeName)
# load objExport plugin if its not loaded yet
try:
if not cmds.pluginInfo("objExport", query=True, loaded=True):
cmds.loadPlugin("objExport")
except:
print "objExport plugin could not be loaded, cannot load mayaseed"
ms_menu.createMenu()
ms_menu.buildMenu()
示例14: exportObjects
def exportObjects(self):
for object in self.objects:
cmds.select(object, r= True)
if self.exportType == 1:
fileType = 'Fbx'
cmds.loadPlugin('fbxmaya', qt= True)
melCmd.eval('FBXExportShowUI -v false;')
else:
fileType = 'OBJexport'
cmds.loadPlugin('objExport', qt= True)
if bool(self.exportGeometrySequence) == bool(True):
startF = self.startFrame
endF = self.endFrame
else:
startF = endF = cmds.currentTime( query=True )
nameExtension = ''
exportName = object.replace(':', '_')
for timevalue in range(startF, (endF+1), 1):
if bool(self.exportGeometrySequence) == bool(True):
nameExtension = '.%04d' % timevalue
cmds.currentTime(timevalue)
if self.exportType == 1:
melCmd.eval('FBXExport -f "' + self.exportPath + exportName + nameExtension + '.fbx" -s')
else:
cmds.file(self.exportPath+exportName+nameExtension, op='', typ=fileType, pr=True, es=True )
print 'Exported: ' + object;
示例15: cameraFrustum_build
def cameraFrustum_build(cam_shape):
#make sure a camera is loaded
if cam_shape==0:
cmds.error('no camera loaded...select a camera and load')
else:
#create frustum only if one doesnt already exist
selCamXform = cmds.listRelatives(cam_shape[0], p=1)
prefix = 'frust_'
frustumGrpName = prefix + 'camera_frustum_all_grp'
if cmds.objExists(frustumGrpName)==0:
#create main grp
frustumMainGrp = cmds.group(em=1, n=frustumGrpName);
cmds.setAttr(frustumGrpName + '.tx', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.ty', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.tz', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.rx', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.ry', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.rz', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.sx', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.sy', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.sz', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.v', lock=1, keyable=0, channelBox=0)
#create frustum geo
frustumGeo = cmds.polyCube(w=2, h=2, d=2, n=prefix + 'camera_frustum_geo')
cmds.delete(frustumGeo[0], constructionHistory=True)
cmds.parent(frustumGeo[0], frustumMainGrp)
#load plugin "nearestPointOnMesh.mll" if needed and connect
plugin = cmds.pluginInfo('nearestPointOnMesh.mll', q=1, l=1)
if plugin==0:
cmds.loadPlugin('nearestPointOnMesh.mll')
nearNodeName = prefix + 'npomNode'
npomNode = cmds.createNode('nearestPointOnMesh', n=nearNodeName)
cmds.connectAttr(frustumGeo[0] + '.worldMesh', npomNode + '.inMesh')
#create clusters
cmds.select(frustumGeo[0] + '.vtx[4:7]', r=1)
nearCluster = cmds.cluster(n=prefix + 'camera_nearFrustum_cluster')
cmds.select(frustumGeo[0] + '.vtx[0:3]', r=1)
farCluster = cmds.cluster(n=prefix + 'camera_farFrustum_cluster')
#create near/far/camera locs
cameraLoc = cmds.spaceLocator(p=(0, 0, 0), n=prefix + 'camera_loc')
cmds.parent(cameraLoc[0], frustumMainGrp)
nearLoc = cmds.spaceLocator(p=(0, 0, 0), n=prefix + 'camera_nearFrustum_loc')
cmds.move(0, 0, -1)
farLoc = cmds.spaceLocator(p=(0, 0, 0), n=prefix + 'camera_farFrustum_loc')
cmds.move(0, 0, 1)
#parent clusters under loc -- parent locs under camera loc
cmds.parent(nearCluster[1], nearLoc[0])
cmds.parent(farCluster[1], farLoc[0])
cmds.parent(nearLoc[0], cameraLoc[0])
cmds.parent(farLoc[0], cameraLoc[0])
#constrain camera loc to camera
cmds.parentConstraint(selCamXform, cameraLoc, weight=1)
return frustumGeo[0]