def remove_attribute_from_node(self, node, attribute_name):
        """
        Add attribute to pynode and log success.
        """

        #check if attr exists on node
        if not (node.hasAttr(attribute_name)):

            #log
            self.logger.debug(
                'Node {0} does not have attr. {1}. Not removing attribute.'.
                format(node.name(), attribute_name))
            return

        try:

            #remove
            pm.deleteAttr(node, attribute=attribute_name)

            #log
            self.logger.debug('Removed attr: {0} from node {1}'.format(
                attribute_name, node.name()))

        except:

            #log
            self.logger.debug(
                'Removing of attr: {0} from node {1} failed'.format(
                    attribute_name, node.name()))
Exemplo n.º 2
0
def _removeNode(node):

    target = pmc.getAttr(node.bindTarget)
    pmc.deleteAttr(target.bindNode)
    pmc.deleteAttr(node.bindTarget)

    pmc.delete(node)
Exemplo n.º 3
0
    def setHierString(self, oldLimb):

        #delete old attribute if the limb name has changed
        if oldLimb != self.limb:
            if self.puppet.hasAttr('%s_hier' % oldLimb):
                pm.setAttr('%s.%s_hier' % (self.puppet, oldLimb), lock=False)
                pm.deleteAttr('%s.%s_hier' % (self.puppet, oldLimb))

        if self.puppet and self.limb:
            if not self.puppet.hasAttr('%s_hier' % self.limb):
                self.puppet.addTag('%s_hier' % self.limb)

            hierObj = hierInfo.HierInfo()

            hierObj.setHierValues(rootGroup=self._hierarchyAttrList[0],
                                  localGroup=self._hierarchyAttrList[1],
                                  worldGroup=self._hierarchyAttrList[2],
                                  localPosition=self._hierarchyAttrList[3])

            #unlock string
            pm.setAttr('%s.%s_hier' % (self.puppet, self.limb), lock=False)
            pm.setAttr('%s.%s_hier' % (self.puppet, self.limb),
                       hierObj.toJson(),
                       type='string')
            pm.setAttr('%s.%s_hier' % (self.puppet, self.limb), lock=True)
def set_attribute_order(node, attrs):
    """
    Set the order of all user attributes on node.
    
    attrs should contain all user attributes.  If any are missing from the list,
    they'll end up at the top.
    
    This can't be undone.
    """
    # Sanity check the attribute list before making any changes.
    for attr in reversed(attrs):
        attr = node.attr(attr)
    
    with maya_helpers.restores() as restores:
        # Make sure undo is enabled.
        restores.append(maya_helpers.SetAndRestoreCmd(pm.undoInfo, key='state', value=True))
        
        # Deleting an attribute and undoing the deletion pushes an attribute to the end of
        # the list.
        for attr in attrs:
            # For some reason, Maya won't delete a locked attribute.
            attr = node.attr(attr)
            locked = pm.getAttr(attr, lock=True)
            if locked:
                pm.setAttr(attr, lock=False)

            pm.deleteAttr(attr)
            pm.undo()

            if locked:
                pm.setAttr(attr, lock=True)
    def remove_attribute_from_node(self, node, attribute_name):
        """
        Add attribute to pynode and log success.
        """

        #check if attr exists on node
        if not(node.hasAttr(attribute_name)):
            
            #log
            self.logger.debug('Node {0} does not have attr. {1}. Not removing attribute.'.format(node.name(), attribute_name))
            return

        try:
            
            #remove
            pm.deleteAttr(node, attribute = attribute_name)

            #log
            self.logger.debug('Removed attr: {0} from node {1}'.format(attribute_name,
                                                                    node.name()))

        except:

            #log
            self.logger.debug('Removing of attr: {0} from node {1} failed'.format(attribute_name,
                                                                                node.name()))
Exemplo n.º 6
0
def poseMark(*args):
	##!FIXME: add a prefix to save poses for multiple names
	oblist = makeList(args, type='joint')

	for root in oblist:
		chain = getChain(root)
		for item in chain:
			for attr in [ x for x in item.listAttr(ud=True) if x.count('.default_') ]:
				if attr.getParent() is not None:
					## skip children of compound attributes-- they vanish with their parents
					## and cause an error otherwise
					continue
				pm.deleteAttr(attr)

			worldMat = pm.dt.Matrix(pm.xform(item, q=True, ws=True, matrix=True))
			m = om.MTransformationMatrix( worldMat.asMatrix() )

			scale = item.scale.get()
			rot = pm.dt.Quaternion(m.rotation())
			trans = pm.dt.Vector(m.translation(om.MSpace.kWorld))
			
			setAttrSpecial(item, 'default_scale', scale, type='float3', channelBox=False)
			setAttrSpecial(item, 'default_rotationV', [rot.x, rot.y, rot.z], type='float3', channelBox=False)
			setAttrSpecial(item, 'default_rotationW', rot.w, type='float', channelBox=False)
			setAttrSpecial(item, 'default_translation', trans, channelBox=False)

			##!FIXME: temporary fix until I get the channelBox flag working in setAttrSpecial
			for attr in [ 'default_scale', 'default_rotationV', 'default_rotationW', 'default_translation' ]:
				attr = item.attr(attr)
				attr.set(k=False)
				attr.set(cb=False)
				if attr.isCompound() or attr.isMulti():
					for child in attr.getChildren():
						child.set(k=False)
						child.set(cb=False)
