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


Python core.selected方法代碼示例

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


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

示例1: _update_lstParent

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import selected [as 別名]
def _update_lstParent(self, pSpData):
        """
        Update the parent list for the selected system
        """
        self.createModel.clear()
        if pSpData:
            self.ui.lstParent.setEnabled(True)
            self.createModel.appendRow(self.parentItem)
            for iIdx, nParentInfo in enumerate(pSpData.aDrivers):
                newParentItem = QtGui.QStandardItem(nParentInfo.name())
                newParentItem.setEditable(False)
                # Prevent any delete action when the sysem is referenced
                if pymel.referenceQuery(self.pSelSpSys.nSwConst, isNodeReferenced=True):
                    newParentItem.setCheckable(False)
                else:
                    newParentItem.setCheckable(True)
                self.createModel.appendRow(newParentItem)
        else:
            self.ui.lstParent.setEnabled(False)
            self.createModel.appendRow(self.parentItem) 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:22,代碼來源:sqSpaceSwitcher.py

示例2: _event_cbSys_selChanged

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import selected [as 別名]
def _event_cbSys_selChanged(self, _iIdx):
        """
        Manage the system change with the combo box. select the node related to the system selected in the combo box
        """
        # Prevent a node selection when the comboBox index changed during selection changed callback
        if not self.bInSelChanged:
            if _iIdx > 0:
                pCurSys = self.aSceneSpaceSwitch[_iIdx - 1]
                pymel.select(pCurSys.nDriven)
            else:  # If the no system index is selected, but a node is selected in the scene, put back the selected system
                for i, pSp in enumerate(self.aSceneSpaceSwitch):
                    if pSp.nDriven == self.nSelDriven:
                        # Change the index, but prevent the event to select back the node
                        self.bInSelChanged = True
                        self.ui.cbSysList.setCurrentIndex(i + 1)
                        self.bInSelChanged = False
                        break 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:19,代碼來源:sqSpaceSwitcher.py

示例3: controllerWalkUp

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import selected [as 別名]
def controllerWalkUp(node, add=False):
    """Walk up in the hierachy using the controller tag

    Arguments:
        node (dagNode or list of dagNode): Node with controller tag
        add (bool, optional): If true add to selection

    """
    oParent = []
    if not isinstance(node, list):
        node = [node]
    for n in node:
        tag = getWalkTag(n)
        if tag:
            cnx = tag.parent.connections()
            if cnx:
                oParent.append(cnx[0])
        else:
            pm.displayWarning("The selected object: %s without Controller tag "
                              "will be skipped" % n.name())
    if oParent:
        pm.select(_getControllerWalkNodes(oParent), add=add)
    else:
        pm.displayWarning("No parent to walk Up.") 
開發者ID:mgear-dev,項目名稱:mgear_core,代碼行數:26,代碼來源:pickWalk.py

示例4: smart_reset

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import selected [as 別名]
def smart_reset(*args):
    """Reset the SRT or the selected channels

    Checks first if we have channels selected. If not, will try to reset SRT

    Args:
        *args: Dummy
    """
    attributes = getSelectedChannels()
    if attributes:
        reset_selected_channels_value(objects=None, attributes=attributes)
    else:
        reset_SRT()

##########################################################
# GETTERS
########################################################## 
開發者ID:mgear-dev,項目名稱:mgear_core,代碼行數:19,代碼來源:attribute.py

示例5: getSelectedChannels

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import selected [as 別名]
def getSelectedChannels(userDefine=False):
    """Get the selected channels on the channel box

    Arguments:
        userDefine (bool, optional): If True, will return only the user
            defined channels. Other channels will be skipped.

    Returns:
        list: The list of selected channels names

    """
    # fetch core's main channelbox
    attrs = pm.channelBox(get_channelBox(), q=True, sma=True)
    if userDefine:
        oSel = pm.selected()[0]
        uda = oSel.listAttr(ud=True)
        if attrs:
            attrs = [x for x in attrs if oSel.attr(x) in uda]
        else:
            return None

    return attrs 
開發者ID:mgear-dev,項目名稱:mgear_core,代碼行數:24,代碼來源:attribute.py

