本文整理汇总了Python中pymel.core.delete函数的典型用法代码示例。如果您正苦于以下问题:Python delete函数的具体用法?Python delete怎么用?Python delete使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了delete函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_system
def delete_system(self):
if self.delete == True:
pm.delete(self.main_group)
self.kill()
if self.delete == False:
self.kill()
示例2: createEmitter
def createEmitter(self, mesh, name="particleEmitter_msh"):
# Create boundingBox of the mesh
bbx = pm.polyEvaluate(mesh, b=True)
cube = pm.polyCube(
w=abs(bbx[0][1] - bbx[0][0]),
h=abs(bbx[1][1] - bbx[1][0]),
d=abs(bbx[2][1] - bbx[2][0]),
sx=1,
sy=1,
sz=1,
ax=(0, 1, 0),
cuv=4,
ch=0,
name=name,
)
cube = cube[0]
cube.setAttr("t", ((bbx[0][1] + bbx[0][0]) / 2, (bbx[1][1] + bbx[1][0]) / 2, (bbx[2][1] + bbx[2][0]) / 2))
# Keep only face 1 for emit
pm.delete([cube + ".f[2:6]", cube + ".f[0]"])
# Connection of mesh and the emitter
self.connectOriginaleMesh(mesh, cube)
# Move emitter in y in a percentage of area of face.
face = pm.PyNode(cube + ".f[1]")
area = face.getArea(space="world")
pm.select(cube)
y = pow(area, 0.1) * 100
pm.move(0, y, 0, r=1, os=1, wd=1)
return cube
示例3: buildMainControls
def buildMainControls(self):
# Get the ctrl postion
ctrlPosition = utils.recalculatePosition(self.jointSystem.positions, self.numHighLevelCtrls)
metaCtrls = []
# Iterate though all the position
for i in range(self.numHighLevelCtrls):
output_window("Build Main Control: {}".format(i))
# Create a control object
ctrl = self.createCtrlObj("%s%i" % (self.part, i))
# Set the position
ctrl.prnt.translate = list(ctrlPosition[i])
# Lock the scale
ctrl.lockScale()
metaCtrls.append(ctrl)
# Is orientation set to world
if not self.ikControlToWorld:
# Get the closest joint position
closestJoints = libMath.spread(0, len(self.jointSystem) - 1, self.numHighLevelCtrls)
for jointPosition, i in zip(closestJoints, range(self.numHighLevelCtrls)):
# Is a closest joint a fraction
if jointPosition % 1:
# Orient between current and next
pm.delete(pm.orientConstraint(
self.jointSystem.jointList[int(jointPosition)],
self.jointSystem.jointList[int(jointPosition) + 1],
metaCtrls[i].prnt.pynode))
else:
pm.delete(pm.orientConstraint(
self.jointSystem.jointList[int(jointPosition)],
metaCtrls[i].prnt.pynode))
self.mainCtrls = metaCtrls
示例4: getMirrorAttrDrivenCurve
def getMirrorAttrDrivenCurve(animUL):
driverName, driverAttr, drivenName, drivenAttr = getDrivenName(animUL)
mirrorDriver = getMirrorCtrl(pm.PyNode(driverName))
mirrorDriven = getMirrorCtrl(pm.PyNode(drivenName))
mirrorAnimUL = getAttrDrivenCurve(mirrorDriver, driverAttr, mirrorDriven, drivenAttr)
if mirrorAnimUL:
pm.delete(mirrorAnimUL)
mirrorAnimULName = "{driver}_{driverAttr}_to_{driven}_{drivenAttr}".format(driver=mirrorDriver.name(), driverAttr=driverAttr, driven=mirrorDriven.name(), drivenAttr=drivenAttr)
mirrorAnimUL = pm.createNode("animCurveUL", name = mirrorAnimULName)
mfnAnimUL = mirrorAnimUL.__apimfn__()
for i in range(animUL.numKeys()):
input = animUL.getUnitlessInput(i)
value = animUL.getValue(i)
if driverAttr == 'tx' and drivenAttr == 'tx':
if input != 0:
newInput = -1*input
newValue = -1*value
elif driverAttr == 'tx' and drivenAttr != 'tx':
if input != 0:
newInput = -1*input
newValue = value
else :
newInput = input
newValue = value
mfnAnimUL.addKey(newInput, newValue, 1, 1)
return mirrorAnimUL
示例5: rebuildDagPose
def rebuildDagPose():
"""
Walks through bind pose data in selected skeleton and consolidates it down to one new bindPose node
Directly inspired by Nathan Horne's NT_rebuildDagPose.mel script
"""
dagPoses = set()
connectedSkinClusters = set()
selection = pmc.selected()
joints = pmc.listRelatives(selection[0], path=True, allDescendents=True, type="joint")
joints.insert(0, selection[0])
for jnt in joints:
dagPoses.update(jnt.listConnections(type="dagPose"))
for dag in dagPoses:
connectedSkinClusters.update(dag.listConnections(type="skinCluster"))
pmc.delete(dagPoses)
pmc.select(joints, replace=True)
newDagPose = pmc.dagPose(save=True, selection=True, bindPose=True)
print "New dagPose, {0}, created".format(newDagPose.shortName())
for sc in connectedSkinClusters:
print "Connecting {0}.message to {1}.bindPose".format(newDagPose.shortName(), sc.shortName())
newDagPose.message.connect(sc.bindPose)
示例6: export_hierarchy_obj
def export_hierarchy_obj(self):
"""Export the individual meshes in the hierarchy"""
file_info = {}
# Reverse the geo list so that the deepest geo is deleted first in case there is a geo inside geo
geo_list = self.geo_list
geo_list.reverse()
for self.current_target in geo_list:
pm.delete(self.current_target, ch=1)
parent = pm.listRelatives(self.current_target, parent=True)
pm.parent(self.current_target, w=True)
pm.select(self.current_target)
path = libFile.linux_path(libFile.join(self.export_dir, self.current_target + ".obj"))
# Load the obj plugin
cmds.file(path,
pr=1,
typ="OBJexport",
force=1,
options="groups=0;ptgroups=0;materials=0;smoothing=0;normals=0",
es=1)
file_info[self.current_target] = path
logger.info("Exporting\n%s" % file_info[self.current_target])
if not self.new_scene and self.cleansing_mode:
pm.delete(self.current_target)
pm.refresh()
else:
pm.parent(self.current_target, parent)
self.update_progress()
# Write the geo file_info
self.geo_file_info = file_info
示例7: create_point_on_mesh
def create_point_on_mesh(geo, position, sticky_target, free_rotation=True):
"""
Create point on mesh setup
@param position:
@param geo:
@parem sticky:
@return:
"""
pom = pm.createNode("closestPointOnMesh")
pom.inPosition.set(position)
geo.worldMatrix[0] >> pom.inputMatrix
geo.worldMesh[0] >> pom.inMesh
pom.position >> sticky_target.translate
index = pom.closestVertexIndex.get()
locator = pm.spaceLocator()
libUtilities.snap(locator, geo.vtx[index], rotate=False)
libUtilities.freeze_transform(locator)
pm.pointOnPolyConstraint(geo.vtx[index], locator, maintainOffset=True)
pm.delete(pom)
constraint = pm.listRelatives(locator, type="constraint")[0]
if free_rotation:
for attr in ["rx", "rz", "ry"]:
libUtilities.break_connection(locator, attr)
locator.attr(attr).set(0)
return {"constraint": constraint, "locator": locator}
示例8: bdLocOnJnt
def bdLocOnJnt():
try:
rootJnt = pm.ls(sl=True)[0]
except:
pm.warning('Nothing selected')
return
try:
crvPath = pm.ls(sl=True)[1]
except:
pm.warning('No curve selected')
return
allJnt = rootJnt.listRelatives(f=True, ad=True,type='joint')
allJnt = allJnt + [rootJnt]
allJnt.reverse()
locators = []
for jnt in allJnt:
print jnt
loc = pm.spaceLocator(name = jnt.name().replace( '_jnt','_loc'))
locGrp = pm.group(n = loc.name() + '_grp')
tempCnstr = pm.pointConstraint(jnt,locGrp,mo=0);
pm.delete(tempCnstr )
locators.append(locGrp)
bdMultiMotionPath(crvPath, locators)
bdParentJntToLocs(allJnt)
示例9: _parentSurfaceFLCL
def _parentSurfaceFLCL(self, constrained_obj, geo, deleteCPOMS=1):
"""
Parents object to follicle at closest point on surface.
Select child transform, then select mesh to hold parent follicle.
"""
cpos = pmc.createNode('closestPointOnSurface', n='cpos_flcl_' + geo)
mc.connectAttr(pmc.listRelatives(geo, shapes=True, children=True)[0] + '.local', cpos + '.inputSurface')
obj_mtx = pmc.xform(constrained_obj, q=True, m=True)
pmc.setAttr(cpos + '.inPosition', [obj_mtx[12], obj_mtx[13], obj_mtx[14]])
flclShape = pmc.createNode('follicle', n='flclShape' + geo)
flcl = pmc.listRelatives(flclShape, type='transform', parent=True)
pmc.rename(flcl, 'flcl_' + geo + '_1')
mc.connectAttr(flclShape + '.outRotate', flcl[0] + '.rotate')
mc.connectAttr(flclShape + '.outTranslate', flcl[0] + '.translate')
mc.connectAttr(geo + '.worldMatrix', flclShape + '.inputWorldMatrix')
mc.connectAttr(geo + '.local', flclShape + '.inputSurface')
mc.setAttr(flclShape + '.simulationMethod', 0)
u = mc.getAttr(cpos + '.result.parameterU')
v = mc.getAttr(cpos + '.result.parameterV')
pmc.setAttr(flclShape + '.parameterU', u)
pmc.setAttr(flclShape + '.parameterV', v)
pmc.parent(constrained_obj, flcl)
if deleteCPOMS == 1:
pmc.delete(cpos)
return flcl
示例10: position_joint
def position_joint(self):
'''
# positions the joint
'''
temp_parent_constraint = pm.parentConstraint(self.bound_geo, self.joint,
maintainOffset= False)
pm.delete(temp_parent_constraint)
示例11: bdAddExtraGrp
def bdAddExtraGrp(nameMaskCon,grpType,empty):
controllers = pm.ls(nameMaskCon,type = 'transform')
conPyNodes = []
for con in controllers:
conPyNodes.append(con)
for node in conPyNodes:
if empty:
pm.select(cl=True)
conGrp = pm.group(name = node.name() + '_' + grpType)
pos = node.getTranslation(space='world')
rot = node.getRotation(space='world')
conGrp.setTranslation(pos)
conGrp.setRotation(rot)
parent = node.getParent()
pm.parent(conGrp,parent)
else:
conGrp = pm.duplicate(node,name = node.name().replace('CON',grpType))
'''
for axis in ['X','Y','Z']:
conGrp[0].attr('translate' + axis).setKeyable(True)
conGrp[0].attr('translate' + axis).setLocked(False)
'''
conGrpRelatives = pm.listRelatives(conGrp,ad = True)
#print sdkConRelatives
pm.delete(conGrpRelatives)
pm.parent(node,conGrp)
示例12: removeBindPose
def removeBindPose(cls, skin_node):
"""
[email protected] Remove BindPose of SkinCluster
:rtype: bool
:return: True if bindPose is deleted
"""
# Check
if isinstance(skin_node, basestring):
skin_node = pmc.PyNode(skin_node)
if isinstance(skin_node, pmc.nodetypes.SkinCluster):
raise RuntimeError("\n\tThis node -- %s -- is not a SkinCluster !!!\n" % skin_node.name())
# Get BindPose
bindpose_node = self.SKIN_NODE.inputs(type='dagPose')
if not bindpose_node:
raise RuntimeError("\n\tSkinCluster doesn't have bindPose !!!\n")
# Remove
pmc.delete(bindpose_node)
return True
示例13: checkTwoSkin
def checkTwoSkin(cls, skin_from, skin_to):
"""
[email protected] Check two skin. If skin_to is different of skin_from delete it and apply new skin
with same influences of skin_from.
:type skin_from: pymel.core.nodetypes.SkinCluster
:param skin_from: Skin reference for check
:type skin_to: pymel.core.nodetypes.SkinCluster
:param skin_to: Skin you want to check
:rtype: pymel.core.nodetypes.SkinCluster
:return: SkinCluster checked
"""
# Get influences
influences_ref = pmc.skinCluster(skin_from, query=True, influence=True)
influences_check = pmc.skinCluster(skin_to, query=True, influence=True)
# If is same return check skinCluster
if influences_check == influences_ref:
return skin_to
# If is not same apply new skin
skin_check_geo = pmc.skinCluster(skin_to, query=True, geometry=True)
pmc.delete(skin_to)
for geo in skin_check_geo:
skin_to = cls.skinFromOther(skin_from, geo)
return skin_to
示例14: duplicate_rigid_body
def duplicate_rigid_body(self):
self.bound_geo = pm.duplicate(self.rigid_body,
name= '%s_rb' % (self.rigid_body))[0]
shape_nodes = self.bound_geo.getShapes()
for shape_node in shape_nodes:
if 'rigidBody' in '%s' % (shape_node):
pm.delete(shape_node)
示例15: AlignBindNode
def AlignBindNode(self, **kws):
'''
Overwrite the default behaviour: Align the newly made BindNode as required for this bind
'''
#Parent the BindNode/UpVector Object to the upVectorParent Node
#Parent the AimLocator Object to the Source node -used to modify the AimPoint
pm.parent(self.BindNode['Root'], self.upVectorParent)
pm.parent(self.BindNode['Up'], self.upVectorParent)
pm.parent(self.BindNode['AimOffset'], self.SourceNode)
#self.BindNode['Root'].scale.set(self.Settings.BaseScale,self.Settings.BaseScale,self.Settings.BaseScale)
self.BindNode['Main'].rotateOrder.set(self.SourceNode.rotateOrder.get())
self.BindNode['Root'].rotateOrder.set(self.DestinationNode.rotateOrder.get())
#Aim Alignment
pm.aimConstraint(self.BindNode['AimOffset'], self.BindNode['Root'], aimVector=(0,1,0),upVector=(0,0,1),\
worldUpType="object",worldUpObject=self.BindNode['Up'])
#Positional Alignment
pm.delete(pm.pointConstraint(self.SourceNode, self.BindNode['AimOffset']))
pm.makeIdentity(self.BindNode['AimOffset'], apply=True, t=1, r=1, s=0)
pm.delete(pm.pointConstraint(self.upVectorParent, self.BindNode['Root']))
pm.makeIdentity(self.BindNode['Root'], apply=True, t=1, r=0, s=0)
pm.delete(pm.pointConstraint(self.upVectorParent, self.BindNode['Up']))
pm.makeIdentity(self.BindNode['Up'], apply=True, t=1, r=0, s=0)
pm.delete(pm.pointConstraint(self.DestinationNode, self.BindNode['Root']))
#Rotate Alignment
pm.delete(pm.orientConstraint(self.DestinationNode, self.BindNode['Main']))