當前位置: 首頁>>代碼示例>>Python>>正文


Python cmds.setToolTo方法代碼示例

本文整理匯總了Python中maya.cmds.setToolTo方法的典型用法代碼示例。如果您正苦於以下問題:Python cmds.setToolTo方法的具體用法?Python cmds.setToolTo怎麽用?Python cmds.setToolTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在maya.cmds的用法示例。


在下文中一共展示了cmds.setToolTo方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: paint

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setToolTo [as 別名]
def paint():
    """
    Initialize the smooth weight context, make sure to have a mesh selected 
    with a skin cluster attached to it. Once this command is run the context
    will be set as the active tool.
    """
    if not cmds.artUserPaintCtx(CONTEXT, query=True, exists=True):
        cmds.artUserPaintCtx(CONTEXT)
            
    cmds.artUserPaintCtx(
        CONTEXT, 
        edit=True, 
        ic=CONTEXT_INITIALIZE, 
        svc=CONTEXT_UPDATE, 
        whichTool="userPaint", 
        fullpaths=True,
        outwhilepaint=True,
        brushfeedback=False,
        selectedattroper="additive"
    )

    cmds.setToolTo(CONTEXT) 
開發者ID:robertjoosten,項目名稱:maya-skinning-tools,代碼行數:24,代碼來源:commands.py

示例2: selection_changed

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setToolTo [as 別名]
def selection_changed(self, *args):
        """ make sure to opt out of the current spore tool when the selction
        is changed """

        if cmds.currentCtx().startswith('spore'):
            cmds.setToolTo('selectSuperContext') 
開發者ID:wiremas,項目名稱:spore,代碼行數:8,代碼來源:AEsporeNodeTemplate.py

示例3: emit

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setToolTo [as 別名]
def emit(self, *args):
        """ run the actual sample command and check if transforms are frozen """

        # exit spore context since it looses track of points after sampling
        if cmds.currentCtx().startswith('spore'):
            cmds.setToolTo('selectSuperContext')

        in_mesh = node_utils.get_connected_in_mesh(self._node)
        transform = cmds.listRelatives(in_mesh, p=True, f=True)[0]
        if cmds.getAttr(transform + '.translateX') != 0\
        or cmds.getAttr(transform + '.translateY') != 0\
        or cmds.getAttr(transform + '.translateZ') != 0\
        or cmds.getAttr(transform + '.rotateX') != 0\
        or cmds.getAttr(transform + '.rotateY') != 0\
        or cmds.getAttr(transform + '.rotateZ') != 0\
        or cmds.getAttr(transform + '.scaleX') != 1\
        or cmds.getAttr(transform + '.scaleY') != 1\
        or cmds.getAttr(transform + '.scaleZ') != 1:
            msg = 'Feeze transformations to sample the geomety!'
            result = message_utils.IOHandler().confirm_dialog(msg, 'Freeze Transformations')
            if result:
                cmds.makeIdentity(transform, a=True, s=True, r=True, t=True, n=0)
            else:
                return

        cmds.setAttr('{}.emit'.format(self._node), 1)
        cmds.sporeSampleCmd()

    # ------------------------------------------------------------------------ #
    # clear button
    # ------------------------------------------------------------------------ # 
開發者ID:wiremas,項目名稱:spore,代碼行數:33,代碼來源:AEsporeNodeTemplate.py

示例4: paint

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setToolTo [as 別名]
def paint(mesh, influence):
    """
    Initialize the remove influence context. Once this command is run the 
    context will be set as the active tool.
    
    :param str mesh:
    :param str influence:
    """
    # initialize paint tool
    cmds.paintRemoveInfluenceCtxInitialize(
        mesh,
        influence
    )
    
    # initialize context
    if not cmds.artSelectCtx(CONTEXT, query=True, exists=True):
        cmds.artSelectCtx(CONTEXT)
            
    cmds.artSelectCtx( 
        CONTEXT, 
        edit=True, 
        beforeStrokeCmd=CONTEXT_BEFORE,
        afterStrokeCmd=CONTEXT_AFTER,
        selectop="unselect", 
        outwhilepaint=True,
        brushfeedback=False 
    )
     
    # set tool
    cmds.setToolTo(CONTEXT) 
開發者ID:robertjoosten,項目名稱:maya-skinning-tools,代碼行數:32,代碼來源:commands.py

示例5: alignTool

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setToolTo [as 別名]
def alignTool():
    mel.eval("setToolTo alignToolCtx") 
開發者ID:minoue,項目名稱:rush,代碼行數:4,代碼來源:Modify.py