Exemplo n.º 7
0
def removeModulator(attr):
    '''
    node = pm.ls(sl=True)[0]
    attr = node.rz
    '''
    inPlug = attr.inputs(p=True)[0]

    toDelete = []
    if type(inPlug.node()) is pm.nt.UnitConversion:
        toDelete.append(inPlug)
        inPlug = inPlug.node().input.inputs(p=True)[0]

    # assume inPlug's node is an adl or mdl
    # input1 is the original connection
    origPlug = inPlug.node().input1.inputs(p=True)[0]
    # input2 is the modulation attr
    modPlug = inPlug.node().input2.inputs(p=True)[0]

    # restore orig connection
    origPlug >> attr

    # delete unwanted nodes
    pm.delete(inPlug.node(), toDelete)

    # remove mod attr
    pm.deleteAttr(modPlug)
Exemplo n.º 8
0
    def update_attrs(self, func, status):

        attrs = self.exp_json[func]["attrs"]

        if status:

            for attr, attrType in attrs.items():

                if not pc.attributeQuery(
                        attr, node=self.nparticle.name(), exists=True):
                    pc.addAttr(self.nparticle.name(), ln=attr, dt=attrType)
                    pc.addAttr(self.nparticle.name(),
                               ln=("%s0" % attr),
                               dt=attrType)

        else:

            for attr, attrType in attrs.items():

                if pc.attributeQuery(attr,
                                     node=self.nparticle.name(),
                                     exists=True):

                    if len(
                            pc.listConnections(
                                "%s.%s" % (str(self.nparticle), attr))) == 0:

                        pc.deleteAttr(self.nparticle.name(), at=attr)
                        pc.deleteAttr(self.nparticle.name(), at=("%s0" % attr))

                    else:

                        pc.warning(
                            "Can't remove Attribute:%s(Function:%s), which is being used."
                            % (attr, func))
Exemplo n.º 9
0
	def del_Attr(self):
		cur_Items = self.ui.attr_listView.selectedItems()
		for each in cur_Items:
			cur_item = each.text()
			pm.setAttr(self.ui.object_name.text() +'.'+ cur_item, l = False)
			pm.deleteAttr(self.ui.object_name.text() +'.'+ cur_item)
		self.load_Object()
Exemplo n.º 10
0
def deleteShotSculptFrame():

    if editState == True:
        editSculptFrame()

    ssn = pm.optionMenu("selectedSSNode_menu", q=True, v=True)
    bshps = pm.getAttr(ssn + '.bshps')
    frame = pm.textScrollList("SculptLayers_tsl", q=True, si=True)

    result = pm.confirmDialog(title='Delete Sculpt-Frame',
                              message='Are you sure you want to delete ' +
                              frame[0] + "?",
                              button=['Yes', 'No'],
                              defaultButton='Yes',
                              cancelButton='No',
                              dismissString='No')

    if result == 'Yes':
        pm.deleteAttr(ssn + '.' + frame[0])

        pm.textScrollList("SculptLayers_tsl", e=True, ri=str(frame[0]))

        for bshp in bshps:
            ##mel command: blendShapeDeleteTargetGroup + bshp + index
            index = getIndexByName(bshp, frame[0])

            #remove the alias
            pm.aliasAttr(bshp + '.' + frame[0], remove=True)
            ##delete the target
            pm.removeMultiInstance(bshp + '.weight[' + str(index) + ']',
                                   b=True)
Exemplo n.º 11
0
def remove_io(*args):
    """
    Removes IO from the robot it's attached to by deleting all of
    its attributes. The io controller and models are preserved.
    This function just breaks the connection between the robot and the io
    controller
    :param args: required by Maya to call a function from UI button required by Maya UI
    :return:
    """

    # Get the selected item from the Mimic UI
    selection = pm.textScrollList('tsl_ios', selectItem=True, query=True)[0]

    # Split the selection into the robot's name and the IO name
    robot_str, io_name = selection.split(': ')
    pm.select(robot_str)
    robot = mimic_utils.get_robot_roots()[0]

    target_CTRL = mimic_utils.get_target_ctrl_path(robot)

    parent_attribute = '{}.io_{}'.format(target_CTRL, io_name)

    # Delete IO attribute on the robot controller
    pm.deleteAttr(parent_attribute)

    # Clear the io from the Mimic UI selection and reset the UI
    pm.textScrollList('tsl_ios', edit=True, removeItem=selection)
    if not pm.textScrollList('tsl_ios', query=True, numberOfItems=True):
        reset_io_UI()

    pm.select(target_CTRL)
    pm.headsUpMessage('IO \'{}\' removed successfully from {}'.format(
        io_name, robot))
Exemplo n.º 12
0
def remove_external_axis(*args):
    """
    Removes external axis from the robot it's attached to by deleting all of
    its attributes. The axis controller and models are preserved.
    This function just breaks the connection between the robot and the axis
    :param *args: required by Maya UI
    :return:
    """

    # Get the selected item from the Mimic UI
    selection = pm.textScrollList('tsl_externalAxes',
                                  selectItem=True,
                                  query=True)[0]

    # Split the selection into the robot's name and the external axis name
    robot, axis_name = selection.split(': ')

    target_CTRL = '{}|robot_GRP|target_CTRL'.format(robot)

    parent_attribute = '{}.externalAxis_{}'.format(target_CTRL, axis_name)

    # Remove connections between the axis controller and the robot
    external_axis_attribute_path = target_CTRL + '.' + axis_name
    external_axis_CTRL, driving_attribute = _get_external_axis_connections(
        external_axis_attribute_path)
    driving_axis = driving_attribute[-1]
    # Prep transformation string for Maya's limit attributes
    if 'translate' in driving_attribute:
        driving_attribute_trunc = 'Trans'
    else:
        driving_attribute_trunc = 'Rot'
    _enable_external_axis_limits(external_axis_CTRL,
                                 driving_attribute_trunc,
                                 driving_axis,
                                 enable=False)

    # Delete External Axis attribute on the robot controller
    pm.deleteAttr(parent_attribute)

    # Clear the axis from the Mimic UI selection and reset the UI
    pm.textScrollList('tsl_externalAxes',
                      edit=True,
                      removeItem=selection)
    if not pm.textScrollList('tsl_externalAxes',
                             query=True,
                             numberOfItems=True):
        reset_external_axis_UI()

    '''
    # NEEDS Attention. This deletes parent constraint even if the axis
    # being removed isn't the one the robot is attached to
    if _check_if_robot_is_attached_to_external_axis(robot):
        pm.delete('{}|robot_GRP|local_CTRL|' \
                  'localCTRL_externalAxisCTRL_parentConstraint'
                  .format(robot))
        pm.setAttr('{}|robot_GRP|local_CTRL.visibility'.format(robot), 1)
    '''

    pm.headsUpMessage('External Axis \'{}\' removed successfully from {}'
                      .format(axis_name, robot))
