コード例 #1
0
ファイル: mesh.py プロジェクト: arubertoson/maya-mamtools
def detach(extract=False):
    """
    Extracts or duplicate selected polygon faces.
    """
    selected = mampy.complist()
    if not selected:
        raise InvalidSelection('Detach only works on edge and polygon components.')
    else:
        control = selected[0]
        if control.type not in [MFn.kMeshPolygonComponent, MFn.kMeshEdgeComponent]:
            raise InvalidSelection('Detach only works on edges and polygons.')

    new = ComponentList()
    for comp in selected:

        node = Node(comp.dagpath)
        name = '{}_{}'.format(node.transform.short_name, 'ext' if extract else 'dup')
        cmds.duplicate(str(comp.dagpath), n=name)

        # Delete unwanted children from duplicate hierarchy
        dupdag = Node(name)
        for child in dupdag.iterchildren():
            if child.type == MFn.kTransform:
                cmds.delete(str(child))

        if extract:
            cmds.polyDelFacet(comp.cmdslist())

        dupcomp = MeshPolygon.create(dupdag.dagpath).add(comp.indices)
        cmds.polyDelFacet(dupcomp.toggle().cmdslist())

        cmds.hilite(str(dupdag))
        new.append(dupcomp.get_complete())
    cmds.select(new.cmdslist(), r=True)
コード例 #2
0
ファイル: others.py プロジェクト: elanifegnirf/Snippets
def transfertSelection():
	"""
	This definition transfers a component selection to another object.
	
	:return: Definition succes. ( Boolean )
	"""

	selection = cmds.ls(sl=True, long=True)

	targetObject = str()
	for item in selection:
		if "." not in item:
			targetObject = item
			break

	if targetObject != "":
		cmds.hilite(targetObject, replace=True)
		cmds.selectMode(component=True)
		nextSelection = []
		for item in selection:
			if item != targetObject:
				if "." in item:
					itemTokens = item.split(".")
					nextSelection.append(targetObject + "." + itemTokens[1])
		nextSelection and cmds.select(nextSelection)
	return True
コード例 #3
0
ファイル: isolate.py プロジェクト: arubertoson/maya-mamselect
def set_isolate_set(selected):
    set_name = get_isolate_set_name()
    # Trying to hide visible children in hierarchy to get wanted isolate
    # behavior.
    for sel in selected:
        for child in sel.iterchildren():
            if child in selected or not child.type == MFn.kTransform:
                continue
            # Only work on visible children
            if child.attr['visibility']:
                child.attr['visibility'] = False
                HIDDEN_CHILDREN.add(child)

    hilited = DagpathList(
        [dag for dag in mampy.daglist(hl=True) if dag not in selected]
    )
    if hilited:
        cmds.hilite(hilited.cmdslist(), toggle=True)
        # In case the dag object was a child of unhilited object rehilite it.
        for dag in selected:
            cmds.hilite(str(dag))

    if not set_name:
        for dag in selected:
            cmds.isolateSelect(get_active_panel(), addDagObject=str(dag))
        return

    cmds.sets(clear=set_name)
    cmds.sets(selected.cmdslist(), include=set_name)
コード例 #4
0
def transfertSelection():
    """
	Transfers a component selection to another object.
	
	:return: Definition succes.
	:rtype: bool
	"""

    selection = cmds.ls(sl=True, long=True)

    targetObject = ""
    for item in selection:
        if "." not in item:
            targetObject = item
            break

    if targetObject != "":
        cmds.hilite(targetObject, replace=True)
        cmds.selectMode(component=True)
        nextSelection = []
        for item in selection:
            if item != targetObject:
                if "." in item:
                    itemTokens = item.split(".")
                    nextSelection.append(targetObject + "." + itemTokens[1])
        nextSelection and cmds.select(nextSelection)
    return True
コード例 #5
0
ファイル: masks.py プロジェクト: arubertoson/maya-mamselect
def set_mask(*masks):
    """Set selection masks in maya.

    if the current mask is the given mask toggle object component mode. This is the
    default mode maya uses when switching selection masks. You will be able to continue
    selecting components but also select other objects as maya objects.

    Usage:

        set_mask('vertex', 'controlVertex', 'latticePoint')
        set_mask('meshComponents')

    """
    component_masks = {mask: True for mask in masks}
    if (cmds.selectMode(q=True, component=True) and
            any(cmds.selectType(q=True, **{mask: True}) for mask in component_masks.iterkeys())):
        cmds.selectMode(object=True)
        cmds.selectType(ocm=True, alc=False)
        cmds.selectType(ocm=True, **component_masks)
        cmds.selectType(**component_masks)
        cmds.hilite(mampy.daglist().cmdslist())
    else:
        cmds.selectMode(component=True)
        cmds.selectType(allComponents=False)
        cmds.selectType(**component_masks)
コード例 #6
0
ファイル: masks.py プロジェクト: arubertoson/maya-mamselect
def exit_tool_and_mask():
    """Exit current tool or toggle selection mode.

    When working with other contexts in maya use this function to exit the current
    context and return to selection context; if you are using base tools ('select',
    move, rotate, scale) toggle selection mode instead.

    Usage:

        tool_select()

    """
    # base_tools = ['{}SuperContext'.format(i) for i in ('select', 'move', 'rotate', 'scale')]
    if not cmds.currentCtx() == 'selectSuperContext':
        cmds.setToolTo('selectSuperContext')
    else:
        if cmds.selectMode(q=True, object=True):
            hilited = mampy.daglist(hl=True)
            if hilited:
                cmds.hilite(hilited.cmdslist(), toggle=True)
                cmds.select(hilited.cmdslist())
            else:
                cmds.selectMode(component=True)
        else:
            cmds.selectMode(object=True)
コード例 #7
0
    def run(self,*args):

        name = mc.textFieldGrp(self.name, q=True, tx=True)
        joint = mc.intSliderGrp(self.joint, q=True, v=True)
        obj = mc.ls(sl=True, o=True)

        if name == '':
            print 'ERROR!!'
            return

        for i in obj:
            mc.select(i)
            if mc.objectType(i) == 'mesh':
                mc.hilite(i)
                curves = mc.polyToCurve(usm=False, f=2, dg=1)
            else:
                curves = mc.duplicate(rr=True)
            if mc.checkBoxGrp(self.reverse, q=True, v1=True):
                mc.reverseCurve()
            
            joints = []
            for j in range(joint):
                mc.select(cl=True)
                joints.append(mc.joint(n=name))
            
            mc.select(mc.ls(joints, curves,  tr=True))
            apg.positionAlongCurve()

            for j in range(joint - 1):
                mc.parent(joints[j + 1], joints[j])
                mc.joint(joints[j], e=True, zso=True, oj='xyz', sao='yup')
                if j == joint - 2:
                    mc.rename(joints[j + 1], name + '_end')
            mc.delete(curves)
        mc.select(cl=True)
コード例 #8
0
 def setHighlight(self, state):
     if not self.targetGeom:
         return
     if state:
         m.hilite(self.targetGeom, replace=True)
     else:
         m.hilite(self.targetGeom, unHilite=True)
コード例 #9
0
ファイル: mayaCommands.py プロジェクト: tbttfox/MeshCrawler
def selectVerts(obj, idx):
    cmds.selectType(objectComponent=True, allComponents=False)
    cmds.selectType(objectComponent=True, vertex=True)
    cmds.selectType(vertex=True)
    cmds.hilite(obj)
    if idx is not None:
        cmds.select('pSphere1.vtx[{0}]'.format(idx), replace=True)
コード例 #10
0
ファイル: selection.py プロジェクト: auqeyjf/glTools
def disableObjectVertexSelection(item):
	'''
	Disable vertex selection for specified object
	@param item: Object to switch selection mode for
	@type item: str
	'''
	# Hilite item
	mc.hilite(item,u=1)
コード例 #11
0
ファイル: selection.py プロジェクト: jonntd/glTools
def disableObjectVertexSelection(item):
    '''
	Disable vertex selection for specified object
	@param item: Object to switch selection mode for
	@type item: str
	'''
    # Hilite item
    mc.hilite(item, u=1)
コード例 #12
0
ファイル: selection.py プロジェクト: bennymuller/glTools
def disableObjectVertexSelection(item):
    """
    Disable vertex selection for specified object
    @param item: Object to switch selection mode for
    @type item: str
    """
    # Hilite item
    cmds.hilite(item, u=1)
コード例 #13
0
ファイル: selection.py プロジェクト: bennymuller/glTools
def disableObjectVertexSelection(item):
    """
    Disable vertex selection for specified object
    @param item: Object to switch selection mode for
    @type item: str
    """
    # Hilite item
    cmds.hilite(item, u=1)