示例6: snapTogetherTool

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setToolTo [as 別名]
def snapTogetherTool():
    cmds.setToolTo(cmds.snapTogetherCtx()) 
開發者ID:minoue,項目名稱:rush,代碼行數:4,代碼來源:Modify.py

示例7: exit

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setToolTo [as 別名]
def exit(self, *args, **kwargs):
        utils.executeDeferred(self.reset_select_mask)
        if self.repeat:
            lazy_reset = lambda: cmds.setToolTo(self.context_name)
            utils.executeDeferred(lazy_reset) 
開發者ID:theodox,項目名稱:mGui,代碼行數:7,代碼來源:ctx.py

示例8: editPivotHandle

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setToolTo [as 別名]
def editPivotHandle(self):

        qt_maya_window.installEventFilter(self.keypressFilter)

        #create transform
        self.pivotHandle = mc.group(em=True, name='Adjust_Pivot')
        mc.setAttr(self.pivotHandle+'.rotate', lock=True)
        mc.setAttr(self.pivotHandle+'.rx', keyable=False)
        mc.setAttr(self.pivotHandle+'.ry', keyable=False)
        mc.setAttr(self.pivotHandle+'.rz', keyable=False)
        mc.setAttr(self.pivotHandle+'.scale', lock=True)
        mc.setAttr(self.pivotHandle+'.sx', keyable=False)
        mc.setAttr(self.pivotHandle+'.sy', keyable=False)
        mc.setAttr(self.pivotHandle+'.sz', keyable=False)
        mc.setAttr(self.pivotHandle+'.visibility', lock=True, keyable=False)
        mc.setAttr(self.pivotHandle+'.displayHandle', True)

        self.pivotHandle = mc.parent(self.pivotHandle, self.node)[0]

        mc.addAttr(self.pivotHandle, ln='ml_pivot_handle', at='bool', keyable=False)

        #set initial position
        mc.setAttr(self.pivotHandle+'.translate', *mc.getAttr(self.node+'.rotatePivot')[0])

        #lock it so you don't delete it or something.
        mc.lockNode(self.pivotHandle, lock=True)

        self.scriptJob = mc.scriptJob(event=['SelectionChanged', self.cleanup], runOnce=True)

        mc.setToolTo('Move')

        mc.inViewMessage( amg='After moving the pivot, press <hl>Return</hl> to bake or <hl>Esc</hl> to cancel.', pos='midCenterTop', fade=True, fadeStayTime=4000, dragKill=True) 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:34,代碼來源:ml_pivot.py

示例9: softSelectionClusterWeights

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setToolTo [as 別名]
def softSelectionClusterWeights(*args):

    sel = mc.ls(sl=True, o=True)

    if not sel:
        raise RuntimeError('Please select some vertices.')

    weights = getSoftSelectionWeights()

    if not weights:
        raise RuntimeError('Please select some vertices.')

    #get manipulator position for pivot
    mc.setToolTo('Move')
    moveMode = mc.manipMoveContext('Move', query=True, mode=True)
    mc.manipMoveContext('Move', edit=True, mode=0)
    position = mc.manipMoveContext('Move', query=True, position=True)
    mc.manipMoveContext('Move', edit=True, mode=moveMode)

    clusterNode, clusterHandle = mc.cluster(sel[0])

    for vert in mc.ls(sel[0]+'.vtx[*]', fl=True, l=True):
        weight = 0.0
        if vert in weights.keys():
            weight = weights[vert]
        mc.percent(clusterNode, vert, v=weight)

    #set cluster pivot
    mc.xform(clusterHandle, a=True, ws=True, piv=(position[0], position[1], position[2]))
    clusterShape = mc.listRelatives(clusterHandle, c=True, s=True)
    mc.setAttr(clusterShape[0] + '.origin', position[0], position[1], position[2]) 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:33,代碼來源:ml_softWeights.py

示例10: setTool

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setToolTo [as 別名]
def setTool(self):
        mc.setToolTo(self.draggerContext) 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:4,代碼來源:ml_utilities.py