Exemplo n.º 13
0
def removeModulator(attr):
    '''
    node = pm.ls(sl=True)[0]
    attr = node.rz
    '''
    inPlug = attr.inputs(p=True)[0]
    
    toDelete = []
    if type(inPlug.node()) is pm.nt.UnitConversion:
        toDelete.append(inPlug)
        inPlug = inPlug.node().input.inputs(p=True)[0]
        
    # assume inPlug's node is an adl or mdl
    # input1 is the original connection
    origPlug = inPlug.node().input1.inputs(p=True)[0]
    # input2 is the modulation attr
    modPlug = inPlug.node().input2.inputs(p=True)[0]
    
    # restore orig connection
    origPlug >> attr
    
    # delete unwanted nodes
    pm.delete(inPlug.node(), toDelete)
    
    # remove mod attr
    pm.deleteAttr(modPlug)
Exemplo n.º 14
0
Arquivo: swc.py Projeto: loichuss/maya
def __SWCresetData__(objSWC):
    # get all data at once
    data = []
    data.append(objSWC.def_jointName.get())
    data.append(objSWC.def_jointArray.get())
    data.append(objSWC.def_normalize.get())
    
    # delete jointArray if exist
    if (objSWC.hasAttr('jointArray')):
        pmc.deleteAttr(objSWC.jointArray)
    # create current extra attribut
    __SWCaddExtraAttribut__(objSWC, '', data[0])
    
    # copy data
    # jointName
    attr = pmc.PyNode(objSWC+'.jointName')
    attr.set(data[0])
    attr = pmc.PyNode(objSWC+'.def_corJointName')
    attr.set(data[0])

    # normalization
    attr = pmc.PyNode(objSWC+'.normalize')
    attr.setLocked(False)
    attr.set(data[2])
    attr.setLocked(True)
    
    # jointArray
    for i in range(0, len(data[1])):
        attr = pmc.PyNode(objSWC+'.jointArray.'+data[0][i])
        attr.set(data[1][i])
Exemplo n.º 15
0
    def remove_cache_tag(self, *args):
        selection = pm.selected()
        if selection:
            for obj in selection:
                try:
                    if pm.objExists(obj + ".arc_renderable"):
                        pm.deleteAttr(obj, at='arc_renderable')
                        self.log.insertText("  %s%s\n" %('Remove arc_renderable Tag'.ljust(40, "."), obj))
                except:
                    self.log.insertText("  %s%s\n" %('Unable To Remove arc_renderable Tag'.ljust(40, "."), obj))                    

                try:                    
                    self.cacheSet.remove(obj)
                    self.tempSet.add(obj)
                except:
                    pass
                                
#===============================================================================
# 
# class CheckGeoTags(Check):
#     def __init__(self):
#         super(CheckGeoTags, self).__init__()
#         
#         self.main_button_label = "Geometry Tags"
#         self.options_label = "Geo Tags Options"
#         self.options = True
#         
#     def check(self, *args):
#         status = True
#         objs = []
#         log = "Checking Geometry Tags... \n"
# 
#         pm.select('md', hi=True)
#         all_geos = pm.ls(sl=True, type='mesh')
# 
#         attrs = ['objectName', 'arc_full_path', 'arc_master_path', 'tagName', 'arc_renderable']
# 
#         for geo in all_geos:
#             for attr in attrs:
#                 geo_attr = '%s.%s'%(geo, attr)
#                 if not pm.objExists(geo_attr):
#                     log += "  %s%s\n"%(geo_attr.ljust(40, '.'), "FAIL")
#                     status = False
#                     if geo not in objs:
#                         objs.append(geo)
# 
#         return [status, objs, log]
# 
#     def options_buttons(self, *args):
#         pm.button(label = "Add Tag", c=self.add_control_tag)
#         
#     def add_control_tag(self, *args):
#         selection = pm.selected()
#         if selection:
#             for obj in selection:
#                 pm.addAttr(obj, ln='ClientAnimCtrl', at="bool")
#                 print "Added ClientAnimCtrl tag to %s" %obj        
#         
#         
#===============================================================================
Exemplo n.º 16
0
    def associate(self):
        """ Create Message attributes for each joint, and connect to all other joints. """

        # Create compound attribute to store hierarchy connection in,
        for joint in self.joints:

            # If already present, delete the attribute to recreate it,
            if joint.nodeName() + '.limb' in joint.listAttr():
                pm.deleteAttr(joint, attribute='limb')

            # Create the attribute, make sure top and end has size 1,
            pm.addAttr(
                joint,
                longName='limb',
                attributeType='compound',
                numberOfChildren=1 if
                (joint == self.joints[0] or joint == self.joints[-1]) else 2,
            )

        # Create attributes to connect parent child onto,
        for parent, child in zip(self.joints[:-1], self.joints[1:]):
            pm.addAttr(child,
                       longName='limbParent',
                       attributeType='message',
                       parent='limb')
            pm.addAttr(parent,
                       longName='limbChild',
                       attributeType='message',
                       parent='limb')

        # Make connections, apparently can't make it work inside same loop as creation.
        for parent, child in zip(self.joints[:-1], self.joints[1:]):
            pm.connectAttr(parent.message, child.limbParent)
            pm.connectAttr(child.message, parent.limbChild)