コード例 #14
0
def face_extraction(faces=None, deleteOrg=True, selectDuplicated=True, transferWeight=True):
    '''
    メッシュを選択したフェイスで切り分ける
    deleteOrg 切り分け元のフェイスを削除するかどうかを指定デフォルトTrue
    faces → 外部ツールからフェイスのリストを渡して実行したい場合の引数
    '''
    if faces is None:
        selection = cmds.ls(sl=True)
    else:
        selection = faces
    selObjects = []
    for sel in selection:
        objNameTemp = sel.split('.')
        if not objNameTemp[0] in selObjects:
            selObjects.append(objNameTemp[0])

    cmds.select(cl=True)
    duplicated = []  # 最後の選択格納用
    # ハイライトされているオブジェクト毎に処理
    for selObj in selObjects:
        compTemp = []  # バラバラのコンポーネントをオブジェクト毎に格納するリスト
        # 選択されているコンポーネントを整理
        for sel in selection:
            objNameTemp = sel.split('.')
            objName = objNameTemp[0]  # コンポーネントのオブジェクト名
            # オブジェクト名が一致且つフェイス選択ならリスト入り
            if selObj == objName and '.f[' in sel:
                compTemp.append(sel)
        # print('compTemp ALL : '+str(compTemp))
        if len(compTemp) != 0:
            dupObj = cmds.duplicate(selObj, rr=True)
            # 子供のオブジェクト取得関数呼び出し
            children = cmds.listRelatives(dupObj[0], type='transform', ad=True)
            # 子供のオブジェクトがある場合は重複を避けるため削除
            if children:
                cmds.delete(children)
            duplicated.append(dupObj[0])
            if transferWeight:  # ウェイト転送フラグが有効だったら
                weight.transfer_weight(selObj, dupObj, logTransfer=False)  # ウェイトを転送
            faces = ",".join(compTemp)  # リストを括弧のない文字列に
            faces = faces.replace(selObj, dupObj[0])  # 名前置き換え
            delface = faces.split(',')
            cmds.selectMode(co=True)
            cmds.hilite(dupObj)
            cmds.select(delface, r=True)
            #print('del face :',delface)
            for obj in dupObj:
                face_count = str(len(common.conv_comp(obj, mode='face')))
                cmds.select(obj+'.f[0:'+face_count+']', tgl=True)
            #mel.eval('InvertSelection;')  # 選択の反転
            deleter = cmds.ls(sl=True)
            cmds.delete(deleter)  # 最初に選択されていなかったフェース部分のみ削除
            # 削除フラグが立っていたら古いフェイス削除
            if deleteOrg is True:
                cmds.delete(compTemp)
    if selectDuplicated:
        cmds.select(duplicated)
    return duplicated
コード例 #15
0
ファイル: mesh.py プロジェクト: arubertoson/maya-mamselect
def deselect_all_but():
    preselect = mampy.complist(preSelectHilite=True)
    obj = get_object_under_cursor()
    if not obj:
        return

    cmds.select(obj, r=True)
    if not preselect:
        return
    else:
        cmds.hilite(obj, toggle=True)
コード例 #16
0
ファイル: utils.py プロジェクト: lazerdaze/lancer
 def undoableWrapper(*args, **kargs):
     selection = cmds.ls(sl=True, fl=True)
     highlight = cmds.ls(hl=True, fl=True)
     try:
         return function(*args, **kargs)
     finally:
         if selection:
             cmds.select(selection)
         else:
             cmds.select(clear=True)
         if highlight:
             cmds.hilite(highlight)
コード例 #17
0
 def result(*args,**kargs):
     selection = cmds.ls(sl=True,fl=True)
     highlight = cmds.ls(hl=True,fl=True)
     try:
         result = function(*args,**kargs)
     finally:
         if selection:
             cmds.select(selection)
         else:
             cmds.select(clear=True)
         if highlight:
             cmds.hilite(highlight)
コード例 #18
0
 def selectVtx(self):
     vtxList = cmds.textScrollList('vtxList_JellyBean', q=1, si=1)
     if not vtxList:
         cmds.select(cmds.polyListComponentConversion(self.saveShape, ff=1, fe=1, fuv=1, fvf=1, tv=1), r=1)
         cmds.hilite(self.saveShape)
         return
     if not '.' in vtxList[0]:
         _shapeN = cmds.text('shapeInfo_JellyBean', q=1, l=1)
         vtxList = ['%s.%s' % (_shapeN, i) for i in vtxList]
     else:
         _shapeN = cmds.ls(vtxList[0], o=1)
     cmds.hilite(_shapeN)
     cmds.select(vtxList, r=1)
コード例 #19
0
	def on_selectVerts( self, *a ):
		selJoints = self.UI_tsl.getSelectedItems()
		if not selJoints:
			return

		verts = []
		for j in selJoints:
			verts += meshUtils.jointVertsForMaya( j )

		if verts:
			cmd.hilite( [ self._mesh ] )
			cmd.select( verts )
			mel.artAttrSkinToolScript( 4 )
コード例 #20
0
ファイル: skinWeightsUI.py プロジェクト: yazici/zootoolbox
    def on_selectVerts(self, *a):
        selJoints = self.UI_tsl.getSelectedItems()
        if not selJoints:
            return

        verts = []
        for j in selJoints:
            verts += meshUtils.jointVertsForMaya(j)

        if verts:
            cmd.hilite([self._mesh])
            cmd.select(verts)
            mel.artAttrSkinToolScript(4)
コード例 #21
0
ファイル: selection.py プロジェクト: jonntd/glTools
def enableObjectVertexSelection(item):
    '''
	Enable vertex selection for specified object
	@param item: Object to switch selection mode for
	@type item: str
	'''
    # Hilite item
    mc.hilite(item)
    # Get item type
    itemType = mc.objectType(mc.listRelatives(item, s=1, ni=1)[0])
    # Set selection mode
    if itemType == 'mesh':
        mc.selectType(ocm=1, vertex=1)
    if itemType == 'nurbsSurface' or itemType == 'nurbsCurve':
        mc.selectType(ocm=1, controlVertex=1)
コード例 #22
0
ファイル: SelectHelper.py プロジェクト: jonntd/Tapp
    def replaceHighlight(newHiglightItems):
        selection = SelectHelper.getSelectionDagPaths(False)
        hilite = SelectHelper.getSelectionDagPaths(True)

        # include selected objects that were in previous hilite
        newHilite = [i for i in hilite if i in selection]
        newHilite.extend(newHiglightItems)

        # remove previous hilite
        if len(hilite) > 0:
            cmds.hilite(hilite, u=True)

        # set new hilite
        if len(newHilite) > 0:
            cmds.hilite(newHilite, r=True)
コード例 #23
0
ファイル: selection.py プロジェクト: auqeyjf/glTools
def enableObjectVertexSelection(item):
	'''
	Enable vertex selection for specified object
	@param item: Object to switch selection mode for
	@type item: str
	'''
	# Hilite item
	mc.hilite(item)
	# Get item type
	itemType = mc.objectType(mc.listRelatives(item,s=1,ni=1)[0])
	# Set selection mode
	if itemType == 'mesh':
		mc.selectType(ocm=1,vertex=1)
	if itemType == 'nurbsSurface' or itemType == 'nurbsCurve':
		mc.selectType(ocm=1,controlVertex=1)
コード例 #24
0
ファイル: SelectHelper.py プロジェクト: jonntd/ngSkinTools
    def replaceHighlight(newHiglightItems):
        selection = SelectHelper.getSelectionDagPaths(False)
        hilite = SelectHelper.getSelectionDagPaths(True)

        # include selected objects that were in previous hilite
        newHilite = [i for i in hilite if i in selection]
        newHilite.extend(newHiglightItems)

        # remove previous hilite
        if len(hilite) > 0:
            cmds.hilite(hilite, u=True)

        # set new hilite
        if len(newHilite) > 0:
            cmds.hilite(newHilite, r=True)
コード例 #25
0
ファイル: mesh.py プロジェクト: arubertoson/maya-mamselect
def toggle_mesh_under_cursor():
    """Toggle mesh object under cursor."""
    preselect = mampy.complist(preSelectHilite=True)
    if not preselect:
        under_cursor_mesh = get_object_under_cursor()
        if under_cursor_mesh is None:
            return
        node = Node(under_cursor_mesh)
        if cmds.selectMode(q=True, component=True):
            cmds.hilite(str(node.transform))
        else:
            cmds.select(str(node), toggle=True)
    else:
        node = preselect.pop().mdag
        if node.transform in mampy.daglist(hl=True):
            cmds.hilite(str(node.transform), unHilite=True)
