本文整理汇总了Python中pymel.core.sets函数的典型用法代码示例。如果您正苦于以下问题:Python sets函数的具体用法?Python sets怎么用?Python sets使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sets函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: doExecution
def doExecution(*args):
is_find = pm.checkBox( UI_name[0], q=True, value=True )
is_fix = pm.checkBox( UI_name[1], q=True, value=True )
is_fixLayer = pm.checkBox( UI_name[2], q=True, value=True )
shader_info_all_layers = []
if( is_find ):
findErrorShape()
if( is_fixLayer ):
#// collect shaders info in each layer
shader_info_all_layers = collectShaderInfoInLayer()
if( is_fix ):
fixComponentShading()
if( is_fixLayer ):
for shd_layer in shader_info_all_layers:
#// switch to a specified layer
curr_layer = shd_layer[0]
pm.editRenderLayerGlobals( currentRenderLayer=curr_layer )
#// parsing string for mesh & shader from list
#// assign shader to mesh from list
for shd in shd_layer[1]:
obj = shd[0]
SG = shd[1]
pm.sets( SG, edit=True, forceElement=obj )
pm.editRenderLayerGlobals( currentRenderLayer='defaultRenderLayer' )
return 1
示例2: 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
示例3: useVRayMtl
def useVRayMtl(currentPage, texture1):
shdr, sg = pm.createSurfaceShader( 'VRayMtl', currentPage[0]+"_shdr" )
pm.sets( sg, forceElement=currentPage )
filenode = pm.createNode('file', name=currentPage[0]+"_file")
filenode.fileTextureName.set(texture1)
pm.connectAttr( filenode+".outColor", shdr.color , force=1)
placement = pm.shadingNode('place2dTexture', asUtility=1, name='placeTextureName')
pm.connectAttr(placement.outUV, filenode.uvCoord, f=1)
pm.connectAttr(placement.outUvFilterSize, filenode.uvFilterSize, f=1)
pm.connectAttr(placement.coverage, filenode.coverage, f=1)
pm.connectAttr(placement.translateFrame, filenode.translateFrame, f=1)
pm.connectAttr(placement.rotateFrame, filenode.rotateFrame, f=1)
pm.connectAttr(placement.mirrorU, filenode.mirrorU, f=1)
pm.connectAttr(placement.mirrorV, filenode.mirrorV, f=1)
pm.connectAttr(placement.stagger, filenode.stagger, f=1)
pm.connectAttr(placement.wrapU, filenode.wrapU, f=1)
pm.connectAttr(placement.wrapV, filenode.wrapV, f=1)
pm.connectAttr(placement.repeatUV, filenode.repeatUV, f=1)
pm.connectAttr(placement.vertexUvOne, filenode.vertexUvOne, f=1)
pm.connectAttr(placement.vertexUvTwo, filenode.vertexUvTwo, f=1)
pm.connectAttr(placement.vertexUvThree, filenode.vertexUvThree, f=1)
pm.connectAttr(placement.vertexCameraOne, filenode.vertexCameraOne, f=1)
pm.connectAttr(placement.noiseUV, filenode.noiseUV, f=1)
pm.connectAttr(placement.offset, filenode.offset, f=1)
pm.connectAttr(placement.rotateUV, filenode.rotateUV, f=1)
pm.setAttr(placement.rotateFrame, 90)
pm.setAttr(placement.repeatU, -1)
示例4: binMeshAssignShader
def binMeshAssignShader(creatorShape = None, shadingGroupList=[], perFaceAssingments=[]):
if not creatorShape:
log.error("binMeshAssignShader: No creator shape")
return
if pm.PyNode(creatorShape).type() != "mtap_standinMeshNode":
log.error("binMeshAssignShader: Node {0} is not a creator shape".format(creatorShape))
return
log.debug("binMeshAssignShader: creatorShape {0}".format(creatorShape))
polyShapeList = getConnectedPolyShape(creatorShape)
for polyShape in polyShapeList:
log.debug("binMeshAssignShader: polyShape {0}".format(polyShape))
for index, shadingGroup in enumerate(shadingGroupList):
binMeshCheckAndCreateShadingGroup(shadingGroup)
assignments = perFaceAssingments[index]
print assignments
faceSelection = []
for polyId in assignments:
faceSelection.append(polyId)
print "meshShape has", polyShape.numFaces(), "faces. Edeff."
fs = polyShape.f[faceSelection]
print "pm.sets('{0}', e=True, forceElement={1})".format(shadingGroup,str(fs))
pm.sets(shadingGroup, e=True, forceElement=str(fs))
示例5: assign_material
def assign_material(mtl_or_sg, *nodes):
'''Assign a material to a bunch of nodes
:param mtl_or_sg: The material or shadingEngine to assign
:param nodes: The nodes to be assigned to
'''
class_ = mtl_or_sg.classification()
if 'shadingEngine' in class_:
sg = mtl_or_sg
elif 'shader/surface' in class_:
sgs = pmc.listConnections(mtl_or_sg, type='shadingEngine')
if sgs:
sg = sgs[0]
else:
sg = pmc.sets(
empty=True,
renderable=True,
name=str(mtl_or_sg) + 'SG'
)
mtl_or_sg.outColor.connect(sg.surfaceShader)
else:
raise TypeError('{} not a shader or shadingEngine'.format(mtl_or_sg))
for node in nodes:
pmc.sets(sg, forceElement=node)
示例6: move_face_shell
def move_face_shell(faces, u=0, v=0):
""" Move all uvs related to arg faces by u and v values
"""
udim = uv_udim_convert([u,v])
uvs = pm.polyListComponentConversion(faces, tuv=True)
pm.polyEditUV(uvs, u=-(u-1), v=-(v-1))
pm.sets(faces, n=set_name%str(udim))
示例7: create_dominant_color_shader
def create_dominant_color_shader(dag, tex_name_surfix=['co', 'color', 'diffuse', 'dif', 'base'],
sample_rate=None, max_auto_sample=50,
default_shader='aiStandardSurface', default_channel='baseColor'):
"""
Create an auto average-color lambert shader and assign it to input object.
Maybe does not work with TIFF texture ( cannot extract color ).
"""
if type(dag) == pm.nodetypes.Transform:
mesh = dag.getShape()
if not type(mesh) == pm.nodetypes.Mesh:
return None
elif type(dag) == pm.nodetypes.Mesh:
mesh = dag
else:
return None
avg_color = _detect_dominant_color(mesh, tex_name_surfix, sample_rate,
max_auto_sample, default_shader, default_channel)
if not avg_color:
return None
color_shader, sg = pm.createSurfaceShader('lambert')
color_shader.color.set(avg_color)
pm.connectAttr(color_shader.color, sg.surfaceShader, f=1)
pm.sets(sg, forceElement=mesh)
return color_shader
示例8: 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)
示例9: create
def create(self):
"""creates Maya objects
"""
import pymel.core as pm
self.parent_node = self.get_parent()
self.shape_node = pm.nt.Mesh(name='%sShape' % self.node_name)
self.transform_node = self.shape_node.getParent()
self.transform_node.rename(self.node_name)
self.rs_proxy_node = \
pm.nt.RedshiftProxyMesh(name='%sRsProxy' % self.node_name)
self.rs_proxy_node.outMesh >> self.shape_node.inMesh
self.rs_proxy_node.fileName.set(self.instance_file)
# self.transform_node.t.set(self.pos)
# self.transform_node.r.set(self.rot)
# self.transform_node.s.set([self.sca, self.sca, self.sca])
self.parent_node.t.set(self.pos)
self.parent_node.r.set(self.rot)
self.parent_node.s.set([self.sca, self.sca, self.sca])
# assign default shader
lambert1 = pm.ls('lambert1')[0]
lambert1_shading_group = \
lambert1.outputs(type='shadingEngine')[0]
pm.sets(lambert1_shading_group, fe=self.transform_node)
pm.parent(self.transform_node, self.parent_node, r=1)
示例10: _restoreShaders
def _restoreShaders(self, shadersDict):
objsInScene = set(map(str, pm.ls()))
for obj, shs in shadersDict.iteritems():
if (str(obj) in objsInScene):
for shader in shs:
if (str(shader) in objsInScene):
pm.select(obj)
pm.sets(shader, fe=1)
示例11: assignTriPlanarShader
def assignTriPlanarShader(objA, tX=None, tY=None, tZ=None):
shdNode, shdGrp, placement = createTriPlanarShader(txtX=tX, txtY=tY, txtZ=tZ)
pm.sets(shdGrp, edit=True, forceElement=objA)
pm.mel.eval("source AEplace3dTextureTemplate.mel;")
for i in placement:
try:
pm.mel.eval("PSfitPlacementToGroup %s;" % i.name())
except pm.MelUnknownProcedureError:
pass
示例12: rig_crankshaft
def rig_crankshaft():
#cmds.file("/jobs/pennzoilPennzoilNaturalGas_5402237/build/piston/release/work/mayaScene/pistonBuild/vLatest/mayaScene_pistonBuild_vLatest.ma",
# i=True, type="mayaAscii", ignoreVersion=True,rpr="mayaScene_pistonBuild_vLatest",options="v=0",pr=True,loadReferenceDepth="all")
#setup variables for existing nodes
global_ctrl=pm.PyNode('global_CTRL')
global_loc=pm.PyNode('global_LOC')
crankshaft_ctrl = pm.PyNode('crankshaft_CTRL')
crankshaft_loc = pm.PyNode('crankshaft_LOC')
display_ctrl = mpc.rig_makeCtrlLabel('display')
#create piston controls
for piston in range(0,global_loc.numPistons.get()):
ctrl_offset = mpc.rig_ctrlDuplicate(crankshaft_ctrl, 'piston'+string.uppercase[piston]+'_mover')
weight_loc = pm.PyNode('weight%s_LOC'%string.uppercase[piston])
rod_loc = pm.PyNode('rod%s_LOC'%string.uppercase[piston])
head_loc = pm.PyNode('head%s_LOC'%string.uppercase[piston])
piston_loc = pm.PyNode('piston%s_LOC'%string.uppercase[piston])
if ctrl_offset[0]:
pm.delete( pm.parentConstraint(weight_loc, ctrl_offset[0] ) )
ctrl_offset[0].rx.set(90)
pm.parentConstraint(ctrl_offset[2], piston_loc, mo=True)
else:
pm.delete( pm.parentConstraint(weight_loc, ctrl_offset[1] ) )
pm.parentConstraint(ctrl_offset[2], piston_loc, mo=True)
mpc.rig_ctrlLock([ctrl_offset[1]], ['tx','ty','tz','rz','ry','sx','sy','sz','v'], setKeyable=False, lock=True)
mpc.rig_ctrlColor(ctrl_offset[1], 15)
#setup connections
pm.delete( pm.parentConstraint( crankshaft_ctrl.getParent(), crankshaft_loc ) )
pm.parentConstraint( crankshaft_ctrl, crankshaft_loc, mo=True )
#parent + create groups + lock down ctrls
grp_csr = pm.group(em=True,n='crankshaftRig_GRP')
grp_model = pm.group(em=True,n='model_GRP')
grp_nodes = pm.group(em=True,n='nodes_GRP')
grp_model.setParent(grp_csr)
grp_nodes.setParent(grp_csr)
global_ctrl.getParent().setParent(grp_csr)
global_loc.setParent(grp_nodes)
global_loc.visibility.set(0)
display_ctrl.getParent().setParent(global_ctrl)
display_ctrl.getParent().ty.set(pm.xform('headA_LOC', q=True , t=True, ws=True)[1])
mpc.rig_ctrlLock([crankshaft_ctrl], ['tx','ty','tz','rz','ry','sx','sy','sz','v'], setKeyable=False, lock=True)
pm.scaleConstraint( global_ctrl, grp_nodes, mo=True )
display_ctrl.addAttr('displayLocators', at='long', min=0,max=1, k=True)
display_ctrl.displayLocators.connect(global_loc.v, f=True)
if pm.objExists('pistons_lodA_GRP'):
pm.PyNode('pistons_lodA_GRP').setParent(grp_model)
#Create Sets
rp_set = mpc.rig_setsCreateHubSet([grp_csr], 'crankshaft', 'rigPuppet')
ac_set = mpc.rig_setsCreateHubSet(pm.ls('*CTRL'), 'crankshaft','animCurves')
gc_set = mpc.rig_setsCreateHubSet(pm.ls('*GEO'), 'crankshaft','geometryCache')
pm.delete('hubMayaScenePistonBuildSet')
pm.sets(rp_set, add=(ac_set, gc_set))
示例13: matAsign
def matAsign(): # ASIGN MATERIAL FOR ALL OBJECTS
listAtrRoot = pm.ls('*.mtoa_constant_mMat')
listAtrRef = pm.ls('*:*.mtoa_constant_mMat')
listAtr = set(listAtrRef + listAtrRoot) # combine lists for REFERENCED and ROOT geo
for i in listAtr:
object = pm.PyNode(i.split('.')[0]) # Create object based on << mMat >>
ins = pm.ls(object, ap = 1, dag = 1 ) # select instances
if i.get():
if pm.objExists((i.get()+ 'SG')):
pm.sets((i.get()+ 'SG'), forceElement = ins)
示例14: __mirrorShapes__
def __mirrorShapes__(elts, across='x', direction='L_'):
if elts==None:
# get each element inside CONTROL
if pmc.objExists('CONTROLS'):
elts = pmc.sets('CONTROLS', query=True)
i=0
while i<len(elts):
if pmc.objectType(elts[i]) == 'objectSet':
elts.extend(pmc.sets(elts[i], query=True))
elts.pop(i)
i -= 1
i += 1
# delete element at center meaning without L_ or R_
for i in reversed(range(len(elts))):
if (elts[i].name().startswith(direction)==False):
elts.pop(i)
else:
vp.vPrint('No CONTROLS set funded', 1)
else:
# delete element at center meaning without L_ or R_
for i in reversed(range(len(elts))):
if (elts[i].name().startswith('L_')==False) and (elts[i].name().startswith('R_')==False):
elts.pop(i)
# creating the vector inverse depending on the across variable
if across=='x':
vectInverse = [-1,1,1]
if across=='y':
vectInverse = [1,-1,1]
if across=='z':
vectInverse = [1,1,-1]
# loop into each element
for elt in elts:
# finding the opposite transform
if elt.startswith('L_'):
eltInv = various.checkObj( elt.name().replace('L_', 'R_'), type=['transform', 'joint'] )
else:
eltInv = various.checkObj( elt.name().replace('R_', 'L_'), type=['transform', 'joint'] )
if eltInv:
# getting atoms from both element
atoms = various.getAtoms(elt, flat=False)
atomsInv = various.getAtoms(eltInv, flat=False)
# finding the smallest object just in case one has less atoms than the other
if len(atoms) > len(atomsInv):
size = len(atomsInv)
else:
size = len(atoms)
# working on each atoms
for i in range(size):
pmc.move(atomsInv[i], atoms[i].getPosition(space='world')*vectInverse, absolute=True)
示例15: cbsTrans
def cbsTrans(*args, **kwargs):
sculptTrans = kwargs.setdefault('sculptTrans', pm.ls(sl=True)[0])# (string) The mesh to get the tweak edits extracted from
shape = kwargs.setdefault('shape') # (string) The shape node of the sculptTrans node
tweak = kwargs.setdefault('tweak') # (string) The tweak node that is going to be cleared
skin = kwargs.setdefault('skin') # (string) The skinCluster node that drives the base mesh
base = kwargs.setdefault('base') # (string) The base mesh for the character
#get some info
sculptTrans, shape, tweak, skin = gatherInfo(sculptTrans, shape, tweak, skin)
if not 'baseTransform' in pm.listAttr(sculptTrans, ud=True):
pm.error('This model has not been prepared for sculpting. If you accidentally started, simply run Clear Tweaks to extract what has been done')
if not base:
base = sculptTrans.baseTransform.get()
baseRef = sculptTrans.baseReference.get()
#turn off a couple things that might mess with things
pm.symmetricModelling(e=True, symmetry= False)
pm.softSelect(e=True, softSelectEnabled=False)
#first, let's unlock the guys from the old function
pm.lockNode(base, l=False)
pm.lockNode(sculptTrans, l=False)
pm.setAttr('%s.v'%base, True)
#extract from the sculpted shape
newShape = clearTweaks(base=base, tweak=tweak)
pm.delete(sculptTrans)
newOrig = pm.duplicate(base, n='%s_editReference'%base)[0]
pm.connectAttr(('%s.outMesh' %newOrig.getShapes()[1]), ('%s.inMesh' %newOrig.getShape()))
pm.select(cl=True)
deviation = False
for v in range(pm.polyEvaluate(base, v=True)):
refPos = pm.xform('%s.vtx[%i]'%(baseRef, v), q=True, t=True)
adjPos = pm.xform('%s.vtx[%i]'%(newOrig, v), q=True, t=True)
if not refPos == adjPos:
deviation=True
pm.move('%s.vtx[%i]' %(newShape, v), (refPos[0]-adjPos[0], refPos[1]-adjPos[1], refPos[2]-adjPos[2]), r=True)
pm.move('%s.vtx[%i]'%(base, v), (refPos[0]-adjPos[0], refPos[1]-adjPos[1], refPos[2]-adjPos[2]), os=True, r=True)
pm.select('%s.vtx[%i]' %(base, v), add=True)
if deviation:
pm.warning('It appears there were issues extracting from the mesh, steps have been taken to try and remedy, but unexpected results may occur')
#apply a texture to the new shape.
pm.select(newShape, r=True)
pm.sets('initialShadingGroup', e=True, forceElement=True)
pm.delete(newOrig, baseRef)
return newShape