Exemplo n.º 17
0
    def setBuildString(self, oldLimb):

        #delete old attribute if the limb name has changed
        if oldLimb != self.limb:
            if self.puppet.hasAttr('%s_build' % oldLimb):
                pm.setAttr('%s.%s_build' % (self.puppet, oldLimb), lock=False)
                pm.deleteAttr('%s.%s_build' % (self.puppet, oldLimb))

        if self.puppet and self.limb:
            if not self.puppet.hasAttr('%s_build' % self.limb):
                self.puppet.addTag('%s_build' % self.limb)

            buildObj = buildInfo.BuildInfo()
            buildObj.setBuildValues(compType=self.compType,
                                    startJoint=self._componentAttrList[0],
                                    endList=self._componentAttrList[3],
                                    name=self._componentAttrList[1],
                                    side=self._componentAttrList[2])

            #unlock string
            pm.setAttr('%s.%s_build' % (self.puppet, self.limb), lock=False)
            pm.setAttr('%s.%s_build' % (self.puppet, self.limb),
                       buildObj.toJson(),
                       type='string')
            pm.setAttr('%s.%s_build' % (self.puppet, self.limb), lock=True)
Exemplo n.º 18
0
def bdAttrMoveUp(attr):
	print 'Moving %s attr up'%attr
	attrList = bdGetAttrList()
	attrIndex = 0
	for a in attrList:
		if attr in a.name():
			attrIndex = attrList.index(a)

	attrReconstruct = attrList[(attrIndex-1):]
	attrReconstructConnections = []
	attrReconstructValues = []
	attrReconstructType = []
	attrReconstructRange = []


	for attr in attrReconstruct:
		attrConnections = pm.listConnections('%s'%attr,plugs=1)
		attrReconstructConnections.append(attrConnections)
		
		attrValue = bdGetValue(attr)
		attrReconstructValues.append(attrValue)
		
		attrType = attr.type()
		attrReconstructType.append(attrType)
		
		attrRange = attr.getRange()
		attrReconstructRange.append(attrRange)
	

	shiftItem = attrReconstruct.pop(1)
	attrReconstruct.insert(0,shiftItem)

	shiftItem = attrReconstructConnections.pop(1)
	attrReconstructConnections.insert(0,shiftItem)

	shiftItem = attrReconstructValues.pop(1)
	attrReconstructValues.insert(0,shiftItem)

	shiftItem = attrReconstructType.pop(1)
	attrReconstructType.insert(0,shiftItem)

	shiftItem = attrReconstructRange.pop(1)
	attrReconstructRange.insert(0,shiftItem)
	'''
	i = 0
	for attr in attrReconstruct:
		print attr.name()
		print attrReconstructConnections[i]
		print attrReconstructValues[i]
		print attrReconstructType[i]
		print attrReconstructRange[i]
		i += 1

	'''
	for attr in attrReconstruct:
		try:
			pm.deleteAttr(attr)
		except:
			pm.warning('Fail to delete %s'%attr.name())
Exemplo n.º 19
0
def addOutputAttrs(node):
    try:
        pmc.deleteAttr(node.outMatrix)
    except:
        print 'attributes to delete not found'

    pmc.select(node)
    pmc.addAttr(ln='outMatrix', at='matrix', multi=1)
Exemplo n.º 20
0
 def matteIdDetach_PB_hit(self):
     self.createMatteAttrNode()
     mesh_list = self.getSelMeshList()
     attr_name, matteIdColor, attr_node = self.checkMatteIdData()
     for mesh in mesh_list:
         exists = pm.attributeQuery(attr_name, node=mesh, ex=True)
         if exists is True:
             pm.deleteAttr(mesh, at=attr_name)
Exemplo n.º 21
0
 def _removeOrigTrans( self, args ):
     '''This function does removes the orig trans attribute.
     :param name: The name to use
     :returns: int -- the return code.
     '''
     for arg in args:
         if (pm.objExists(arg+'.origTrans')):
             pm.deleteAttr(arg+'.origTrans')
             print "OrigTrans detected and removed on object %s" % (arg)
Exemplo n.º 22
0
    def deleteAllTags(self):
        if self.masters_all is None:
            self.masters_all = self.findAllAssets()

        for m in self.masters_all:
            if pm.attributeQuery(self.attribute, node=m, exists=True):
                # delete visible tag
                pm.deleteAttr(m, attribute=self.attribute)
        return