コード例 #26
0
def straightenVertsFromUI():
    """
    Straighten Vertices From UI
    """
    # Get Edge Selection
    sel = cmds.ls(sl=True, fl=True)
    edges = cmds.filterExpand(sel, ex=True, sm=32)
    verts = cmds.filterExpand(sel, ex=True, sm=31)
    if not edges and verts:
        cmds.select(verts)
        mel.eval('ConvertSelectionToContainedEdges')
        edges = cmds.filterExpand(ex=True, sm=32)
    if not edges:
        print('Select a list of connected vertices or edges and run again...')
        return

    # Get Mesh from vertices
    mesh = cmds.ls(edges, o=True)

    # Get UI Parameters
    falloff = cmds.floatSliderGrp('straightenVerts_falloffFSG',
                                  q=True,
                                  value=True)
    edgeSpacing = cmds.checkBoxGrp('straightenVerts_edgeSpacingCBG',
                                   q=True,
                                   v1=True)
    snapToOrig = cmds.checkBoxGrp('straightenVerts_snapToOrigCBG',
                                  q=True,
                                  v1=True)
    delHistory = cmds.checkBoxGrp('straightenVerts_deleteHistoryCBG',
                                  q=True,
                                  v1=True)

    # Straighten Vertices
    straightenVerts(edgeList=edges,
                    falloff=falloff,
                    keepEdgeSpacing=edgeSpacing,
                    snapToOriginal=snapToOrig,
                    deleteHistory=delHistory)

    # Restore Selection
    if sel:
        cmds.selectMode(component=True)
        cmds.selectType(edge=True)
        cmds.hilite(mesh)
        cmds.select(edges)
コード例 #27
0
ファイル: char.py プロジェクト: ewerybody/melDrop
def createJointAtPoint(radius=30):
    sel = cmds.ls(sl=1)
    hi = cmds.ls(hilite=1)[0]
    vtx = cmds.filterExpand(sm=31)
    pos = [0.0,0.0,0.0]
    for v in vtx:
        p = cmds.xform(v, q=1, t=1, ws=1)
        for i in range(3):
            pos[i] = pos[i] + p[i]
    for i in range(3):
        pos[i] = pos[i] / len(vtx)
    cmds.select(d=1)
    cmds.joint(p=pos, radius=radius)
    cmds.isolateSelect('modelPanel4',addSelected=1)
    cmds.select(hi)
    cmds.hilite(replace=1)
    cmds.selectType(ocm=1,vertex=1)
コード例 #28
0
def UvLose(*args):
    global display7
    global selection, ulface
    cmds.select(selection)
    NameList_Uvlose = []
    cmd = r'polyCleanupArgList 4 { "0","2","0","0","0","0","0","0","0","1e-05","0","1e-05","1","0","0","-1","0","0"  };'
    result = mm.eval(cmd)
    ulface = cmds.ls(sl=True)
    cmds.ConvertSelectionToShell()
    NameList = cmds.ls(sl=True)
    cmds.select(clear=1)
    cmds.hilite(replace=True)
    print ulface
    for i in NameList:
        NameList_Uvlose.append(i.split('.')[0].encode('utf8'))
    if len(NameList_Uvlose) != 0:
        display7 = 1
    return NameList_Uvlose
コード例 #29
0
def OverSides(*args):
    global selection
    global display3, osface
    cmds.select(selection)
    NameList_Os = []
    cmd = r'polyCleanupArgList 4 {"0","2","0","0","1","0","0","0","0","1e-05","0","1e-05","0","0","0","-1","0","0" }'
    result = mm.eval(cmd)
    osface = cmds.ls(sl=True)
    cmds.ConvertSelectionToShell()
    NameList = cmds.ls(sl=True)
    cmds.select(clear=1)
    cmds.hilite(replace=True)
    print osface
    for i in NameList:
        NameList_Os.append(i.split('.')[0].encode('utf8'))
    if len(NameList_Os) != 0:
        display3 = 1
    return NameList_Os
コード例 #30
0
def UVoverlap(*args):
    global selection
    global display8, UVolface
    cmds.select(selection)
    NameList_Uvoverlap = []
    cmds.ConvertSelectionToFaces()
    UVolface = cmds.polyUVOverlap(oc=True)
    cmds.select(UVolface)
    cmds.ConvertSelectionToShell()
    NameList = cmds.ls(sl=True)
    cmds.select(clear=1)
    cmds.hilite(replace=True)
    print UVolface
    for i in NameList:
        NameList_Uvoverlap.append(i.split('.')[0].encode('utf8'))
    if len(NameList_Uvoverlap) != 0:
        display8 = 1
    return NameList_Uvoverlap
コード例 #31
0
def evenEdgeSpacingFromUI():
    """
    Even Edge Spacing From UI
    """
    # Get Edge Selection
    sel = cmds.ls(sl=True, fl=True)
    edges = cmds.filterExpand(sel, ex=True, sm=32)
    verts = cmds.filterExpand(sel, ex=True, sm=31)
    if not edges and verts:
        cmds.select(verts)
        mel.eval('ConvertSelectionToContainedEdges')
        edges = cmds.filterExpand(ex=True, sm=32)
    if not edges:
        print('Select a list of connected vertices or edges and run again...')
        return

    # Get Mesh from vertices
    mesh = cmds.ls(edges, o=True)

    # Get UI Parameters
    smooth = cmds.intSliderGrp('evenEdgeSpacing_smoothISG', q=True, v=True)
    influence = cmds.floatSliderGrp('evenEdgeSpacing_influenceFSG',
                                    q=True,
                                    v=True)
    snapToOrig = cmds.checkBoxGrp('evenEdgeSpacing_snapToOrigCBG',
                                  q=True,
                                  v1=True)
    delHistory = cmds.checkBoxGrp('evenEdgeSpacing_deleteHistoryCBG',
                                  q=True,
                                  v1=True)

    # Even Edge Spacing
    evenEdgeSpacing(edgeList=edges,
                    smooth=smooth,
                    influence=influence,
                    snapToOrig=snapToOrig,
                    deleteHistory=delHistory)

    # Restore Selection
    if sel:
        cmds.selectMode(component=True)
        cmds.selectType(edge=True)
        cmds.hilite(mesh)
        cmds.select(edges)
コード例 #32
0
    def doCheck(self):

        # Clean out existing vars to start a new detection
        self.emptyUVs = []
        unMapLim = 0
        unMapCount = 0
        unMapRep = ''

        # Array for holding polygons and their faces
        polyHold = cmds.ls(geometry=True)
        faceHold = cmds.polyListComponentConversion(polyHold, tf=True)

        # Saving the selection and hilite states
        userHil = cmds.ls(hilite=True)
        userSel = cmds.ls(selection=True)

        # Selecting the faces for contraint
        cmds.select(faceHold)

        # Constraining the selection to any faces that are unmapped
        cmds.polySelectConstraint(mode=3, type=8, textured=2)
        self.emptyUVs = cmds.ls(selection=True)
        unMapLim = len(self.emptyUVs)

        # Clearing out the selections
        cmds.polySelectConstraint(disable=True)
        cmds.select(clear=True)

        # Counting up the faces found to be unmapped
        for i in range(0, unMapLim):
            cmds.select(self.emptyUVs[i])
            unMapCount += cmds.polyEvaluate(self.emptyUVs[i],
                                            faceComponent=True)

        # Restoring the original selection state
        cmds.selectType(allObjects=True)
        cmds.hilite(userHil)
        cmds.select(userSel)

        # Determining if any unmapped faces have been found and reporting
        if self.emptyUVs:
            unMapRep = '%d unmapped faces detected.' % (unMapCount)

        return unMapRep
コード例 #33
0
def floodReplace(comps, sm_dfrm):

    obj = str(comps[0]).split('.')[0]
    cmds.hilite(obj, replace=1)
    cmds.select(comps)

    mel.eval('artSetToolAndSelectAttr( "artAttrCtx", "softMod.{}.weights" );'.
             format(sm_dfrm))
    mel.eval('artAttrInitPaintableAttr;')
    mel.eval('artAttrValues artAttrContext;')
    mel.eval('artAttrPaintOperation artAttrCtx Replace;')
    mel.eval('artAttrCtx -e -opacity 1 `currentCtx`;')
    mel.eval('artAttrCtx -e -value 0 `currentCtx`;')
    cmds.select(comps)
    mel.eval('invertSelection;')
    mel.eval('artAttrCtx -e -clear `currentCtx`;')

    cmds.select(obj)
    mel.eval('SelectTool;')
コード例 #34
0
def floodSmooth(comps, sm_dfrm, smooth=3):

    obj = str(comps[0]).split('.')[0]
    cmds.select(obj)
    cmds.hilite(obj, replace=1)
    cmds.select('{}.vtx[*]'.format(obj))

    mel.eval('artSetToolAndSelectAttr( "artAttrCtx", "softMod.{}.weights" );'.
             format(sm_dfrm))
    mel.eval('artAttrInitPaintableAttr;')
    mel.eval('artAttrValues artAttrContext;')
    mel.eval('artAttrPaintOperation artAttrCtx Smooth;')
    mel.eval('artAttrCtx -e -opacity 1 `currentCtx`;')
    cmds.select('{}.vtx[*]'.format(obj))
    for i in range(smooth):
        mel.eval('artAttrCtx -e -clear `currentCtx`;')

    cmds.select(obj)
    mel.eval('SelectTool;')