示例6: getSelectedObjectChannels

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import selected [as 別名]
def getSelectedObjectChannels(oSel=None, userDefine=False, animatable=False):
    """Get the selected object channels.

    Arguments:
        oSel (None, optional): The  pynode with channels to get
        userDefine (bool, optional): If True, will return only the user
            defined channels. Other channels will be skipped.
        animatable (bool, optional): If True, only animatable parameters
            will be return

    Returns:
        list: The list of the selected object channels names
    """
    if not oSel:
        oSel = pm.selected()[0]

    channels = [x.name().rsplit(".", 1)[1]
                for x in oSel.listAttr(ud=userDefine, k=animatable)]

    return channels


##########################################################
# UTIL
########################################################## 
開發者ID:mgear-dev,項目名稱:mgear_core,代碼行數:27,代碼來源:attribute.py

示例7: rivet_per_face

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import selected [as 別名]
def rivet_per_face():
    """creates hair follicles per selected face
    """
    sel_list = pm.ls(sl=1, fl=1)

    follicles = []
    locators = []
    for face in sel_list:
        # use the center of the face as the follicle position
        p = reduce(lambda x, y: x + y, face.getPoints()) / face.numVertices()
        obj = pm.spaceLocator(p=p)
        locators.append(obj)
        shape = face.node()
        uv = face.getUVAtPoint(p, space='world')

        follicle_transform, follicle = create_follicle(shape, uv)

        pm.parent(obj, follicle_transform)
        follicles.append(follicle)

    return follicles, locators 
開發者ID:eoyilmaz,項目名稱:anima,代碼行數:23,代碼來源:auxiliary.py

示例8: create_bbox

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import selected [as 別名]
def create_bbox(nodes, per_selection=False):
    """creates bounding boxes for the selected objects

    :param bool per_selection: If True will create a BBox for each
      given object
    """

    if per_selection:
        for node in nodes:
            return cube_from_bbox(node.boundingBox())
    else:
        bbox = pm.dt.BoundingBox()
        for node in nodes:
            bbox.expand(node.boundingBox().min())
            bbox.expand(node.boundingBox().max())
        return cube_from_bbox(bbox) 
開發者ID:eoyilmaz,項目名稱:anima,代碼行數:18,代碼來源:auxiliary.py

示例9: reset_tweaks

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import selected [as 別名]
def reset_tweaks(cls):
        """Resets the tweaks on the selected deformed objects
        """
        for obj in pm.ls(sl=1):
            for tweak_node in pm.ls(obj.listHistory(), type=pm.nt.Tweak):

                try:
                    for i in tweak_node.pl[0].cp.get(mi=1):
                        tweak_node.pl[0].cv[i].vx.set(0)
                        tweak_node.pl[0].cv[i].vy.set(0)
                        tweak_node.pl[0].cv[i].vz.set(0)
                except TypeError:
                    try:
                        for i in tweak_node.vl[0].vt.get(mi=1):
                            tweak_node.vl[0].vt[i].vx.set(0)
                            tweak_node.vl[0].vt[i].vy.set(0)
                            tweak_node.vl[0].vt[i].vz.set(0)
                    except TypeError:
                        pass 
開發者ID:eoyilmaz,項目名稱:anima,代碼行數:21,代碼來源:rigging.py

示例10: create

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import selected [as 別名]
def create(self):
        # reverse_foot_controller = pm.selected()[0]
        # foot_ik_ankle_joint = pm.selected()[0]
        # foot_ik_ball_joint = pm.selected()[0]
        # foot_ik_tip_joint = pm.selected()[0]
        #
        # attrs = [
        #     'tipHeading',
        #     'tipRoll',
        #     'tipBank',
        #     'ballRoll',
        #     'ballBank'
        # ]
        #
        #
        # for attr in attrs:
        #     pm.addAttr(reverse_foot_controller, ln=attr, at='float', k=1)
        #
        # reverse_foot_controller.tipHeading >> foot_ik_tip_joint.ry
        # reverse_foot_controller.tipRoll >> foot_ik_tip_joint.rx
        # reverse_foot_controller.tipBank >> foot_ik_tip_joint.rz
        #
        # reverse_foot_controller.ballRoll >> foot_ik_ball_joint.rx
        # reverse_foot_controller.ballBank >> foot_ik_ball_joint.rz
        pass 