Exemplo n.º 23
0
def bdAttrMoveUp(attr):
    print 'Moving %s attr up' % attr
    attrList = bdGetAttrList()
    attrIndex = 0
    for a in attrList:
        if attr in a.name():
            attrIndex = attrList.index(a)

    attrReconstruct = attrList[(attrIndex - 1):]
    attrReconstructConnections = []
    attrReconstructValues = []
    attrReconstructType = []
    attrReconstructRange = []

    for attr in attrReconstruct:
        attrConnections = pm.listConnections('%s' % attr, plugs=1)
        attrReconstructConnections.append(attrConnections)

        attrValue = bdGetValue(attr)
        attrReconstructValues.append(attrValue)

        attrType = attr.type()
        attrReconstructType.append(attrType)

        attrRange = attr.getRange()
        attrReconstructRange.append(attrRange)

    shiftItem = attrReconstruct.pop(1)
    attrReconstruct.insert(0, shiftItem)

    shiftItem = attrReconstructConnections.pop(1)
    attrReconstructConnections.insert(0, shiftItem)

    shiftItem = attrReconstructValues.pop(1)
    attrReconstructValues.insert(0, shiftItem)

    shiftItem = attrReconstructType.pop(1)
    attrReconstructType.insert(0, shiftItem)

    shiftItem = attrReconstructRange.pop(1)
    attrReconstructRange.insert(0, shiftItem)
    '''
    i = 0
    for attr in attrReconstruct:
        print attr.name()
        print attrReconstructConnections[i]
        print attrReconstructValues[i]
        print attrReconstructType[i]
        print attrReconstructRange[i]
        i += 1

    '''
    for attr in attrReconstruct:
        try:
            pm.deleteAttr(attr)
        except:
            pm.warning('Fail to delete %s' % attr.name())
Exemplo n.º 24
0
def delHair(dType='all', keepHair=False):
    ''' delete Hair with Controls or Control only'''
    sel = pm.selected()
    newAttr = ['lengthDivisions', 'widthDivisions']
    hairInfoAll = selHair(returnInfo=True)
    if not hairInfoAll:
        return
    Cgroups = [h[1] for h in hairInfoAll]
    hairMeshes = [h[0][0] for h in hairInfoAll]
    if not keepHair:
        pm.delete(hairMeshes)
        pm.delete(Cgroups)
    else:
        if dType == 'all':
            for hair in hairMeshes:
                pm.select(hair, r=1)
                selHair(setPivot=True)
                pm.xform(hair,
                         ws=1,
                         piv=pm.xform(Cgroups[hairMeshes.index(hair)],
                                      q=1,
                                      ws=1,
                                      piv=1)[:3])
                pm.delete(hair, ch=True)
                lockTransform(hair, lock=False)
                for a in newAttr:
                    if pm.attributeQuery(a, exists=1, node=hair):
                        pm.deleteAttr(hair + "." + a)
            pm.delete(Cgroups)
        elif dType == 'self' or dType == 'above' or dType == 'below':
            for ob in sel:
                ctrls = Cgroups[sel.index(ob)].listRelatives(
                    type=pm.nt.Transform)
                if ctrls.count(ob):
                    if dType == 'self' or ctrls.index(ob) == 0 or ctrls.index(
                            ob) == (len(ctrls) - 1):
                        if ctrls.index(ob) == 0:
                            pm.scale(ctrls[1], [0.001, 0.001, 0.001], a=1)
                        elif ctrls.index(ob) == (len(ctrls) - 1):
                            pm.scale(ctrls[-2], [0.001, 0.001, 0.001], a=1)
                        pm.delete(ob)
                    elif dType == 'above':
                        pm.delete(ctrls[ctrls.index(ob) + 1:])
                        pm.scale(ctrls[ctrls.index(ob)], [0.001, 0.001, 0.001],
                                 a=1)
                    elif dType == 'below':
                        pm.delete(ctrls[:ctrls.index(ob)])
                        pm.scale(ctrls[ctrls.index(ob)], [0.001, 0.001, 0.001],
                                 a=1)
            for hair in hairMeshes:
                pm.select(hair)
                selHair(rebuild=[
                    True,
                    hair.attr('lengthDivisions').get(),
                    hair.attr('widthDivisions').get()
                ])
Exemplo n.º 25
0
def delBoolAttr(*args):
    floatAttrName = pm.textFieldGrp( 'boolText', q = True, text = True ).split(' ')
    pm.pickWalk( d = "down" )
    selected = pm.ls(sl=1,long=1)
    for member in selected:
        for i in floatAttrName:
            if pm.attributeQuery( "mtoa_constant_" + i, node = member, exists = True ):
                pm.deleteAttr(member + '.mtoa_constant_' + i)
            else:
                print 'attribute ' + i + ' not exist!'
Exemplo n.º 26
0
def remove_attr(obj, attr_name):
    '''
    Remove an attribute from an object by name

    Args:
        obj (PyNode): The object to remove the attribute from
        attr_name (string): The name of the attribute to remove
    '''
    if (does_attr_exist(obj, attr_name) == True):
        pm.deleteAttr(obj, at=attr_name)
Exemplo n.º 27
0
def delColorAttr(colorField):
    attrName = colorField.getText().split(' ')
    pm.pickWalk(d="down")
    sel = pm.ls(sl=1, long=1)
    for m in sel:
        for i in attrName:
            if pm.attributeQuery("mtoa_constant_" + i, node=m, exists=True):
                pm.deleteAttr(m + '.mtoa_constant_' + i)
            else:
                print 'attribute ' + i + ' not exist!'
Exemplo n.º 28
0
def delColorAttr(colorField):
    attrName = colorField.getText().split(' ')
    pm.pickWalk( d = "down" )
    sel = pm.ls(sl=1,long=1)
    for m in sel:
        for i in attrName:
            if pm.attributeQuery( "mtoa_constant_" + i, node = m, exists = True ):
                pm.deleteAttr(m + '.mtoa_constant_' + i)
            else:
                print 'attribute ' + i + ' not exist!'