コード例 #35
0
ファイル: straightenVerts.py プロジェクト: fsanges/glTools-1
def smoothEdgeLineFromUI():
    '''
	Smooth Edge Line From UI
	'''
    # Get Edge Selection
    sel = mc.ls(sl=True, fl=True)
    edges = mc.filterExpand(sel, ex=True, sm=32)
    verts = mc.filterExpand(sel, ex=True, sm=31)
    if not edges and verts:
        mc.select(verts)
        mm.eval('ConvertSelectionToContainedEdges')
        edges = mc.filterExpand(ex=True, sm=32)
    if not edges:
        print('Select a list of connected vertices or edges and run again...')
        return

    # Get Mesh from vertices
    mesh = mc.ls(edges, o=True)

    # Get UI Parameters
    smooth = mc.intSliderGrp('smoothEdges_smoothISG', q=True, v=True)
    falloff = mc.floatSliderGrp('smoothEdges_falloffFSG', q=True, v=True)
    edgeSpacing = mc.checkBoxGrp('smoothEdges_edgeSpacingCBG', q=True, v1=True)
    snapToOrig = mc.checkBoxGrp('smoothEdges_snapToOrigCBG', q=True, v1=True)
    delHistory = mc.checkBoxGrp('smoothEdges_deleteHistoryCBG',
                                q=True,
                                v1=True)

    # Smooth Edges
    smoothEdgeLine(edges,
                   smooth=smooth,
                   falloff=falloff,
                   snapToOrig=snapToOrig,
                   keepEdgeSpacing=edgeSpacing,
                   deleteHistory=delHistory)

    # Restore Selection
    if sel:
        mc.selectMode(component=True)
        mc.selectType(edge=True)
        mc.hilite(mesh)
        mc.select(edges)
コード例 #36
0
ファイル: modeling.py プロジェクト: shrimo/dmptools
def advanceMoveMulti():
    """
    same as advanceMove but with multicomponents enable
    """
    cmds.selectMode(object=True)
    selection = cmds.ls(sl=True)
    cmds.selectMode(component=True)
    cmds.selectMode(object=True)
    cmds.selectMode(component=True)
    for node in selection:
        cmds.delete(node, ch=True)
        cmds.selectType(meshComponents=True)
        cmds.hilite(node)
        cmds.select(clear=True)
        #mel.eval('dR_selTypeChanged("meshComponents");')

    activePanel = cmds.getPanel(withFocus=True)
    cmds.modelEditor(activePanel, e=True, manipulators=False)
    cmds.setToolTo('moveSuperContext')
    cmds.selectPref(clickDrag=True)
コード例 #37
0
def smoothEdgeLineFromUI():
    """
    Smooth Edge Line From UI
    """
    # Get Edge Selection
    sel = cmds.ls(sl=True, fl=True)
    edges = cmds.filterExpand(sel, ex=True, sm=32)
    verts = cmds.filterExpand(sel, ex=True, sm=31)
    if not edges and verts:
        cmds.select(verts)
        mel.eval('ConvertSelectionToContainedEdges')
        edges = cmds.filterExpand(ex=True, sm=32)
    if not edges:
        print('Select a list of connected vertices or edges and run again...')
        return

    # Get Mesh from vertices
    mesh = cmds.ls(edges, o=True)

    # Get UI Parameters
    smooth = cmds.intSliderGrp('smoothEdges_smoothISG', q=True, v=True)
    falloff = cmds.floatSliderGrp('smoothEdges_falloffFSG', q=True, v=True)
    edgeSpacing = cmds.checkBoxGrp('smoothEdges_edgeSpacingCBG', q=True, v1=True)
    snapToOrig = cmds.checkBoxGrp('smoothEdges_snapToOrigCBG', q=True, v1=True)
    delHistory = cmds.checkBoxGrp('smoothEdges_deleteHistoryCBG', q=True, v1=True)

    # Smooth Edges
    smoothEdgeLine(edges,
                   smooth=smooth,
                   falloff=falloff,
                   snapToOrig=snapToOrig,
                   keepEdgeSpacing=edgeSpacing,
                   deleteHistory=delHistory)

    # Restore Selection
    if sel:
        cmds.selectMode(component=True)
        cmds.selectType(edge=True)
        cmds.hilite(mesh)
        cmds.select(edges)
コード例 #38
0
	def on_selectIntersectingVerts( self, *a ):
		selJoints = self.UI_tsl.getSelectedItems()
		if not selJoints:
			return

		allVerts = []
		jointVerts = {}

		for j in selJoints:
			jointVerts[ j ] = verts = meshUtils.jointVertsForMaya( j )
			allVerts += verts

		allVerts = set( allVerts )

		commonVerts = []
		for j, jVerts in jointVerts.iteritems():
			commonVerts += allVerts.intersection( set( jVerts ) )

		if commonVerts:
			cmd.hilite( [ self._mesh ] )
			cmd.select( commonVerts )
			mel.artAttrSkinToolScript( 4 )
コード例 #39
0
def OpenEdge(*args):
    global selection
    global display5
    global opedge
    NameList_Oe = []
    cmds.select(selection)
    # 选择约束开放边
    pm.polySelectConstraint(where=1, type=0x8000, mode=3)
    opedge = cmds.ls(sl=True)
    print opedge
    cmds.ConvertSelectionToShell()
    NameList = cmds.ls(sl=True)
    # 重置约束
    cmd = r'resetPolySelectConstraint'
    result = mm.eval(cmd)
    cmds.select(clear=1)
    cmds.hilite(replace=True)
    for i in NameList:
        NameList_Oe.append(i.split('.')[0].encode('utf8'))
    if len(NameList_Oe) != 0:
        display5 = 1
    return NameList_Oe
コード例 #40
0
ファイル: skinWeightsUI.py プロジェクト: yazici/zootoolbox
    def on_selectIntersectingVerts(self, *a):
        selJoints = self.UI_tsl.getSelectedItems()
        if not selJoints:
            return

        allVerts = []
        jointVerts = {}

        for j in selJoints:
            jointVerts[j] = verts = meshUtils.jointVertsForMaya(j)
            allVerts += verts

        allVerts = set(allVerts)

        commonVerts = []
        for j, jVerts in jointVerts.iteritems():
            commonVerts += allVerts.intersection(set(jVerts))

        if commonVerts:
            cmd.hilite([self._mesh])
            cmd.select(commonVerts)
            mel.artAttrSkinToolScript(4)
コード例 #41
0
ファイル: straightenVerts.py プロジェクト: auqeyjf/glTools
def straightenVertsFromUI():
	'''
	Straighten Vertices From UI
	'''
	# Get Edge Selection
	sel = mc.ls(sl=True,fl=True)
	edges = mc.filterExpand(sel,ex=True,sm=32)
	verts = mc.filterExpand(sel,ex=True,sm=31)
	if not edges and verts:
		mc.select(verts)
		mm.eval('ConvertSelectionToContainedEdges')
		edges = mc.filterExpand(ex=True,sm=32)
	if not edges:
		print('Select a list of connected vertices or edges and run again...')
		return
	
	# Get Mesh from vertices
	mesh = mc.ls(edges,o=True)
	
	# Get UI Parameters
	falloff = mc.floatSliderGrp('straightenVerts_falloffFSG',q=True,value=True)
	edgeSpacing = mc.checkBoxGrp('straightenVerts_edgeSpacingCBG',q=True,v1=True)
	snapToOrig = mc.checkBoxGrp('straightenVerts_snapToOrigCBG',q=True,v1=True)
	delHistory = mc.checkBoxGrp('straightenVerts_deleteHistoryCBG',q=True,v1=True)
	
	# Straighten Vertices
	straightenVerts(	edgeList		= edges,
						falloff			= falloff,
						keepEdgeSpacing	= edgeSpacing,
						snapToOriginal	= snapToOrig,
						deleteHistory	= delHistory)
	
	# Restore Selection
	if sel:
		mc.selectMode(component=True)
		mc.selectType(edge=True)
		mc.hilite(mesh)
		mc.select(edges)