開發者ID:eoyilmaz,項目名稱:anima,代碼行數:27,代碼來源:rigging.py

示例11: assign_random_material_color

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import selected [as 別名]
def assign_random_material_color(cls):
        """assigns a lambert with a random color to the selected object
        """
        selected = pm.selected()

        # create the lambert material
        lambert = pm.shadingNode('lambert', asShader=1)

        # create the shading engine
        shading_engine = pm.nt.ShadingEngine()
        lambert.outColor >> shading_engine.surfaceShader

        # randomize the lambert color
        import random
        h = random.random()  # 0-1
        s = random.random() * 0.5 + 0.25  # 0.25-0.75
        v = random.random() * 0.5 + 0.5  # 0.5 - 1

        from anima.utils import hsv_to_rgb
        r, g, b = hsv_to_rgb(h, s, v)
        lambert.color.set(r, g, b)

        pm.sets(shading_engine, fe=selected)
        pm.select(selected) 
開發者ID:eoyilmaz,項目名稱:anima,代碼行數:26,代碼來源:render.py

示例12: open_node_in_browser

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import selected [as 別名]
def open_node_in_browser(cls):
        # get selected nodes
        node_attrs = {
            'file': 'fileTextureName',
            'aiImage': 'filename',
            'aiStandIn': 'dso',
        }
        import os
        from anima.utils import open_browser_in_location

        for node in pm.ls(sl=1):
            type_ = pm.objectType(node)
            # special case: if transform use shape
            if type_ == 'transform':
                node = node.getShape()
                type_ = pm.objectType(node)
            attr_name = node_attrs.get(type_)
            if attr_name:
                # if any how it contains a "#" character use the path
                path = node.getAttr(attr_name)
                if "#" in path:
                    path = os.path.dirname(path)
                open_browser_in_location(path) 
開發者ID:eoyilmaz,項目名稱:anima,代碼行數:25,代碼來源:render.py

示例13: export_shader_attributes

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import selected [as 別名]
def export_shader_attributes(cls):
        """exports the selected shader attributes to a JSON file
        """
        # get data
        data = []
        nodes = pm.ls(sl=1)
        for node in nodes:
            node_attr_data = {}
            attrs = node.listAttr()
            for attr in attrs:
                try:
                    value = attr.get()
                    if not isinstance(value, pm.PyNode):
                        node_attr_data[attr.shortName()] = value
                except TypeError:
                    continue
            data.append(node_attr_data)

        # write data
        import json
        with open(cls.node_attr_info_temp_file_path, 'w') as f:
            json.dump(data, f) 
開發者ID:eoyilmaz,項目名稱:anima,代碼行數:24,代碼來源:render.py

示例14: randomize_light_color_temp

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import selected [as 別名]
def randomize_light_color_temp(cls, min_field, max_field):
        """Randomizes the color temperature of selected lights

        :param min:
        :param max:
        :return:
        """
        min = pm.floatField(min_field, q=1, v=1)
        max = pm.floatField(max_field, q=1, v=1)
        cls.randomize_attr(
            [node.getShape() for node in pm.ls(sl=1)],
            'aiColorTemperature',
            min,
            max,
            1
        ) 
開發者ID:eoyilmaz,項目名稱:anima,代碼行數:18,代碼來源:render.py

示例15: randomize_light_intensity

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import selected [as 別名]
def randomize_light_intensity(cls, min_field, max_field):
        """Randomizes the intensities of selected lights

        :param min:
        :param max:
        :return:
        """
        min = pm.floatField(min_field, q=1, v=1)
        max = pm.floatField(max_field, q=1, v=1)
        cls.randomize_attr(
            [node.getShape() for node in pm.ls(sl=1)],
            'aiExposure',
            min,
            max,
            0.1
        ) 
開發者ID:eoyilmaz,項目名稱:anima,代碼行數:18,代碼來源:render.py


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