Exemplo n.º 29
0
def doDelAttrAOV(*args):
    if( isSelEmpty() and isObjType() == False ):
        return 0
    
    for obj in sel:
        if( obj.hasAttr(prefixAOV+'Id') ):
            pm.deleteAttr( obj, attribute=prefixAOV+'Id' )
        if( obj.hasAttr(prefixAOV+'idcolor') ):
            pm.deleteAttr( obj, attribute=prefixAOV+'idcolor' )
            
    return 1
Exemplo n.º 30
0
def pruneUnused():
    if not objExists('|main'):
        return

    shape = get()

    groups = existingGroups()
    for g in groups:
        attr = shape + '.' + g
        if not listConnections(attr):
            deleteAttr(attr)
Exemplo n.º 31
0
def clearMirrorNode(node):
    """Remove mirror node meta data from the given node.

    Args:
        node (pm.PyNode): Name of node to remove data from.

    Returns:
        None
    """
    if mirrorData.hasMirrorData(node):
        pm.deleteAttr(node.attr(mirrorData.MIRROR_DATA_ATTR_NAME))
Exemplo n.º 32
0
def delBoolAttr(*args):
    floatAttrName = pm.textFieldGrp('boolText', q=True, text=True).split(' ')
    pm.pickWalk(d="down")
    selected = pm.ls(sl=1, long=1)
    for member in selected:
        for i in floatAttrName:
            if pm.attributeQuery("mtoa_constant_" + i,
                                 node=member,
                                 exists=True):
                pm.deleteAttr(member + '.mtoa_constant_' + i)
            else:
                print 'attribute ' + i + ' not exist!'
Exemplo n.º 33
0
def pruneUnused():
    ''' Removes unused vis groups.
    '''
    shapeNode = get(create=False)
    if not shapeNode:
        return

    groups = existingGroups()
    for g in groups:
        attr = shapeNode + '.' + g
        if not listConnections(attr):
            deleteAttr(attr)
Exemplo n.º 34
0
def delete_attr(name='enterName'):
    """
    deleteAttr [summary]
    
    :param name: [description], defaults to 'enterName'
    :type name: str, optional
    """
    sel = pm.selected()
    attr_name = name
    for i in sel:
        pm.deleteAttr(i, at=attr_name)
    sys.__stdout__.write(str(attr_name) + '完成しました!' + '\n')
    print('\n' + str(attr_name) + ' == 削りました!' + '\n')
Exemplo n.º 35
0
    def removeButton(self, *args):
        try:
            get = self.ui.sources_listWidget.selectedItems()
            for s in get:
                obj = pm.PyNode(s.text())
                obj.visibility.set(0)
                pm.deleteAttr(obj, at='sources__')
                self.ui.sources_listWidget.takeItem(
                    self.ui.sources_listWidget.row(s))

            self.ui.sources_listWidget.sortItems(QtCore.Qt.AscendingOrder)
        except:
            raise
            pass
Exemplo n.º 36
0
	def transfer_Attr(self):
		cur_Items = self.ui.attr_listView.selectedItems()
		sel_Obj = self.ui.object_name.text()
		new_Obj = pm.selected()[0]
		for each in cur_Items:
			self.add_Attr(sel_Obj,each.text(),new_Obj)
			state = self.copy_Attr_State(sel_Obj, each.text())
			if self.ui.transfer_connections_Check.isChecked():
				self.connect_input(sel_Obj,each.text(),new_Obj)
				self.connect_output(sel_Obj,each.text(),new_Obj)
			self.set_Attr_State(each.text(), new_Obj,state)
			if self.ui.delete_Source_Check.isChecked():
				pm.setAttr(sel_Obj + '.' + each.text(), k = True, l = False, cb = True)
				pm.deleteAttr(sel_Obj + '.' + each.text())
Exemplo n.º 37
0
	def move_Down(self):
		cur_item = self.ui.attr_listView.selectedItems()[0].text()
		cur_index = self.attr_List.index(cur_item)
		self.attr_List[cur_index] =  self.attr_List[cur_index + 1]
		self.attr_List[cur_index + 1] = cur_item
		self.ui.attr_listView.clear()
		for each in self.attr_List:
			lock = pm.getAttr(self.ui.object_name.text() +'.'+ each, l = True)
			pm.setAttr(self.ui.object_name.text() +'.'+ each, l = False)
			pm.deleteAttr(self.ui.object_name.text() +'.'+ each)
			pm.undo()
			pm.setAttr(self.ui.object_name.text() +'.'+ each, l = lock)

		self.ui.attr_listView.addItems(self.attr_List)
		self.ui.attr_listView.setCurrentRow( cur_index + 1 )
Exemplo n.º 38
0
    def remove_control_tag(self, *args):
        selection = pm.selected()
        if selection:
            for obj in selection:
                try:
                    if pm.objExists(obj + ".ClientAnimCtrl"):                    
                        pm.deleteAttr(obj, at='ClientAnimCtrl')
                        self.log.insertText("  %s%s\n" %('Remove ClientAnimCtrl Tag'.ljust(40, "."), obj))
                except:
                    self.log.insertText("  %s%s\n" %('Unable To Remove ClientAnimCtrl Tag'.ljust(40, "."), obj))

                try:
                    self.controlSet.remove(obj)
                    self.tempSet.add(obj)
                except:
                    pass                                                        
    def removeSetup(self):
        def breakConnection(sel='', attributes=['v']):
            """
            Break Connection
            @param attributes : list of different attribute:  ['tx','ty','tz','rx','ry','rz','sx','sy','sz', 'v']

            The default value is : ['v']
            """

            for att in attributes:
                attr = sel + '.' + att

                destinationAttrs = pm.listConnections(
                    attr, plugs=True, source=False) or []
                sourceAttrs = pm.listConnections(
                    attr, plugs=True, destination=False) or []

                for destAttr in destinationAttrs:
                    pm.disconnectAttr(attr, destAttr)
                for srcAttr in sourceAttrs:
                    pm.disconnectAttr(srcAttr, attr)

        for jnt in self.jointList:
            breakConnection(jnt, attributes=('sx', 'sy', 'sz'))
            [pm.setAttr('{}.{}'.format(jnt, attr)) for attr in ('sx', 'sy', 'sz')]

        [pm.deleteAttr("{}.{}".format(self.ExpCtrl, attr)) for attr in ('ExpA', 'ExpB', 'ExpC')]
        pm.delete(self.MOD_GRP)
        [pm.delete(node) for node in self.nodeData]