コード例 #42
0
ファイル: straightenVerts.py プロジェクト: auqeyjf/glTools
def evenEdgeSpacingFromUI():
	'''
	Even Edge Spacing From UI
	'''
	# Get Edge Selection
	sel = mc.ls(sl=True,fl=True)
	edges = mc.filterExpand(sel,ex=True,sm=32)
	verts = mc.filterExpand(sel,ex=True,sm=31)
	if not edges and verts:
		mc.select(verts)
		mm.eval('ConvertSelectionToContainedEdges')
		edges = mc.filterExpand(ex=True,sm=32)
	if not edges:
		print('Select a list of connected vertices or edges and run again...')
		return
	
	# Get Mesh from vertices
	mesh = mc.ls(edges,o=True)
	
	# Get UI Parameters
	smooth = mc.intSliderGrp('evenEdgeSpacing_smoothISG',q=True,v=True)
	influence = mc.floatSliderGrp('evenEdgeSpacing_influenceFSG',q=True,v=True)
	snapToOrig = mc.checkBoxGrp('evenEdgeSpacing_snapToOrigCBG',q=True,v1=True)
	delHistory = mc.checkBoxGrp('evenEdgeSpacing_deleteHistoryCBG',q=True,v1=True)
	
	# Even Edge Spacing
	evenEdgeSpacing(	edgeList		= edges,
						smooth			= smooth,
						influence		= influence,
						snapToOrig		= snapToOrig,
						deleteHistory	= delHistory )
	
	# Restore Selection
	if sel:
		mc.selectMode(component=True)
		mc.selectType(edge=True)
		mc.hilite(mesh)
		mc.select(edges)
コード例 #43
0
def rotateJoint(selectedJoint, rotX, rotY, rotZ, *args):
    selectedJoint = cmds.textField(selectedJoint, q=True, tx=True)
    rotX = cmds.textField(rotX, q=True, tx=True)
    rotY = cmds.textField(rotY, q=True, tx=True)
    rotZ = cmds.textField(rotZ, q=True, tx=True)

    if not selectedJoint:
        print "*Input the joint name"
        return

    if not rotX or not rotY or not rotZ:
        print "*Input the rotate values"
        return

    cmds.selectMode(object=True)
    cmds.hilite(selectedJoint)
    cmds.select(selectedJoint + '.rotateAxis', replace=True)
    cmds.rotate(rotX,
                rotY,
                rotZ,
                relative=True,
                objectSpace=True,
                forceOrderXYZ=True)
コード例 #44
0
ファイル: decorators.py プロジェクト: arubertoson/maya-mampy
    def __enter__(self):
        self.slist = cmds.ls(sl=True)
        self.hlist = cmds.ls(hl=True)

        if self.hlist:
            cmds.hilite(self.hlist, toggle=True)
コード例 #45
0
import maya.cmds as mc
import maya.mel as mel
oEdges = mc.ls(sl=True)
oObj = oEdges[0].split('.')[0]
oFace = ''
for i in oEdges:
    if '.f[' in i:
        oFace = i
mc.DetachComponent()
mc.select(cl=True)
mc.select(oFace)
mc.ConvertSelectionToShell()
oFacesFinal = mc.ls(sl=True)
mc.select(oObj)
mc.polyMergeVertex(d=0.0001)
mc.select(oFacesFinal)
mc.selectType(smp=0, sme=0, smf=1, smu=0, pv=0, pe=0, pf=1, puv=0)
mc.hilite(oObj, r=True)
mel.eval('doDelete;')
mc.select(oObj, r=True)
mc.polyCloseBorder()
コード例 #46
0
	def on_selectMesh( self, *a ):
		cmd.hilite( unHilite=True )
		cmd.select( self._mesh )
		mel.artAttrSkinToolScript( 4 )
コード例 #47
0
ファイル: mesh.py プロジェクト: RiggingDojoAdmin/glTools
def polyCleanup(
    meshList=[],
    quads=False,
    nonQuads=False,
    concave=False,
    holes=False,
    nonPlanar=False,
    laminaFace=False,
    nonManifold=False,
    zeroFaceArea=False,
    zeroEdgeLen=False,
    zeroMapArea=False,
    faceAreaTol=0.001,
    edgeLenTol=0.001,
    mapAreaTol=0.001,
    keepHistory=False,
    fix=False,
    printCmd=False,
):
    """
	Perform a check for various "bad" polygon geometry.
	@param meshList: List of meshes to operate on. If empty, operate on meshes in the current scene.
	@type meshList: list
	@param quads: Find all faces with 4 sides. Faces will be triangulated if fix=True.
	@type quads: bool
	@param nonQuads: Find all faces with more than 4 sides. Faces will be triangulated if fix=True.
	@type nonQuads: bool
	@param concave: Find all concave faces. Faces will be triangulated if fix=True.
	@type concave: bool
	@param holes: Find all holed faces. Faces will be triangulated if fix=True.
	@type holes: bool
	@param nonPlanar: Find all non-planar faces. Faces will be triangulated if fix=True.
	@type nonPlanar: bool
	@param laminaFace: Find all lamina faces (faces that share the same edges). Faces will be deleted if fix=True.
	@type laminaFace: bool
	@param nonManifold: Find all non-manifold geometry (edges connected to more than 2 faces).
	@type nonManifold: bool
	@param zeroFaceArea: Find polygon faces with zero surface area. Faces will be deleted if fix=True.
	@type zeroFaceArea: bool
	@param zeroLenFace: Find polygon edges with zero length. Edges will be deleted if fix=True.
	@type zeroLenFace: bool
	@param zeroMapArea: Find polygon faces with zero map (UV) area. Faces will be deleted if fix=True.
	@type zeroMapArea: bool
	@param faceAreaTol: Zero face area tolerance.
	@type faceAreaTol: float
	@param edgeLenTol: Zero edge length tolerance.
	@type edgeLenTol: float
	@param mapAreaTol: Zero map area tolerance.
	@type mapAreaTol: float
	@param keepHistory: Maintain cleanup history
	@type keepHistory: bool
	@param fix: Attempt to fix any bad geoemetry found.
	@type fix: bool
	"""
    # Check mesh list
    for mesh in meshList:
        if not mc.objExists(mesh):
            raise Exception('Mesh "' + mesh + '" does not exist!')

    if not meshList:
        allMeshes = 1
    else:
        allMeshes = 0
        mc.select(meshList)

        # Check fix
    if fix:
        selectOnly = 0
    else:
        selectOnly = 2

    # Check NonManifold
    if nonManifold:
        if fix:
            doNonManifold = 1
        else:
            doNonManifold = 2
    else:
        doNonManifold = -1

        # Build Poly Cleanup Command
    polyCleanupCmd = "polyCleanupArgList 3 {"
    polyCleanupCmd += '"' + str(allMeshes) + '",'  # [0]  - All selectable meshes
    polyCleanupCmd += '"' + str(selectOnly) + '",'  # [1]  - Perform selection only
    polyCleanupCmd += '"' + str(int(keepHistory)) + '",'  # [2]  - Keep construction history
    polyCleanupCmd += '"' + str(int(quads)) + '",'  # [3]  - Check for 4 sided faces
    polyCleanupCmd += '"' + str(int(nonQuads)) + '",'  # [4]  - Check for faces with more than 4 sides
    polyCleanupCmd += '"' + str(int(concave)) + '",'  # [5]  - Check for concave faces
    polyCleanupCmd += '"' + str(int(holes)) + '",'  # [6]  - Check for holed faces
    polyCleanupCmd += '"' + str(int(nonPlanar)) + '",'  # [7]  - Check for non-planar faces
    polyCleanupCmd += '"' + str(int(zeroFaceArea)) + '",'  # [8]  - Check for zero area faces
    polyCleanupCmd += '"' + str(faceAreaTol) + '",'  # [9]  - Tolerance for face area
    polyCleanupCmd += '"' + str(int(zeroEdgeLen)) + '",'  # [10] - Check for zero length edges
    polyCleanupCmd += '"' + str(edgeLenTol) + '",'  # [11] - Tolerance for edge length
    polyCleanupCmd += '"' + str(int(zeroMapArea)) + '",'  # [12] - Check for zero map area faces
    polyCleanupCmd += '"' + str(mapAreaTol) + '",'  # [13] - Tolerance for map area
    polyCleanupCmd += '"0",'  # [14] - Shared UVs (unused)
    polyCleanupCmd += '"' + str(doNonManifold) + '",'  # [15] - Check non-manifold geometry
    polyCleanupCmd += '"' + str(int(laminaFace)) + '"'  # [16] - Check lamina faces
    polyCleanupCmd += "};"

    # Perform Poly Cleanup
    mm.eval(polyCleanupCmd)
    if printCmd:
        print polyCleanupCmd

    # Generate return value
    result = mc.ls(sl=1)

    # Restore selection state
    if meshList:
        mc.select(meshList)
    else:
        mc.select(cl=True)
    hiliteList = mc.ls(hilite=True)
    if hiliteList:
        mc.hilite(hiliteList, tgl=False)

    # Return Result
    return result