示例11: activateContext

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setToolTo [as 別名]
def activateContext(self, context_mode, attr, index):
        """ called whenever a brush button is clicked
        enable/disable context controls & activate tool context
        @param context_mode: indicates which button has been clicked
        @param attr: holds the current node and attribute name
        @param index: the index of the child attr in the combobox """

        # check if there are any source objects
        if not cmds.textScrollList('instanceList', q=True, ai=True):
            self.io.set_message('No source objects selected', 0)
            return

        cmds.setAttr(attr, index)
        attr_name = attr.split('.')[-1]
        node_name = attr.split('.')[0]

        # create a tuple of all controls and a dict that associates each control
        # to a specific context style
        brush_crtls = ('brushRadius', 'minDistance', 'fallOff', 'strength',
                       'numBrushSamples', 'alignTo', 'minRotation',
                       'maxRotation', 'uniformScale', 'minScale',
                       'maxScale', 'scaleFactor', 'scaleAmount',
                       'minOffset', 'maxOffset',
                       'usePressureMapping', 'pressureMapping',
                       'minPressure', 'maxPressure')
        p_map = cmds.getAttr('{}.usePressureMapping'.format(self._node))
        dim_ctrl = {                #    rad    minD,  foff,   stren,  numS,   aliTo   minR,   maxR,   uniS    minS,   maxS,   sFac,   sAmou,  minO,   maxO,   pre,    map,    minP,   maxP
                    'place':            (False, True,   False,  True,   False,  True,   True,   True,   True,   True,   True,   False,  False,  True,   True,   True,   p_map,  p_map,  p_map),
                    'spray':            (True,  True,   False,  True,   True,   True,   True,   True,   True,   True,   True,   False,  False,  True,   True,   True,   p_map,  p_map,  p_map),
                    'scale':            (True,  False,  True,   False,  False,  False,  False,  False,  True,   False,  False,  True,   True,   False,  False,  True,   False,  p_map,  p_map),
                    'align':            (True,  False,  True,   True,   False,  True,   False,  False,  False,  False,  False,  False,  True,  False,  False,  True,   False,  p_map,  p_map),
                    'move':             (True,  False,  True,   True,   False,  False,  False,  False,  False,  False,  False,  False,   False,  False,  False,  True,   False,  p_map,  p_map),
                    'id':               (True,  True,   False,  False,  True,   False,  False,  False,  False,  False,  False,  False,  True,  False,  False,  True,   False,  p_map,  p_map),
                    'remove':           (True,  True,   False,  False,  True,   False,  False,  False,  False,  False,  False,  False,  False,  False,  False,  False,  False,  False,  False),
                    }

        #  dim controls
        for i, ctrl in enumerate(brush_crtls):
            self.dimControl(node_name, ctrl, not dim_ctrl[context_mode][i])

        # colorize button
        buttons = ['placeBtn', 'sprayBtn', 'scaleBtn', 'alignBtn', 'moveBtn',
                   'idBtn', 'removeBtn']
        for btn in buttons:
            cmds.button(btn, e=True, bgc=(0.366, 0.366, 0.366))
        button_name = '{}Btn'.format(context_mode)
        cmds.button(button_name, e=True, bgc=(0.148, 0.148, 0.148))

        # set context
        self.context = cmds.sporeContext()
        cmds.select(self._node)
        cmds.setToolTo(self.context)

    # ------------------------------------------------------------------------ #
    # pen pressure checkbox
    # ------------------------------------------------------------------------ # 
開發者ID:wiremas,項目名稱:spore,代碼行數:58,代碼來源:AEsporeNodeTemplate.py