Exemplo n.º 40
0
def up_down_attribute(up=False, down=False):
    """

    Args:
        up: Set the selected attribute go up 1 index in the main channel box
        down: Set the selected attribute go down 1 index in the main channel box

    Returns: Relocation of selected attribute in main channel box

    """
    selections = pm.ls(sl=True)
    if len(selections) != 1:
        return om.MGlobal.displayError("This function only work with one object per time")

    selection = selections[0]

    selected_attr = pm.channelBox("mainChannelBox", query=True, selectedMainAttributes=True)
    list_attr = pm.listAttr(selection, userDefined=True, locked=True)

    if len(list_attr) > 0:
        for attr in list_attr:
            pm.setAttr("{0}.{1}".format(selection, attr), lock=False)

    if down:
        if len(selected_attr) > 1:
            selected_attr.reverse()
            sort = selected_attr
        if len(selected_attr) == 1:
            sort = selected_attr
        for i in sort:
            attr_list = pm.listAttr(selection, userDefined=True)
            attr_list_size = len(attr_list)
            attr_position = attr_list.index(i)
            pm.deleteAttr(selection, attribute=attr_list[attr_position])
            pm.undo()

            for x in range(attr_position + 2, attr_list_size, 1):
                pm.deleteAttr(selection, attribute=attr_list[x])
                pm.undo()

    if up:
        for i in selected_attr:
            attr_list = pm.listAttr(selection, userDefined=True)
            attr_list_size = len(attr_list)
            attr_position = attr_list.index(i)
            if attr_list[attr_position - 1]:
                pm.deleteAttr(selection, attribute=attr_list[attr_position - 1])
                pm.undo()
            for x in range(attr_position + 1, attr_list_size, 1):
                pm.deleteAttr(selection, attribute=attr_list[x])
                pm.undo()

    if len(list_attr) > 0:
        for attr in list_attr:
            pm.setAttr("{0}.{1}".format(selection, attr), lock=True)

    sys.stdout.write("Complete.\n")
Exemplo n.º 41
0
def holdAttr(attr):
    data = {
        'node': attr.node(),
        'longName': attr.longName(),
        'shortName': attr.shortName(),
        'niceName': pymel.attributeName(attr),
        'inputs': attr.inputs(plugs=True),
        'outputs': attr.outputs(plugs=True),
        'isMulti': attr.isMulti(),
        'type': attr.type(),
        'locked': attr.isLocked(),
        'keyable': attr.isKeyable(),
        'hidden': attr.isHidden()
    }

    pymel.deleteAttr(attr)
    return data
Exemplo n.º 42
0
def remove_attr(node, attr_name, debug=False):
    """
    Remove the given attribute from the given node

    :param node: (PyMel Node) The object that needs to be its attribute deleted.
    :param attr_name: (Str) Name of the attribute to be deleted from the object.
    :param debug: (Boolean) Set True if you want to print out the result.
    """

    if node.hasAttr(attr_name):
        pm.deleteAttr(node, at=attr_name)
        if debug:
            logging.info("'{}' attribute was deleted from {}".format(
                attr_name, node))
    else:
        logging.warning("'{}' has no attribute called '{}'".format(node,
                                                                   attr_name))
Exemplo n.º 43
0
def holdAttr(attr):
    data = {
        'node':attr.node(),
        'longName':attr.longName(),
        'shortName':attr.shortName(),
        'niceName': pymel.attributeName(attr),
        'inputs':attr.inputs(plugs=True),
        'outputs':attr.outputs(plugs=True),
        'isMulti': attr.isMulti(),
        'type': attr.type(),
        'locked': attr.isLocked(),
        'keyable': attr.isKeyable(),
        'hidden': attr.isHidden()
    }

    pymel.deleteAttr(attr)
    return data
Exemplo n.º 44
0
def safeDeleteAttr(attr, **kwargs):
	if not isinstance(attr, pm.PyNode):
		try:
			attr = pm.PyNode(attr)
		except:
			# raise ValueError('safeDeleteAttr: Attribute does not exist: %s.' % attr)
			return

	## skip deleting child attributes-- it doesn't work and they 
	## vanish with their parents anyway
	if attr.getParent() is None:
		inputs = attr.inputs(plugs=True)
		attr.set(lock=False)

		if len(inputs):
			for inp in inputs:
				inp // attr

		pm.deleteAttr(attr)