コード例 #48
0
ファイル: sisidebar_sub.py プロジェクト: moChen0607/SISideBar
def set_reference(mode=''):
    c_ctx = cmds.currentCtx(q=True)
    #print c_ctx
    sel = cmds.ls(sl=True, l=True)
    #print 'set reference :', mode, sel
    current_ctx = cmds.currentCtx()
    if mode == 'object':
        #print 'set reference object mode :'
        cmds.selectMode(o=True)
        rot = cmds.xform(sel, q=True, ro=True, ws=True)
        pos = cmds.xform(sel, q=True, t=True, ws=True)
        rx = rot[0] / 180 * math.pi
        ry = rot[1] / 180 * math.pi
        rz = rot[2] / 180 * math.pi
        cmds.manipScaleContext('Scale', e=True, orientAxes=(rx, ry, rz))
        cmds.manipRotateContext('Rotate', e=True, orientAxes=(rx, ry, rz))
        cmds.manipMoveContext('Move', e=True, orientAxes=(rx, ry, rz))

        cmds.setToolTo('scaleSuperContext')  #マニプ表示がおかしくなるのでいったんコンテキスト設定してから戻す
        cmds.setToolTo('RotateSuperContext')
        cmds.setToolTo('moveSuperContext')
        cmds.setToolTo(current_ctx)
    else:
        if mode == 'vertex':
            manip_type = 'PointHandleTowards'
            comp = cmds.polyListComponentConversion(sel, tv=True)
            comp = cmds.filterExpand(comp, sm=31)
            sel_node = '" , "'.join(pre_sel)
            #print 'vertex ref :', sel_node, comp[0]
        if mode == 'edge':
            manip_type = 'AlignHandleWith'
            comp = cmds.polyListComponentConversion(sel, te=True)
            comp = cmds.filterExpand(comp, sm=32)
            sel_node = comp[0]
        if mode == 'face':
            manip_type = 'AlignHandleWith'
            comp = cmds.polyListComponentConversion(sel, tf=True)
            comp = cmds.filterExpand(comp, sm=34)
            sel_node = comp[0]
        if comp:
            mel.eval('manipScaleOrient 5;')
            mel.eval('{  string $Selection1[]; $Selection1[0] = "' + comp[0] +
                     '"; manipScale' + manip_type + '($Selection1[0], {"' +
                     sel_node + '"}, {}, "", 0);;  };')
            mel.eval('manipRotateOrient 5;')
            mel.eval('{  string $Selection1[]; $Selection1[0] = "' + comp[0] +
                     '"; manipRotate' + manip_type + '($Selection1[0], {"' +
                     sel_node + '"}, {}, "", 0);;  };')
            mel.eval('manipMoveOrient 5;')
            mel.eval('{  string $Selection1[]; $Selection1[0] = "' + comp[0] +
                     '"; manipMove' + manip_type + '($Selection1[0], {"' +
                     sel_node + '"}, {}, "", 0);;  };')
        cmds.selectMode(co=True)
        if pre_ref_mode == 'vertex':
            cmds.selectType(pv=1,
                            smu=0,
                            smp=1,
                            pf=0,
                            pe=0,
                            smf=0,
                            sme=0,
                            puv=0)
        if pre_ref_mode == 'edge':
            cmds.selectType(pv=0,
                            smu=0,
                            smp=0,
                            pf=0,
                            pe=1,
                            smf=0,
                            sme=1,
                            puv=0)
        if pre_ref_mode == 'face':
            cmds.selectType(pv=0,
                            smu=0,
                            smp=0,
                            pf=1,
                            pe=0,
                            smf=0,
                            sme=1,
                            puv=0)
        trans = cmds.xform(sel, q=True, t=True, ws=True)
        num = len(trans) / 3
        x = y = z = 0
        for i in range(0, len(trans), 3):
            x += trans[i]
            y += trans[i + 1]
            z += trans[i + 2]
        pos = [x / num, y / num, z / num]
        #sel_obj = []
        #obj_list = list(set([vtx.split('.')[0] for vtx in pre_sel]))
        #if obj_list:
        #sel_obj = [cmds.listRelatives(s, p=True)[0] if cmds.nodeType(s)=='mesh' else s for s in obj_list]
        #print obj_list, pre_sel
        #cmds.hilite(obj_list, r=True)
        #cmds.hilite(pre_sel, r=True)
    #print 'set to pre mode :', pre_ref_mode
    #print 'set to mode pre :', pre_ref_mode
    if pre_ref_mode == 'object':
        cmds.selectMode(o=True)
    else:
        cmds.selectMode(co=True)
        if pre_obj_list:
            cmds.hilite(pre_obj_list, r=True)
    if pre_sel:
        cmds.select(pre_sel, r=True)
    else:
        cmds.select(cl=True)
    sb.after_pick_context(ctx=c_ctx)
    #移動マニプを選択の中心に移動する
    cmds.manipPivot(p=pos)