示例12: extrude_edge_uv

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setToolTo [as 別名]
def extrude_edge_uv(self):
        self.ex_edges = []
        sel = cmds.ls(sl=True)
        self.s_edges = common.conv_comp(sel, mode='edge')
        s_vtx = common.conv_comp(sel, mode='vtx')
        #self.saw_uvs(mode='pre')#事前に押し出し対象のUVを縫い合わせておく
        self.marge_uvs(mode='pre')
        if not self.s_edges:
            return
        ev_dict ,vec_dict, ev_uv_dict = self.make_edge_vtx_dict(self.s_edges)
        #print 'ev_dict :', ev_dict
        #print 'vec_dict :', vec_dict
        #押し出しを実行する
        cmds.polyExtrudeEdge(self.s_edges,
                            keepFacesTogether=True,
                            smoothingAngle=self.soft_angle.value(),
                            translate=[0, 0, 0])
        self.ex_edges = cmds.ls(sl=True)
        n_edges = common.conv_comp(self.ex_edges, mode='edge')
        n_faces = common.conv_comp(self.ex_edges, mode='face')
        self.n_uvs = common.conv_comp(n_faces, mode='uv')
        #print 'pre_move_uvs :', self.n_uvs
        #根本の位置合わせする
        new_vec_dict = {}
        for nuv in self.n_uvs[:]:
            vtx = common.conv_comp(nuv, mode='vtx')[0]
            edge = common.conv_comp(nuv, mode='edge')[0]
            if edge+' '+vtx in ev_dict.keys():
                uv_pos = ev_dict[edge+' '+vtx]
                #print 'get_uv_pos', nuv, uv_pos
                cmds.polyEditUV(nuv, u=uv_pos[0], v=uv_pos[1] ,r=False)
                self.n_uvs.remove(nuv)
                key_uv = ev_uv_dict[edge+' '+vtx]
                new_vec_dict[nuv] = vec_dict[key_uv]
        #print 'post push uvs :', self.n_uvs
        #押し出し先を根本につけて押し出しベクトル辭書をつくる
        self.uv_vec_dict = {}
        self.base_pos_dict = {}
        for nuv in self.n_uvs:
            edges = common.conv_comp(nuv, mode='edge')
            face = common.conv_comp(nuv, mode='face')
            f_uvs = common.conv_comp(face, mode='uv')
            for edge in edges:
                if edge in n_edges:
                    continue
                #print 'get new edge :', edge
                e_uvs = common.conv_comp(edge, mode='uv')
                l_uvs = list(set(f_uvs) & set(e_uvs))
                #print 'new edge uvs :', l_uvs
                for uv in l_uvs:
                    if not uv in new_vec_dict.keys():
                        continue
                    uv_pos = cmds.polyEditUV(uv, query=True)
                    cmds.polyEditUV(nuv, u=uv_pos[0], v=uv_pos[1] ,r=False)
                    self.uv_vec_dict[nuv] = new_vec_dict[uv]
                    self.base_pos_dict[nuv] = uv_pos
                    self.saw_edges.append(edge)#縫い合わせ用リストに入れておく
        self.push_out()
        cmds.setToolTo('moveSuperContext') 
開發者ID:ShikouYamaue,項目名稱:SISideBar,代碼行數:61,代碼來源:extrude_edge.py

示例13: restore_context_and_axis

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setToolTo [as 別名]
def restore_context_and_axis():
    global current_mode
    global pre_mode
    current_mode = cmds.selectMode(q=True, o=True)
    current_tool = cmds.currentCtx()
    target_tool_list = ['scaleSuperContext', 'RotateSuperContext', 'moveSuperContext', 'selectSuperContext']
    #選択オブジェクトが切り替わったときだけ切り替え実行
    if cmds.selectMode(q=True, co=True):
        if cmds.ls(sl=True, type='transform'):#複合選択モードの時は逃げる
            print 'multi selection mode return :'
            return
        if cmds.ls(sl=True, set=True):#複合選択モードの時は逃げる
            print 'multi selection mode return :'
            return
        if 'pre_sel_comp' in globals():
            current_selection = cmds.ls(sl=True)
            if pre_sel_comp != current_selection:
                if current_tool in target_tool_list:
                    if not cmds.ls(sl=True):
                        if pre_sel_comp:
                            #print 'newsel'
                            try:
                                cmds.select(pre_sel_comp[0])
                            except:
                                pass
                    if cmds.ls(sl=True):
                        sb.window.select_xyz_from_manip()#事前に選択したハンドル方向をなるべくキープする
                        if current_selection != cmds.ls(sl=True):
                            cmds.select(current_selection, r=True)
        global pre_sel_comp
        pre_sel_comp = cmds.ls(sl=True)#Flatにすると比較が無駄に重くなるので注意
    if cmds.selectMode(q=True, o=True):
        if 'pre_sel_obj' in globals():
            current_selection = cmds.ls(sl=True, o=True)
            if pre_sel_obj != current_selection:
                if current_tool in target_tool_list:
                    #print 'ajust context'
                    if not cmds.ls(sl=True):
                        if cmds.ls(hl=True):#ラティスポイントとかの時は逃げる
                            return
                        if pre_sel_obj:
                            #print 'newsel'
                            try:
                                cmds.select(pre_sel_obj[0])
                            except:
                                pass
                    if cmds.ls(sl=True):
                        sb.window.select_xyz_from_manip()#事前に選択したハンドル方向をなるべくキープする
                        if current_selection != cmds.ls(sl=True):
                            cmds.select(current_selection, r=True)
                    cmds.setToolTo('selectSuperContext')
                    cmds.setToolTo(current_tool)
        global pre_sel_obj
        pre_sel_obj = cmds.ls(sl=True, o=True)
    pre_mode = current_mode 
開發者ID:ShikouYamaue,項目名稱:SISideBar,代碼行數:57,代碼來源:sisidebar_sub.py


注:本文中的maya.cmds.setToolTo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。