Exemplo n.º 45
0
Arquivo: swc.py Projeto: loichuss/maya
def __SWCestimateReattribut__(objSWC):
    bonesNameOld   = objSWC.def_jointName.get()
    bonesNameNew   = objSWC.jointName.get()
    bonesWgt       = objSWC.def_jointArray.get()
    iteSim         = {}
    wgts           = []
    bonesNameClean = []
    
    # find if a bones has multiple copy
    forbide = []
    for i in range(0, len(bonesNameNew)):
        tmp = []
        if (i in forbide)== False:
            for j in range(0, len(bonesNameNew)):
                if (bonesNameNew[j]==bonesNameNew[i]):
                    tmp.append(j)
            forbide.extend(tmp)
            iteSim[i] = tmp
    
    # calculate weight
    for ite in iteSim:
        # name according to new weight
        bonesNameClean.append(bonesNameNew[ite])
        # copy the array
        wgt = bonesWgt[iteSim[ite][0]]
        # if the joint has more than one new destination
        if len(iteSim[ite]) > 1:
            for i in range(1, len(iteSim[ite])):
                for j in range(0, len(wgt)):
                    wgt[j] += bonesWgt[iteSim[ite][i]][j]
        wgts.append(wgt)

    # change jointName by an array without double
    objSWC.jointName.set(bonesNameClean)
    
    # delete jointArray to create a new one with the right name and number of children
    pmc.deleteAttr(objSWC.jointArray)
    __SWCaddExtraAttribut__(objSWC, '', bonesNameClean)
    for i in range(0, len(bonesNameClean)):
        attr = pmc.PyNode(objSWC+'.jointArray.'+bonesNameClean[i])
        attr.set(wgts[i])
Exemplo n.º 46
0
 def setAttributes(self, cmd):
     print "AttibuteManager:setAttributes command", cmd
     
     if cmd == "assignSelected":
         attributeSelected = pm.treeView(self.objectTree, query=True, si = True)
         if not attributeSelected or len(attributeSelected) == 0:
             print "No attr selected"
             return
         
         # It is possible to select the parent Menu entry or the child. 
         # I need the parent entry to decide if is a mesh, light or other type
         # and the attribute itself
         print "Selected attributes:", attributeSelected
         leafAttributes = []
         typeList = []
         for att in attributeSelected:
             if not pm.treeView(self.objectTree, query=True, il = att):
                 children =  pm.treeView(self.objectTree, query=True, ch = att)
                 if children and len(children) > 1:
                     #print "Children of ", att, children
                     leafAttributes.extend(children[1:])
             else:
                 #print "Att", att, "is leaf"
                 leafAttributes.append(att)
         leafAttributes = list(set(leafAttributes))
         print "LeafAttributes", leafAttributes
         for leaf in leafAttributes:
             parent =  pm.treeView(self.objectTree, query=True, ip = leaf)
             typeList.append(parent)
         
         selection = pm.ls(sl=True)
         relatives = pm.listRelatives(ad=True) # give me all children
         print "selection", relatives
         for element in relatives:
             print "Check", element, element.type()
             eType = element.type()
             if eType == 'mesh':
                 for att in leafAttributes:
                     if att in mantra_node_attributes['mesh']:
                         print "Adding attribute to mesh", element
                         if att == 'Render As Subdiv':
                             if not element.hasAttr('mtm_renderAsSubdiv'):
                                 element.addAttr('mtm_renderAsSubdiv', at='bool')
             if 'Light' in eType:
                 for att in leafAttributes:
                     if att in mantra_node_attributes['light']:
                         print "Adding attribute to light", element
                         if att == 'Sampling Quality':
                             if not element.hasAttr('mtm_samplingQuality'):
                                 element.addAttr('mtm_samplingQuality', at='float')
         for element in selection:
             if element.type() in ['lambert', 'phong', 'phongE', 'blinn']:
                 for att in leafAttributes:
                     if att in mantra_node_attributes['shader']:
                         print "Adding attribute to shader", element
                         if att == 'Reflection Options':
                             if not element.hasAttr('mtm_reflBlur'):
                                 element.addAttr('mtm_reflBlur', at='float')
                             if not element.hasAttr('mtm_reflSamples'):
                                 element.addAttr('mtm_reflSamples', at='long')
                         if att == 'Refraction Options':
                             if not element.hasAttr('mtm_refrBlur'):
                                 element.addAttr('mtm_refrBlur', at='float')
                             if not element.hasAttr('mtm_refrSamples'):
                                 element.addAttr('mtm_refrSamples', at='long')
                 
             
         
         pm.select(selection)
         
     if cmd == "removeSelected":
         selection = pm.ls(sl=True)
         relatives = pm.listRelatives(ad=True) # give me all children
         if relatives:
             for a in relatives:
                 attrs = pm.listAttr(a, ud=True, leaf=False, sn=False, string="mtm_*")
                 for att in attrs:
                     pm.deleteAttr(a, at=att)
         for a in selection:
             attrs = pm.listAttr(a, ud=True, leaf=False, sn=False, string="mtm_*")
             for att in attrs:
                 pm.deleteAttr(a, at=att)
                 
         
     if cmd == "removeAllAttr":
         all = pm.ls()
         attrList = []
         for a in all:
             attrs = pm.listAttr(a, ud=True, leaf=False, sn=False, string="mtm_*")
             for att in attrs:
                 pm.deleteAttr(a, at=att)
Exemplo n.º 47
0
 def __delattr__(self, key):
     super(Wrapper, self).__delattr__(key)
     key = self._compose(key)
     attr = self.obj.attr(key)
     if attr:
         pm.deleteAttr(attr)
Exemplo n.º 48
0
 def delete_interface(self):
     """Destroy the attributes on the network input and output hubs. Used for interface changes."""
     for attr_holder, attr_name, attr_kwargs in self.iter_interface_infos():
         if attr_holder.hasAttr(attr_name):
             pymel.deleteAttr(attr_holder, attribute=attr_name)