コード例 #49
0
def CreateJNT(*args):
    cmds.select(cl=1)
    sel = cmds.ls('*setJNT')
    IKlist = []
    FKlist = []
    FKGRPlist = []
    skinlist = []
    parentList = []
    scaleList = []
    paweightList = []
    scweightList = []

    # create IK FK switch
    Tr = XF('switchLocation', q=1, ws=1, t=1)
    Rt = XF('switchLocation', q=1, ws=1, ro=1)
    Roo = XF('switchLocation', q=1, ws=1, roo=1)
    XF(cmds.curve(d=1,
                  p=[(-1.000750770419927, 0.0, -2.001501540839854),
                     (1.000750770419927, 0.0, -2.001501540839854),
                     (1.000750770419927, 0.0, -1.000750770419927),
                     (2.001501540839854, 0.0, -1.000750770419927),
                     (2.001501540839854, 0.0, 1.000750770419927),
                     (1.000750770419927, 0.0, 1.000750770419927),
                     (1.000750770419927, 0.0, 2.001501540839854),
                     (-1.000750770419927, 0.0, 2.001501540839854),
                     (-1.000750770419927, 0.0, 1.000750770419927),
                     (-2.001501540839854, 0.0, 1.000750770419927),
                     (-2.001501540839854, 0.0, -1.000750770419927),
                     (-1.000750770419927, 0.0, -1.000750770419927),
                     (-1.000750770419927, 0.0, -2.001501540839854)],
                  n='FKIK_ctrl'),
       ws=1,
       t=Tr,
       ro=Rt,
       roo=Roo)
    selObj = cmds.ls(sl=1)
    CtlScale = cmds.getAttr('setJNT_scale.scaleX')
    for i in selObj:
        cmds.select(i)  # ---- scale!!! ----#
        cmds.hilite(i)
        cmds.select(i + '.cv[:]')
        cmds.scale(CtlScale * 3, CtlScale * 3, CtlScale * 3)
        cmds.hilite(u=1)
        cmds.select(i)
    CTLShape = cmds.listRelatives(selObj, s=1)
    cmds.setAttr((CTLShape[0] + '.overrideEnabled'), 1)
    cmds.setAttr((CTLShape[0] + '.overrideColor'), 17)
    cmds.addAttr(ln='FKIK', at='float', min=0, max=10, dv=0, k=1)
    cmds.select(cl=1)

    # create FK, IK, skin joints
    for i in range(len(JNTver)):
        if 'IK' in JNTver[i]:  # create IK joint
            for s in sel:
                Tr = XF(s, q=1, ws=1, t=1)
                Rt = XF(s, q=1, ws=1, ro=1)
                Roo = XF(s, q=1, ws=1, roo=1)
                XF(cmds.joint(name=s.split('_')[1] + '_' + JNTver[i] + '_JNT'),
                   ws=1,
                   t=Tr,
                   ro=Rt,
                   roo=Roo)
                IKlist.append(s.split('_')[1] + '_' + JNTver[i] + '_JNT')
                cmds.makeIdentity(apply=True, t=1, r=1, s=1, n=0)
            cmds.select(cl=1)
        elif 'skin' in JNTver[i]:  # create skin joint
            for s in sel:
                Tr = XF(s, q=1, ws=1, t=1)
                Rt = XF(s, q=1, ws=1, ro=1)
                Roo = XF(s, q=1, ws=1, roo=1)
                JNT = XF(cmds.joint(name=s.split('_')[1] + '_' + JNTver[i] +
                                    '_JNT'),
                         ws=1,
                         t=Tr,
                         ro=Rt,
                         roo=Roo)
                skinlist.append(s.split('_')[1] + '_' + JNTver[i] + '_JNT')
                cmds.makeIdentity(apply=True, t=1, r=1, s=1, n=0)
            cmds.select(cl=1)
        elif 'FK' in JNTver[i]:  # create CTRL at FK joint
            for s in sel:
                Tr = XF(s, q=1, ws=1, t=1)
                Rt = XF(s, q=1, ws=1, ro=1)
                Roo = XF(s, q=1, ws=1, roo=1)
                CtlScale = cmds.getAttr(s + '.ctlSize')
                CTL = cmds.circle(nr=(0, 1, 0),
                                  c=(0, 0, 0),
                                  name=s.split('_')[1] + '_' + JNTver[i] +
                                  '_JNT_CTL',
                                  radius=CtlScale)
                CTLShape = cmds.listRelatives(CTL, s=1)
                cmds.setAttr((CTLShape[0] + '.overrideEnabled'), 1)
                cmds.setAttr((CTLShape[0] + '.overrideColor'), 6)
                XF(CTL, ws=1, roo=Roo)
                JNT = cmds.joint(name=s.split('_')[1] + '_' + JNTver[i] +
                                 '_JNT')
                XF(JNT, ws=1, roo=Roo)
                cmds.makeIdentity(apply=True, t=1, r=1, s=1, n=0)
                FKlist.append(JNT)
                offset = cmds.group(CTL,
                                    w=1,
                                    name=s.split('_')[1] + '_' + JNTver[i] +
                                    '_CTL_offset')
                XF(offset, ws=1, roo=Roo)
                GRP = cmds.group(offset,
                                 w=1,
                                 name=s.split('_')[1] + '_' + JNTver[i] +
                                 '_CTL_GRP')
                XF(GRP, ws=1, t=Tr, ro=Rt, roo=Roo)
                FKGRPlist.append(GRP)

                cmds.delete(CTL[0], ch=1)

            for s in range(len(FKlist) - 1):  # FK joint grouping
                cmds.parent(FKGRPlist[s + 1], FKlist[s])

    # create IK handle
    ikHan = cmds.ikHandle(n='Leg_IK_handle',
                          sj=IKlist[1],
                          ee=IKlist[4],
                          solver='ikRPsolver')
    CA('ikSpringSolver.message', 'Leg_IK_handle.ikSolver', force=True)
    cmds.select(cl=1)
    # create IK controller
    Trik = XF(ikHan[0], q=1, ws=1, t=1)
    ikCTL = cmds.curve(
        d=1,
        p=[(-2.001501540839854, 2.001501540839854, 2.001501540839854),
           (-2.001501540839854, -2.001501540839854, 2.001501540839854),
           (2.001501540839854, -2.001501540839854, 2.001501540839854),
           (2.001501540839854, 2.001501540839854, 2.001501540839854),
           (-2.001501540839854, 2.001501540839854, 2.001501540839854),
           (-2.001501540839854, 2.001501540839854, -2.001501540839854),
           (-2.001501540839854, -2.001501540839854, -2.001501540839854),
           (-2.001501540839854, -2.001501540839854, 2.001501540839854),
           (2.001501540839854, -2.001501540839854, 2.001501540839854),
           (2.001501540839854, -2.001501540839854, -2.001501540839854),
           (2.001501540839854, 2.001501540839854, -2.001501540839854),
           (2.001501540839854, 2.001501540839854, 2.001501540839854),
           (-2.001501540839854, 2.001501540839854, 2.001501540839854),
           (-2.001501540839854, 2.001501540839854, -2.001501540839854),
           (2.001501540839854, 2.001501540839854, -2.001501540839854),
           (2.001501540839854, -2.001501540839854, -2.001501540839854),
           (-2.001501540839854, -2.001501540839854, -2.001501540839854)],
        n='IK_ctrl')
    ikoffset = cmds.group(ikCTL, w=1, n=ikCTL + 'offset')
    ikGRP = cmds.group(ikoffset, w=1, n=ikCTL + 'GRP')
    XF(ikGRP, ws=1, t=Trik)
    cmds.parent(ikHan[0], ikCTL)

    # constraint FK IK to skin joints
    for s in range(len(sel)):
        conpa = cmds.parentConstraint(FKlist[s], IKlist[s], skinlist[s], mo=1)
        paList = cmds.parentConstraint(conpa, query=True, weightAliasList=True)
        parentList.append(conpa)
        paweightList.append(paList)
        consc = cmds.scaleConstraint(FKlist[s], IKlist[s], skinlist[s], mo=1)
        scList = cmds.scaleConstraint(consc, query=True, weightAliasList=True)
        scaleList.append(consc)
        scweightList.append(scList)

    # connect FK IK switch => skin
    selSwitch = cmds.ls('*FKIK_ctrl')
    for s in selSwitch:
        CA(s + '.FKIK', SN('unitConversion', au=1, n='UC_' + s) + '.input')
        SA('UC_' + s + '.conversionFactor', 0.1)
        CA('UC_' + s + '.output', SN('reverse', au=1, n='RV_' + s) + '.inputX')
        for i in range(len(parentList)):
            CA('UC_' + s + '.output',
               parentList[i][0] + '.' + paweightList[i][1])
            CA('UC_' + s + '.output',
               scaleList[i][0] + '.' + scweightList[i][1])
            CA('RV_' + s + '.outputX',
               parentList[i][0] + '.' + paweightList[i][0])
            CA('RV_' + s + '.outputX',
               scaleList[i][0] + '.' + scweightList[i][0])

    # create IK poleVector
    poleCTL = cmds.curve(d=1,
                         p=[(0.0, 2.001501540839854, 0.0),
                            (0.0, -2.001501540839854, 0.0), (0.0, 0.0, 0.0),
                            (0.0, 0.0, -2.001501540839854),
                            (0.0, 0.0, 2.001501540839854), (0.0, 0.0, 0.0),
                            (2.001501540839854, 0.0, 0.0),
                            (-2.001501540839854, 0.0, 0.0)],
                         n='pole_CTL')

    CTLShape = cmds.listRelatives(poleCTL, s=1)
    cmds.setAttr((CTLShape[0] + '.overrideEnabled'), 1)
    cmds.setAttr((CTLShape[0] + '.overrideColor'), 17)

    selObj = cmds.ls(sl=1)
    CtlScale = cmds.getAttr('setJNT_scale.scaleX')
    for i in selObj:
        cmds.select(i)  # ---- scale!!! ----#
        cmds.hilite(i)
        cmds.select(i + '.cv[:]')
        cmds.scale(CtlScale * 3, CtlScale * 3, CtlScale * 3)
        cmds.hilite(u=1)
        cmds.select(i)

    Tr = XF('Knee_skin_JNT', q=1, ws=1, t=1)
    offsetPole = cmds.group(poleCTL, n=poleCTL + 'offset')
    GRPpole = cmds.group(offsetPole, n=poleCTL + 'GRP')
    XF(GRPpole, ws=1, t=Tr)
    cmds.move(300, GRPpole, moveZ=True, relative=True, objectSpace=True)
    cmds.poleVectorConstraint(poleCTL, ikHan[0])

    cmds.delete('setJNT_scale')
コード例 #50
0
import maya.cmds as mc
import maya.mel as mel
oEdges = mc.ls(sl=True)
oObj = oEdges[0].split('.')[0]
oFace = ''
for i in oEdges:
	if '.f[' in i:
		oFace = i
mc.DetachComponent()
mc.select(cl=True)
mc.select(oFace)
mc.ConvertSelectionToShell()
oFacesFinal = mc.ls(sl=True)
mc.select(oObj)
mc.polyMergeVertex(d=0.0001)
mc.select(oFacesFinal)
mc.selectType(smp=0, sme=0, smf=1, smu=0, pv=0, pe=0, pf=1, puv=0)
mc.hilite(oObj, r=True)
コード例 #51
0
ファイル: selection.py プロジェクト: rocktavious/DevToolsLib
 def select(self,obj,compType,clearSel=1,addVal=0):
     '''Allow easy reselection of specific selection data'''
     cmds.select(cl=clearSel)
     if self[obj][compType] != None :
         cmds.hilite(obj)
         cmds.select(self[obj][compType],add=addVal)
コード例 #52
0
 def select(self,obj,compType,clearSel=1,addVal=0):
     '''Allow easy reselection of specific selection data'''
     cmds.select(cl=clearSel)
     if self[obj][compType] != None :
         cmds.hilite(obj)
         cmds.select(self[obj][compType],add=addVal)
コード例 #53
0
ファイル: skinWeightsUI.py プロジェクト: yazici/zootoolbox
 def on_selectMesh(self, *a):
     cmd.hilite(unHilite=True)
     cmd.select(self._mesh)
     mel.artAttrSkinToolScript(4)
