本文整理汇总了Python中pymel.core.objExists函数的典型用法代码示例。如果您正苦于以下问题:Python objExists函数的具体用法?Python objExists怎么用?Python objExists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了objExists函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check
def check(self, *args):
self.log.insertText("Checking Master Node... \n")
if pm.objExists('master'):
master_node = pm.PyNode("master")
else :
self.log.insertText(" Master Node does not exists \n")
return False
attrs = ['objectName',
'arc_file_path',
'arc_file_name',
'arc_asset_name',
'arc_asset_dept',
'arc_asset_version',
'ClientAsset']
status = True
for attr in attrs:
msg = "%s.%s"%(master_node, attr)
self.log.insertText(" %s" %(msg.ljust(40, '.')))
if not pm.objExists('%s.%s'%(master_node, attr)):
self.log.insertText("FAIL \n")
status = False
if master_node not in self.result.getAllItems():
self.result.append(master_node)
else:
self.log.insertText("OK \n")
return status
示例2: __restoreShapes__
def __restoreShapes__(elts):
if elts==None:
# get each objects from rigShapesSet
if pmc.objExists('rigShapesSet'):
elts = pmc.sets('rigShapesSet', query=True)
fromSelection=False
else:
fromSelection=True
if elts:
for elt in elts:
if fromSelection:
atoms = various.getAtoms(elt.getShape(), flat=False)
for i in range(len(atoms)):
try:
pmc.move(atoms[i], pmc.PyNode(elt.name()+'_storedShp.cv'+str(i)).get(), absolute=True)
except:
vp.vPrint('No %s in rigShapesSet set' % (elt.name()+'_storedShp'), 1)
else:
if pmc.objExists(elt.name().replace('_storedShp', '')):
obj = pmc.PyNode(elt.name().replace('_storedShp', '')).getShape()
atoms = various.getAtoms(obj, flat=False)
for i in range(len(atoms)):
try:
pmc.move(atoms[i], pmc.PyNode(elt+'.cv'+str(i)).get(), absolute=True)
except:
vp.vPrint('No data founded from %s in rigShapesSet set' % elt.name(), 1)
else:
vp.vPrint('Shape %s doesn\'t exist' % elt.name().replace('_storedShp', ''), 1)
示例3: custom_sets
def custom_sets(self, *args):
self.log.clear()
self.log.insertText('Create Custom Sets...\n')
self.log.insertText('\nFind all controls under the groups: \n "Placer", "rig_arc", and "Face_UI|Panels"\n\nGenerate two sets as result : \n "ctrlSet" contains all tagged controls\n "_NON_TAGGED_CURVES" contains all non-tagged controls\n')
ctrlSets = pm.ls("*ctrlSet")
if not ctrlSets:
self.controlSet = pm.sets(empty=True, name = "ctrlSet")
grps = [grp for grp in ['Placer', 'rig_arc'] if pm.objExists(grp)]
pm.select(grps, hi=True)
all_curve = pm.ls(sl=True, type="nurbsCurve")
pm.select(clear=True)
all_ctrl = [ctrl.getParent() for ctrl in all_curve]
if pm.objExists('Panels'):
pm.select('Panels', hi=True)
all_facial_curve = pm.ls(sl=True, type="nurbsCurve")
pm.select(clear=True)
all_ctrl.extend([curve.getParent() for curve in all_facial_curve if curve.getParent().tz.isLocked()])
#pm.sets(all_ctrl, name="_ALL_CURVES")
no_tags = [ctrl for ctrl in all_ctrl if not pm.attributeQuery ('ClientAnimCtrl', node= ctrl, ex=True)]
pm.sets(no_tags, name="_NON_TAGGED_CURVES")
tags = [ctrl for ctrl in all_ctrl if pm.attributeQuery ('ClientAnimCtrl', node= ctrl, ex=True)]
self.controlSet.addMembers(tags)
示例4: locInst_locSel
def locInst_locSel(self):
'''
Function: Takes a locator and instances it's target (set as an extra attr)
Then sets the location of the instance.
If the instance already exists it uses that
Returns: None
'''
locs = pm.ls(sl=True)
grp_name = "_".join(locs[0].getParent().split('_')[:-2])+"_INST_GRP"
print grp_name
print pm.objExists(grp_name)
if pm.objExists(grp_name): pm.PyNode(grp_name)
else: grp=pm.group(em=True, n=grp_name)
for loc in locs:
#if the target isn't an instance create it
targetExists = pm.ls(loc.target.get().split('_')[:-1][0]!='GEO', r=True, type='transform')[0]
instanceExists = pm.ls(loc.target.get().split('_')[:-1][0]!='INST', r=True, type='transform')[0]
if not instanceExists and targetExists:
matchObj = pm.ls(loc.target.get(), r=True, type='transform')[0]
instance = pm.instance(matchObj, n=('_'.join(matchObj.split('_')[:-1])+'_INST'))[0]
#set the target to the new instance since it was created
loc.target.set(instance)
elif pm.objExists(loc.target.get()) and pm.objExists('_'.join(target.split('_')[:-1])+'_INST'):
pm.error('Neither a GEO nor an INST object exists with this name')
#otherwise initialize the instance variable
else: instance = pm.PyNode('_'.join(arg.split('_')[:-1])+'_INST')
loc.t.connect( instance.t )
loc.r.connect( instance.r )
loc.s.connect( instance.s )
instance.setParent(grp)
示例5: create_wireframe_rl
def create_wireframe_rl(name="wireframe"):
"""
Creates wireframe material
Creates wireframe layer
Adds all geometry and rendercam to the renderlayer
@param name: str layername
"""
mat_name = "%s_mat" % name
if not pm.objExists(mat_name):
material_node = pm.shadingNode("lambert", n=mat_name, asShader=True)
material_node.setColor([1, 1, 1])
material_sg_node = pm.sets(renderable=True, noSurfaceShader=True, empty=True, name="%sSG" % mat_name)
material_sg_node.miContourEnable.set(1)
material_sg_node.miContourColor.set([0,0,0])
material_sg_node.miContourWidth.set(1.5)
material_node.outColor >> material_sg_node.surfaceShader
if not pm.objExists(name):
render_layer = pm.createRenderLayer(n=name)
render_layer.setCurrent()
render_layer.addMembers(pm.ls(geometry=True, cameras=True))
material_sg_node.message >> render_layer.shadingGroupOverride
示例6: create_control
def create_control(control, module):
""" Creates a control for the rig, checking for existing controls or creating
Args:
control (str, pm.nt.Transform): can be anything really, just as long as it exists
Returns:
(pm.nt.Transform): the resulting transform of the control
"""
is_new = False
# Check if default control was created
if pm.objExists('grow_CTRL') and not pm.objExists(control):
control = pm.PyNode('grow_CTRL')
# Create the control if control doesn't exist
elif not pm.objExists(control):
control = pm.circle(n='grow_CTRL')
# Flat control in Y...
control[1].normalY.set(1)
control[1].normalZ.set(0)
control = control[0]
is_new = True
# If it's a string and we weren't passed a PyNode we need to check existing nodes
elif isinstance(control, basestring):
control = pm.PyNode(control)
setup_control_global_attrs(control, module)
return control, is_new
示例7: loadDeformerWeights
def loadDeformerWeights(filename=None):
'''
Usage:
loadDeformerWeights(filename='/jobs/mercedesFable_5402587/build/charTortoise/maya/export/WEIGHTS/tortoiseAFacial/extraWeights/deformerWeights/v03/deformerWeights.json')
loadDeformerWeights()
'''
if not filename:
try:
filename = pm.fileDialog2(cap='Select a json file you stored', fm=1, okc='Load', ff='JSON (*.json)')[0]
except:
pm.error('file not found, whatever.')
with open(filename, 'rb') as fp:
data = json.load(fp)
for key in data.keys():
if pm.objExists(key):
deformer = Deformer(pm.PyNode(key))
print 'Loading weights for deformer:\t%s'%deformer
for deformedShape in data[key].keys():
if pm.objExists(deformedShape):
print '\tLoading deformer weights on shape:\t%s'%deformedShape
deformedTransform = pm.PyNode(deformedShape).getParent()
#print data[key][deformedShape]
deformer.setWeights(data[key][deformedShape], deformedTransform)
else:
pm.warning('Object %s does not exist to apply deformer weights to...skipping'%deformedShape)
else:
pm.warning('Deformer %s doesn\'t exist...skipping'%key)
示例8: test_clusterPlane
def test_clusterPlane(self):
fr = FollowRibbon.FollowRibbon(name="blah")
plane = pm.nurbsPlane(axis=[0, 1, 0], patchesU=8, patchesV=1, lengthRatio=0.1, ch=0)[0]
ctrls = []
ctrls.append(pm.circle(n="blah_ctrl_01")[0].name())
ctrls.append(pm.circle(n="blah_ctrl_02")[0].name())
mainGrp = pm.group(em=1, name="main")
result = fr._clusterPlane(plane=plane, controls=ctrls, mainGrp="main")
self.testLib.assertListEqual(result, ["blah_cluster_01Handle", "blah_cluster_02Handle"])
self.assertTrue(pm.objExists("blah_cluster_01"))
self.assertTrue(pm.objExists("blah_cluster_02"))
self.assertTrue(pm.listRelatives(result[0], parent=True), "main")
self.assertTrue(pm.listRelatives(result[1], parent=True), "main")
self.assertTrue(pm.listRelatives(result[0], parent=1)[0], "blah_ctrlsGrp")
self.assertTrue(pm.listRelatives(result[1], parent=1)[0], "blah_ctrlsGrp")
hist = pm.listHistory(plane)
hitA = 0
hitB = 0
for each in hist:
if each.name() == "blah_cluster_01":
hitA = 1
if each.name() == "blah_cluster_02":
hitB = 1
self.assertTrue(hitA)
self.assertTrue(hitB)
self.assertTrue(pm.isConnected("blah_ctrl_01.translate", "blah_cluster_01Handle.translate"))
self.assertTrue(pm.isConnected("blah_ctrl_02.translate", "blah_cluster_02Handle.translate"))
示例9: dictToDatas
def dictToDatas(self, dict_datas):
"""
[email protected] Get dict datas of skinCluster and push datas to class variables.
This function is for import.
"""
if not dict_datas:
raise RuntimeError("\n\tDict datas is empty or invalid !!!\n")
# Check if skin node exists
# If skin node doesn't exist set variable with string name
if pmc.objExists(dict_datas["SKIN_NODE"]):
self.SKIN_NODE = pmc.PyNode(dict_datas["SKIN_NODE"])
else:
self.SKIN_NODE = dict_datas["SKIN_NODE"]
# Check if shape node exists
# If shape node doesn't exist set variable with string name
if pmc.objExists(dict_datas["SHAPE"]):
self.SHAPE = pmc.PyNode(dict_datas["SHAPE"])
else:
self.SHAPE = dict_datas["SHAPE"]
# Set skin datas
self.INFLUENCES = dict_datas["INFLUENCES"]
self.WEIGHTS = dict_datas["WEIGHTS"]
self.MAX_INFLUENCES = dict_datas["MAX_INFLUENCES"]
self.MAINTAIN_MAX_INFLUENCES = dict_datas["MAINTAIN_MAX_INFLUENCES"]
self.SKINNING_METHOD = dict_datas["SKINNING_METHOD"]
self.USE_COMPONENTS = dict_datas["USE_COMPONENTS"]
self.BIND_PRE_MATRIX = dict_datas["BIND_PRE_MATRIX"]
self.BASE_POINT = dict_datas["BASE_POINT"]
示例10: _create_deformers_
def _create_deformers_(self):
# Setup missing geo shapes dictionary
missing_shapes = {}
# Build in the order of blendshapes
for blendshape in libXml.list_persist(self.import_data["Order"]):
# Check if the blendshapes exists. If so create one.
shapes = libXml.list_persist(self.import_data["Data"][blendshape])
if not pm.objExists(blendshape):
# Read info for each blendshape
# select select the shapes.
pm.select(cl=1)
for shape in shapes:
# Check the shape exists
if pm.objExists(shape):
# Add to the selection
pm.select(shape, add=1)
else:
# If not then then add to error list dictionary
if missing_shapes.has_key(blendshape):
missing_shapes[blendshape].append(shape)
else:
missing_shapes[blendshape] = [shape]
# Select the target geo and create blendshape
pm.select(self.target, add=1)
pm.blendShape(name=blendshape)
if len(missing_shapes):
print "#######The following blends had missing shapes#######"
for key in missing_shapes.keys():
print key.upper()
libUtilities.print_list(missing_shapes[key])
示例11: create_module
def create_module(name):
""" Creates a top group from an object name
For now, just dummy checking if the suffix is all caps
Args:
name (str): name to parse or use
Returns (pm.nt.Transform): resulting group node
"""
module = {}
if name.split('_')[-1].isupper():
name = '_'.join( name.split('_')[:-1] )
grp_name = '%s_GRP'%name
if pm.objExists(name):
top_group = pm.PyNode(name)
elif pm.objExists(grp_name):
top_group = pm.PyNode(grp_name)
else:
top_group = pm.group(em=True, n='%s_GRP'%name)
module['top_group'] = top_group
for subgroup in ['skeleton','model','parts','controls']:
subgroup_name = '%s_%s_GRP'%(name, subgroup)
if not pm.objExists(subgroup_name):
module[subgroup] = pm.group(em=True, n=subgroup_name)
module[subgroup].setParent(top_group)
top_group.addAttr('%s_vis'%subgroup,
at='long',
k=True,
dv=1, min=0, max=1)
top_group.attr('%s_vis'%subgroup).connect(module[subgroup].visibility)
else:
module[subgroup] = pm.PyNode(subgroup_name)
return module
示例12: _prep
def _prep(self,args):
basename=self.inputName.getText()
nparticle=pm.ls(sl=True)[0]
if not pm.objExists(self.inputBar.getText()):
pm.error ('GEO plane doesn\'t exist')
geo = pm.PyNode(self.inputBar.getText())
if not isinstance(nparticle.getShape(), pm.nt.NParticle):
pm.error('Your selection is not an nParticle object')
#create an instancer
tempCube=pm.polyCube(n='temp_iinst_GEO',w=.01,h=.01,d=.01,ch=0)
self.instancer=pm.PyNode(pm.particleInstancer(nparticle,name=(nparticle.name().replace('_NPARTICLE','_INSTANCER')),addObject=True,object=tempCube[0],cycleStep=1,cycleStepUnits='Frames',levelOfDetail='Geometry',rotationUnits='Degrees',rotationOrder='XYZ',position='worldPosition',rotation='rotPP',scale='scalePP',objectIndex='indexPP'))
pm.delete(tempCube)
#group the nparticle + instancer
group=pm.group(n=(nparticle.name().replace('_NPATICLE','_lodA_GRP')))
nparticle.setParent(group)
self.instancer.setParent(group)
#nCache itR
if not pm.objExists( nparticle.name().replace('_NPARTICLE','_NUCLEUS') ):
pm.error('Nucleus doesn\'t exist!')
nucleus = nparticle.name().replace('_NPARTICLE','_NUCLEUS')
#delete everything unnecessary that might cause issues
print geo, nucleus
print 'issue?'
pm.delete(geo, nucleus)
print 'issue?'
pm.select(nparticle)
mm.eval('performCreateNclothCache 1 \"add\";')
pm.confirmDialog(m='WARNING, DO NOT SAVE AFTER THIS STEP',t='DONT SAVE!')
示例13: createObjectSet
def createObjectSet(setName, objLst = [], exclusiveness = False, partition = None, increment = False):
'''
create an objectSet.
@param setName string : This objectSet's name.
@param objLst list : Objects which belongs this objectSet.
@param exclusiveness bool : Whether is this objectSet mutually exclusive with another objectSet in one partition.
@param partition node or string : When exclusiveness flag is True, partitin should be assigned a partition node. Ignore when exclusiveness flag is False.
@param increment bool : Whether to use the existed one or create an increment one When the named objectSet has been existed.
If the existed objectSet will be used, ignore exclusiveness flag and partition flag.
@result node
'''
useExisted = False
if not pm.objExists(setName):
objSet = pm.sets(em=1, name = setName)
elif pm.objExists(setName) and increment :
setName = name.compileNodeName(setName)
objSet = pm.sets(em=1, name = setName)
else:
objSet = pm.PyNode(setName)
useExisted = True
if not useExisted and exclusiveness :
partition.addMember(objSet)
if objLst:
#objSet.addMembers(objLst)
pm.sets(objSet, e=1, forceElement = objLst)
return objSet
示例14: __restorePosingRIG__
def __restorePosingRIG__(elts):
if elts==None:
# get each objects from rigShapesSet
if pmc.objExists('RIG_bindPose'):
elts = pmc.sets('RIG_bindPose', query=True)
fromSelection=False
else:
fromSelection=True
if elts:
for elt in elts:
if fromSelection:
if pmc.objExists(elt.name()+'_storedPos'):
obj = elt.name()+'_storedPos'
attrs = pmc.listAttr(elt, keyable=True)
for i in range(len(attrs)):
try:
pmc.PyNode(elt+'.'+attrs[i]).set(pmc.PyNode(obj+'.'+attrs[i]+'_stored').get())
except:
vp.vPrint('No data founded from %s in rigPosingSet set' % elt.name(), 1)
else:
vp.vPrint('Object %s doesn\'t exist' % (elt.name()+'_storedPos'), 1)
else:
if pmc.objExists(elt.name().replace('_storedPos', '')):
obj = pmc.PyNode(elt.name().replace('_storedPos', ''))
attrs = pmc.listAttr(obj, keyable=True)
for i in range(len(attrs)):
try:
pmc.PyNode(obj+'.'+attrs[i]).set(pmc.PyNode(elt+'.'+attrs[i]+'_stored').get())
except:
vp.vPrint('No data founded from %s in rigPosingSet set' % elt.name(), 1)
else:
vp.vPrint('Object %s doesn\'t exist' % elt.name().replace('_storedPos', ''), 1)
示例15: createHierarchy
def createHierarchy():
"""hierarchy construction"""
gp = {}
# create groups
grps = [['TEMPLATES'], ['BDD'], ['PERSO'], ['SKINSKEL'], ['ADDITIVERIG'], ['ANIMATION'], ['TODELETE'], ['SETUP','PERSO|'], ['SCALEOFFSET','PERSO|SETUP|'], ['NOXFORM','PERSO|SETUP|']]
for grp in grps:
# create the absolute path
tmpName = '|'
for i in reversed(range(len(grp))):
tmpName += grp[i]
# check if the object exist
if pmc.objExists(tmpName):
gp[grp[0]] = pmc.PyNode(tmpName)
else:
gp[grp[0]] = pmc.createNode('transform', name=grp[0], skipSelect=True)
if len(grp)==2:
gp[grp[0]].setParent(grp[1])
clean.__lockHideTransform__(gp[grp[0]], channel=['v'])
# uncheck inherits transform
gp['BDD'].inheritsTransform.set(False)
gp['NOXFORM'].inheritsTransform.set(False)
# create scale offset attribut
if gp['SCALEOFFSET'].hasAttr('scaleOffset')==False:
pmc.addAttr(gp['SCALEOFFSET'], longName='scaleOffset', attributeType='float', defaultValue=1.0, keyable=True )
# connect the scale offset attribut into the scale
clean.__lockHideTransform__(gp['SCALEOFFSET'], channel=['s'], lock=False)
if len(gp['SCALEOFFSET'].sx.inputs(plugs=True))==0:
gp['SCALEOFFSET'].scaleOffset >> gp['SCALEOFFSET'].sx
if len(gp['SCALEOFFSET'].sy.inputs(plugs=True))==0:
gp['SCALEOFFSET'].scaleOffset >> gp['SCALEOFFSET'].sy
if len(gp['SCALEOFFSET'].sz.inputs(plugs=True))==0:
gp['SCALEOFFSET'].scaleOffset >> gp['SCALEOFFSET'].sz
# hide and lock attribut
for key in gp.keys():
clean.__lockHideTransform__(gp[key], channel=['t', 'r', 's'])
# create set
pmc.select(clear=True)
sets = ['CONTROLS']
for set in sets:
if pmc.objExists(set)==False:
gp[set] = pmc.sets(name=set)
else:
gp[set] = pmc.nodetypes.ObjectSet('CONTROLS')
return gp