コード例 #54
0
def evenEdgeSpacing(edgeList,
                    smooth=0,
                    influence=1.0,
                    snapToOrig=False,
                    deleteHistory=False):
    """
    @param edgeList: List of polygon edges to evenly space
    @type edgeList: list
    @param smooth: Number of smooth iterations to apply
    @type smooth: int
    @param influence: Amount of result to apply to original vertex positions
    @type influence: float
    @param snapToOrig: Snap points back to original mesh
    @type snapToOrig: bool
    @param deleteHistory: Delete construction history.
    @type deleteHistory: bool
    """
    # Get Edge List
    edgeList = cmds.filterExpand(edgeList, ex=True, sm=32) or []
    if not edgeList:
        raise Exception('Invalid or empty edge list! Unable to even edge spacing...')

    edgeCrvList = glTools.tools.extractCurves.extractEdgeCurves(edgeList, keepHistory=False)
    evenCrvList = []
    for edgeCrv in edgeCrvList:

        # Rebuild Even Curve
        evenCrv = cmds.rebuildCurve(edgeCrv,
                                  ch=False,
                                  rpo=False,
                                  rt=0,
                                  end=1,
                                  kr=False,
                                  kcp=False,
                                  kep=True,
                                  kt=False,
                                  s=0,
                                  d=1,
                                  tol=0)[0]

        # Smooth Curve
        if smooth: smoothCurve(evenCrv, smooth, True)

        # Snap To Mesh
        mesh = cmds.ls(edgeList, o=True)[0]
        if snapToOrig:
            pts = glTools.utils.component.getComponentStrList(evenCrv)
            glTools.utils.mesh.snapPtsToMesh(mesh, pts)

        evenCrvList.append(evenCrv)

    # Apply Even Spacing to Mesh Edge Vertices
    wire = glTools.utils.wire.createMulti(mesh, edgeCrvList, dropoffDist=0.01, prefix=mesh.split(':')[-1])
    cmds.setAttr(wire[0] + '.rotation', 0)
    cmds.setAttr(wire[0] + '.envelope', influence)

    # Blend to Even Curve
    for i in range(len(edgeCrvList)):
        blendShape = glTools.utils.blendShape.create(baseGeo=edgeCrvList[i], targetGeo=[evenCrvList[i]])
        cmds.setAttr(blendShape + '.' + evenCrvList[i], 1)

    # ==================
    # - Delete History -
    # ==================

    if deleteHistory:
        wireBaseList = glTools.utils.wire.getWireBase(wire[0])
        cmds.delete(mesh, ch=True)
        for edgeCrv in edgeCrvList:
            if cmds.objExists(edgeCrv):
                cmds.delete(edgeCrv)
        for evenCrv in evenCrvList:
            if cmds.objExists(evenCrv):
                cmds.delete(evenCrv)
        for wireBase in wireBaseList:
            if cmds.objExists(wireBase):
                cmds.delete(wireBase)

    # =================
    # - Return Result -
    # =================

    if edgeList:
        cmds.hilite(mesh)
        cmds.select(edgeList)

    return edgeList
コード例 #55
0
def smoothEdgeLine(edgeList,
                   smooth=4,
                   falloff=0.01,
                   snapToOrig=False,
                   keepEdgeSpacing=False,
                   deleteHistory=False):
    """
    @param edgeList:
    @param smooth:
    @param falloff:
    @param snapToOrig:
    @param keepEdgeSpacing:
    @param deleteHistory:
    """
    # Get Edge List
    edgeList = cmds.filterExpand(edgeList, ex=True, sm=32) or []
    if not edgeList:
        raise Exception('Invalid or empty edge list! Unable to even edge spacing...')

    edgeCrvList = glTools.tools.extractCurves.extractEdgeCurves(edgeList, keepHistory=False)
    smoothCrvList = []
    for edgeCrv in edgeCrvList:

        # Smooth Edge Line
        smoothCrv = cmds.duplicate(edgeCrv, n=edgeCrv + '_smoothed')[0]
        smoothCurve(crv=smoothCrv,
                    iterations=smooth,
                    keepEnds=True,
                    keepSpacing=keepEdgeSpacing)

        # Snap To Mesh
        mesh = cmds.ls(edgeList, o=True)[0]
        if snapToOrig:
            pts = glTools.utils.component.getComponentStrList(smoothCrv)
            glTools.utils.mesh.snapPtsToMesh(mesh, pts)

        # Append List
        smoothCrvList.append(smoothCrv)

    # Apply Smoothed Edge to Vertices
    wire = glTools.utils.wire.createMulti(mesh, edgeCrvList, dropoffDist=falloff, prefix=mesh.split(':')[-1])
    cmds.setAttr(wire[0] + '.rotation', 0)

    # Blend to Smooth Curve
    for i in range(len(edgeCrvList)):
        blendShape = glTools.utils.blendShape.create(baseGeo=edgeCrvList[i], targetGeo=[smoothCrvList[i]])
        cmds.setAttr(blendShape + '.' + smoothCrvList[i], 1)

    # ==================
    # - Delete History -
    # ==================

    if deleteHistory:
        wireBaseList = glTools.utils.wire.getWireBase(wire[0])
        cmds.delete(mesh, ch=True)
        for edgeCrv in edgeCrvList:
            if cmds.objExists(edgeCrv):
                cmds.delete(edgeCrv)
        for smoothCrv in smoothCrvList:
            if cmds.objExists(smoothCrv):
                cmds.delete(smoothCrv)
        for wireBase in wireBaseList:
            if cmds.objExists(wireBase):
                cmds.delete(wireBase)

    # =================
    # - Return Result -
    # =================

    if edgeList:
        cmds.hilite(mesh)
        cmds.select(edgeList)

    return edgeList
コード例 #56
0
def straightenVerts(edgeList,
                    falloff=0.01,
                    influence=1.0,
                    snapToOriginal=False,
                    keepEdgeSpacing=False,
                    deleteHistory=False):
    """
    Straighten specified polygon vertices.
    @param influence:
    @param keepEdgeSpacing:
    @param edgeList: List of polygon edges to straighten.
    @type edgeList: list
    @param falloff: Falloff distance around selected vertices.
    @type falloff: float
    @param snapToOriginal: Snap vertices back to closest point on original mesh.
    @type snapToOriginal: bool
    @param deleteHistory: Delete construction history.
    @type deleteHistory: bool
    """
    # Get Edge List
    edgeList = cmds.filterExpand(edgeList, ex=True, sm=32) or []
    if not edgeList:
        raise Exception('Invalid or empty edge list! Unable to straighten vertices...')

    # Build Edge Curve from Vertices
    edgeCrvList = glTools.tools.extractCurves.extractEdgeCurves(edgeList, keepHistory=False)
    straightCrvList = []
    for edgeCrv in edgeCrvList:

        # Build Straight Curve
        straightCrv = cmds.rebuildCurve(edgeCrv,
                                      ch=False,
                                      rpo=False,
                                      rt=0,
                                      end=1,
                                      kr=False,
                                      kcp=False,
                                      kep=True,
                                      kt=False,
                                      s=1,
                                      d=1,
                                      tol=0)[0]

        # Rebuild Straight Curve
        dist = []
        total = 0.0
        params = []
        pts = glTools.utils.base.getMPointArray(edgeCrv)
        max = cmds.getAttr(straightCrv + '.maxValue')
        if keepEdgeSpacing:
            for i in range(pts.length() - 1):
                d = (pts[i] - pts[i + 1]).length()
                dist.append(d)
                total += d
            for i in range(len(dist)):
                d = dist[i] / total * max
                if i: d += params[-1]
                params.append(d)
        else:
            params = glTools.utils.mathUtils.distributeValue(pts.length(), rangeEnd=max)[1:-1]

        params = [straightCrv + '.u[' + str(i) + ']' for i in params]
        cmds.insertKnotCurve(params, ch=False, numberOfKnots=1, add=True, ib=False, rpo=True)

        # Snap To Mesh
        mesh = cmds.ls(edgeList, o=True)[0]
        if snapToOriginal:
            pts = glTools.utils.component.getComponentStrList(straightCrv)
            glTools.utils.mesh.snapPtsToMesh(mesh, pts)

        # Append List
        straightCrvList.append(straightCrv)

    # =================
    # - Deform Points -
    # =================

    # Build Wire Deformer
    wire = glTools.utils.wire.createMulti(mesh, edgeCrvList, dropoffDist=falloff, prefix=mesh.split(':')[-1])
    cmds.setAttr(wire[0] + '.rotation', 0)

    # Blend to Straight Curve
    for i in range(len(edgeCrvList)):
        blendShape = glTools.utils.blendShape.create(baseGeo=edgeCrvList[i], targetGeo=[straightCrvList[i]])
        cmds.setAttr(blendShape + '.' + straightCrvList[i], influence)

    # ==================
    # - Delete History -
    # ==================

    if deleteHistory:
        wireBaseList = glTools.utils.wire.getWireBase(wire[0])
        cmds.delete(mesh, ch=True)
        for edgeCrv in edgeCrvList:
            if cmds.objExists(edgeCrv):
                cmds.delete(edgeCrv)
        for straightCrv in straightCrvList:
            if cmds.objExists(straightCrv):
                cmds.delete(straightCrv)
        for wireBase in wireBaseList:
            if cmds.objExists(wireBase):
                cmds.delete(wireBase)

    # =================
    # - Return Result -
    # =================

    if edgeList:
        cmds.hilite(mesh)
        cmds.select(edgeList)

    return edgeList
コード例 #57
0
ファイル: decorators.py プロジェクト: arubertoson/maya-mampy
 def __exit__(self, *args):
     cmds.select(self.slist, r=True)
     if self.hlist:
         cmds.hilite(self.hlist)