Python pymel.core.parent() Examples

The following are 30 code examples of pymel.core.parent(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pymel.core , or try the search function .
Example #1
Source File: picker.py    From anima with MIT License 6 votes vote down vote up
def get_weight_alias(self, parent):
        """finds weightAlias of given parent\n
        if it couldn't find any it returns None
        """
        if not self._is_setup:
            return

        parent = pm.nodetypes.DagNode(parent)

        assert( isinstance(parent, pm.nodetypes.Transform) )

        weightAliasList = self.get_weight_alias_list()
        parentList = self.get_parent_list()

        weightAlias = None

        for i in range(len(parentList)):
            if parentList[i] == parent:
                weightAlias = weightAliasList[i]
                break

        return weightAlias 
Example #2
Source File: dpAutoRig.py    From dpAutoRigSystem with GNU General Public License v2.0 6 votes vote down vote up
def info(self, title, description, text, align, width, height, *args):
        """ Create a window showing the text info with the description about any module.
        """
        # declaring variables:
        self.info_title       = title
        self.info_description = description
        self.info_text        = text
        self.info_winWidth    = width
        self.info_winHeight   = height
        self.info_align       = align
        # creating Info Window:
        if cmds.window('dpInfoWindow', query=True, exists=True):
            cmds.deleteUI('dpInfoWindow', window=True)
        dpInfoWin = cmds.window('dpInfoWindow', title='dpAutoRig - v'+DPAR_VERSION+' - '+self.langDic[self.langName]['i013_info']+' - '+self.langDic[self.langName][self.info_title], iconName='dpInfo', widthHeight=(self.info_winWidth, self.info_winHeight), menuBar=False, sizeable=True, minimizeButton=False, maximizeButton=False)
        # creating text layout:
        infoColumnLayout = cmds.columnLayout('infoColumnLayout', adjustableColumn=True, columnOffset=['both', 20], parent=dpInfoWin)
        cmds.separator(style='none', height=10, parent=infoColumnLayout)
        infoLayout = cmds.scrollLayout('infoLayout', parent=infoColumnLayout)
        if self.info_description:
            infoDesc = cmds.text(self.langDic[self.langName][self.info_description], align=self.info_align, parent=infoLayout)
        if self.info_text:
            infoText = cmds.text(self.info_text, align=self.info_align, parent=infoLayout)
        # call Info Window:
        cmds.showWindow(dpInfoWin) 
Example #3
Source File: picker.py    From anima with MIT License 6 votes vote down vote up
def add_parent_to_DAG_menu(self, parent):
        """adds the given parent to the DAG menu

        oyParSw - switch to --> %PARENTNAME%
        """
        # simply add "python(import oyObjectPicker as oyOP; oyOP.setObjectsParentTo( %s, %s+\".pickedData.constrainedParent[ %number% ]\" ))"

        commandLabel = "oyObjectPicker - switch to --> " + parent.name()
        parentIndex = self.get_parent_index(parent)

        if parentIndex == -1:
            return

        commandString = "{\n \
        int $parentIndex = " + str(parentIndex) + ";\n \
        string $parentConstraint[] = `listConnections (\"%s.pickedData.parentConstraint\")`;\n \
        string $parents[] = `parentConstraint -q -tl $parentConstraint[0]`;\n \
        string $parentName = $parents[ $parentIndex ];\n \
        python(\"import oyObjectPicker as oyOP; oyOP.set_objects_parent( '%s', '\"+$parentName+\"')\");\n \
        }"

        # pm.mel.source("oyAddDAGMenuCommands")
        # pm.mel.oyADMC_addSpecialCommandsToObject(
        #     self._object.name(), commandLabel, commandString
        # ) 
Example #4
Source File: picker.py    From anima with MIT License 6 votes vote down vote up
def set_parent_weight(self, parent):
        """sets the weight of the parent to 1 and the others to 0
        """
        parent = pm.nodetypes.DagNode(parent)

        # get the weightAlias of the parent
        parent_weightAlias = self.get_weight_alias(parent)

        # set the weight of the other parents to 0 and the current to 1
        weightAliasList = self.get_weight_alias_list()

        for weightAlias in weightAliasList:
            if weightAlias == parent_weightAlias:
                weightAlias.setKey(v=1, ott="step")
            else:
                currentWeight = weightAlias.get()
                print("currentWeight = %s" % currentWeight)
                if currentWeight > 0:
                    weightAlias.setKey(v=0, ott="step") 
Example #5
Source File: dpAutoRig.py    From dpAutoRigSystem with GNU General Public License v2.0 6 votes vote down vote up
def donateWin(self, *args):
        """ Simple window with links to donate in order to support this free and openSource code via PayPal.
        """
        # declaring variables:
        self.donate_title       = 'dpAutoRig - v'+DPAR_VERSION+' - '+self.langDic[self.langName]['i167_donate']
        self.donate_description = self.langDic[self.langName]['i168_donateDesc']
        self.donate_winWidth    = 305
        self.donate_winHeight   = 300
        self.donate_align       = "center"
        # creating Donate Window:
        if cmds.window('dpDonateWindow', query=True, exists=True):
            cmds.deleteUI('dpDonateWindow', window=True)
        dpDonateWin = cmds.window('dpDonateWindow', title=self.donate_title, iconName='dpInfo', widthHeight=(self.donate_winWidth, self.donate_winHeight), menuBar=False, sizeable=True, minimizeButton=False, maximizeButton=False)
        # creating text layout:
        donateColumnLayout = cmds.columnLayout('donateColumnLayout', adjustableColumn=True, columnOffset=['both', 20], rowSpacing=5, parent=dpDonateWin)
        cmds.separator(style='none', height=10, parent=donateColumnLayout)
        infoDesc = cmds.text(self.donate_description, align=self.donate_align, parent=donateColumnLayout)
        cmds.separator(style='none', height=10, parent=donateColumnLayout)
        brPaypalButton = cmds.button('brlPaypalButton', label=self.langDic[self.langName]['i167_donate']+" - R$ - Real", align=self.donate_align, command=partial(utils.visitWebSite, DONATE+"BRL"), parent=donateColumnLayout)
        #usdPaypalButton = cmds.button('usdPaypalButton', label=self.langDic[self.langName]['i167_donate']+" - USD - Dollar", align=self.donate_align, command=partial(utils.visitWebSite, DONATE+"USD"), parent=donateColumnLayout)
        # call Donate Window:
        cmds.showWindow(dpDonateWin) 
Example #6
Source File: rigutils.py    From DynRigBuilder with MIT License 6 votes vote down vote up
def createCurveFromJoint(joints, name="curve", ibtCVNum=0, degree=3):
    """
    Create a nurbs curve along the given joints
    :param joints: `list` list of joint nodes
    :param name: `string` name of the built surface
    :param ibtCVNum: `int` number of cv points added inbetween the joint position
    :param degree: `int` nurbs surface degree
    :return: `PyNode` result curve
    """
    jntPos = [jnt.getTranslation(space="world") for jnt in joints]
    cvPos = []
    if ibtCVNum>0:
        for i in range(len(jntPos)-1):
            cvPos.append(jntPos[i])
            ratio = (jntPos[i+1]-jntPos[i])/(ibtCVNum+1.0)
            for j in range(1, ibtCVNum+1):
                cvPos.append(jntPos[i]+ratio*j)
        cvPos.append(jntPos[-1])
    else:
        cvPos = jntPos
    auxCrv = pm.curve(p=cvPos, d=degree, n=name)
    pm.rebuildCurve(auxCrv, ch=0, rpo=1, rt=0, end=1, kep=1, kr=0, kcp=0,
                    kt=0, s=len(cvPos)-1, d=degree)
    pm.parent(auxCrv, w=1)
    return auxCrv 
Example #7
Source File: picker.py    From anima with MIT License 6 votes vote down vote up
def set_objects_parent(object_, parent):
#    import oyObjectPicker as oyOP

    selList = pm.ls(sl=True)

#    myPickedObj = oyOP.PickedObject(object_)
    myPickedObj = PickedObject(object_)

    # before seting up check if there is a cycle with the parent
    if myPickedObj.check_cycle(parent):
        object_ = pm.nodetypes.DagNode(object_)
        parent = pm.nodetypes.DagNode(parent)
        pm.PopupError(
            "CYCLE ERROR!!!\n%s is a parent or special object for %s" % (
            object_.name(), parent.name() ))
        # do not setup any object
        return

    myPickedObj.setup_to_be_picked_up()
    myPickedObj.add_new_parent(parent)
    myPickedObj.set_active_parent(parent)
    # reselect selList
    pm.select(selList) 
Example #8
Source File: reference.py    From anima with MIT License 6 votes vote down vote up
def get_no_parent_transform(cls, ref):
        """returns the top most parent node in the given subReferences

        :param ref: pm.nt.FileReference instance
        """
        all_referenced_nodes = ref.nodes()
        for node in all_referenced_nodes:
            if isinstance(node, pm.nt.Transform):
                #print('%s has parent' % node.name())
                parent_node = node.getParent()
                if parent_node not in all_referenced_nodes:
                    return node

        # check sub references
        sub_refs = pm.listReferences(ref)
        for sub_ref in sub_refs:
            no_parent_transform = cls.get_no_parent_transform(sub_ref)
            if no_parent_transform:
                return no_parent_transform 
Example #9
Source File: drawNode.py    From anima with MIT License 6 votes vote down vote up
def create_axialCor(self):
        # Create Axial Correction group
        if self._axialCor is not None:
            temp_grp = pm.group(self.drawnNode, n=(self._axialCor + "_#"))
            self.ofsGrp.append(temp_grp)
        else:
            name = (self.drawnNode + "_axialCor")
            self._axialCor = self._draw(Shape.transform,
                                        (name))

            pm.delete(pm.parentConstraint(self.drawnNode, self.axialCor, mo=0))
            pm.parent(self._drawnNode, self._axialCor)
            #pm.delete(self.create_parentConst(self.drawnNode, self.axialCor))
            #pm.parent(self._drawnNode, self.axialCor)

    # Create Point Constrain 
Example #10
Source File: pivot_switcher.py    From anima with MIT License 6 votes vote down vote up
def setup(self):
        """setups specified object for pivot switching
        """

        # if it is setup before, don't do anything
        if self._isSetup:
            return

        if not self.is_good_for_setup():
            pm.PopupError(
                "the objects pivots are connected to something\n"
                "THE OBJECT CANNOT BE SETUP!!!"
            )
            return

        # create the parent constraint
        self._create_future_pivot()

        # create attributes for data holding
        self._create_data_attribute()

        # save the settings
        self._save_settings()

        self._isSetup = True 
Example #11
Source File: picker.py    From anima with MIT License 6 votes vote down vote up
def create_stabilizer_parent(self):
        """creates the stabilizer parent
        """
        # the new stabilizer parent should be at the origin of the original
        # objects parent so that the keyframes of the object should not be altered

        self._stabilizer_parent = pm.nodetypes.DagNode(
            auxiliary.axial_correction_group(
                self._object,
                to_parents_origin=True
            )
        )

        self._stabilizer_parent = pm.nodetypes.DagNode(
            pm.rename(
                self._stabilizer_parent,
                self._object.name() + "_stabilizer_parent"
            )
        )

        # connect it to the created nodes attribute
        index = self._object.attr('pickedData.createdNodes').numElements()
        self._stabilizer_parent.attr('message') >> \
            self._object.attr('pickedData.createdNodes[' + str(index) + ']') 
Example #12
Source File: picker.py    From anima with MIT License 6 votes vote down vote up
def create_local_parent(self):
        """creates local parent and axial correction group of local parent
        """
        # create the localParent group
        self._local_parent = pm.group(
            em=True,
            n=self._object.name() + "_local_parent"
        )

        # move it to the same place where constrainedParent is
        matrix = pm.xform(self._constrained_parent, q=True, ws=True, m=True)
        pm.xform(self._local_parent, ws=True, m=matrix)

        # parent it to the constrained parents parent
        parents = pm.listRelatives(self._constrained_parent, p=True)

        if len(parents) != 0:
            temp = pm.parent(self._local_parent, parents[0], a=True)
            self._local_parent = temp[0]

        self._local_parent = pm.nodetypes.DagNode(self._local_parent)
        index = self._object.attr('pickedData.createdNodes').numElements()
        self._local_parent.attr('message') >> \
            self._object.attr('pickedData.createdNodes[' + str(index) + ']') 
Example #13
Source File: previs.py    From anima with MIT License 6 votes vote down vote up
def save_as(self, shot_name, child_task_name='Previs'):
        """saves the file under the given shot name
        """
        # first find the shot
        from stalker import Version, Shot, Task
        shot = Shot.query.filter(Shot.name == shot_name).first()
        if not shot:
            raise RuntimeError('No shot found with shot name: %s' % shot_name)

        # get the child task
        child_task = Task.query\
            .filter(Task.parent == shot)\
            .filter(Task.name == child_task_name)\
            .first()

        logged_in_user = LocalSession().logged_in_user

        v = Version(task=child_task, created_by=logged_in_user)
        self.m_env.save_as(v) 
Example #14
Source File: joint.py    From anima with MIT License 6 votes vote down vote up
def set_zero_joint(self):

        #Removes Zero Joint from Joint Chain
        pm.joint(self.jointChain[0], e=True, zso=True, oj='xyz', sao='xup')
        self.zeroJoint = self.jointChain[0]

        self._zeroPos = pm.dt.Point(pm.getAttr(self._zeroJoint.translate))
        self.jointChain.remove(self.jointChain[0])
        self.jointPos.remove(self.jointPos[0])
        pm.joint(self.jointChain[1], e=True, zso=True, oj='xyz', sao='yup')
        for i in range(1, len(self.jointChain)):
            pm.joint(self.jointChain[i], e=True, zso=True, oj='xyz', sao='yup')
            #sets Start End Num Of Joints again
        self._numOfJoints = len(self._jointChain)
        #Orient Zero Joint
        temporalGroup = DrawNode(Shape.transform, 'temporalGroup')
        pm.parent(self.startJoint, temporalGroup.drawnNode)

        print(pm.getAttr(self.zeroJoint.jointOrient))
        pm.setAttr(self.zeroJoint.jointOrientX, 0)
        pm.parent(self.startJoint, self.zeroJoint)
        temporalGroup.delete() 
Example #15
Source File: auxiliary.py    From anima with MIT License 6 votes vote down vote up
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 
Example #16
Source File: general.py    From anima with MIT License 6 votes vote down vote up
def publish_checker(cls):
        """Opens the Publish Checker window without publishing the current
        scene
        """
        import functools
        from anima.env import mayaEnv
        m = mayaEnv.Maya()
        version = m.get_current_version()

        # create the publish window
        from anima.ui import publish_checker
        dialog = publish_checker.UI(
            environment=m,
            publish_callback=None,
            version=version,
            parent=mayaEnv.get_maya_main_window()
        )
        dialog.auto_delete_new_version_on_exit = False
        dialog.show() 
Example #17
Source File: camera_tools.py    From anima with MIT License 6 votes vote down vote up
def create_camera_space_locator(frustum_curve):
    """Creates a locator under the given frame_curve

    :param frustum_curve:
    :return:
    """
    # create the locator
    locator = pm.spaceLocator()
    locator_shape = locator.getShape()
    pm.parent(locator, frustum_curve, r=True)
    locator.tz.set(lock=True, keyable=False)
    locator.rx.set(lock=True, keyable=False)
    locator.ry.set(lock=True, keyable=False)
    locator.rz.set(lock=True, keyable=False)
    pm.transformLimits(locator, tx=(-0.5, 0.5), etx=(True, True))
    pm.transformLimits(locator, ty=(-0.5, 0.5), ety=(True, True))
    locator_shape.localScaleZ.set(0)
    return locator 
Example #18
Source File: rigging.py    From anima with MIT License 6 votes vote down vote up
def finalize_setup(self):
        """does final clean up
        """
        self.check_main_control()

        # group the node together
        parent_group = pm.nt.Transform(name='SquashStretchBendRiggerGroup#')
        pm.parent(self.main_control.getParent(), parent_group)
        pm.parent(self.aim_locator1, parent_group)
        if self.use_squash:
            pm.parent(self.squash_handle, parent_group)

        pm.parent(self.bend_handle, parent_group)

        # set visibilities
        self.aim_locator1.v.set(0)
        if self.use_squash:
            self.squash_handle.v.set(0)
        self.bend_handle.v.set(0)

        # as a gesture select the main control
        pm.select(self.main_control) 
Example #19
Source File: picker.py    From anima with MIT License 5 votes vote down vote up
def add_new_parent(self, parent):
        """adds a new parent
        """
        if not self._is_setup: return

        parent = pm.nodetypes.DagNode(parent)

        # check if this object is allready a parent
        if self.get_weight_alias(parent) is not None:
            return

        # check if there is a cycle between parent and self._object
        if self.check_cycle(parent):
            pm.PopupError(
                "Cycle Warning!!!\nnode is one of the special objects")
            return

        # create parent constraint between new parent and constrained parent
        pm.parentConstraint(parent, self._constrained_parent, w=0, mo=True)

        # set a keyframe for the new parent
        weightAlias = self.get_weight_alias(parent)
        weightAlias.setKey(t=0, v=0, ott='step')

        # add the parent to the DAG Menu
        self.add_parent_to_DAG_menu(parent) 
Example #20
Source File: picker.py    From anima with MIT License 5 votes vote down vote up
def check_cycle(self, node):
        """checks if the given parent is a child of the self._object
        or if it is setup before to be the pickedObject and self._object
        is a parent for it
        """
        # CHECK LEVEL 1
        # check if parent is one of the special object
        if self.is_special_object(node):
            return True

        # CHECK LEVEL 2
        # check if its a pickedObject and self._object is a parent for node

        # create a PickedObject with parent and get the parent list
        node = pm.nodetypes.DagNode(node)
        nodeAsPickedObject = PickedObject(node)

        parentList = list()
        parentList = nodeAsPickedObject.get_parent_list()

        if parentList is None:
            return False
        elif len(parentList) != 0:
            # TRUE if one of the parents of the node is self._object
            if self._object in parentList:
                return True

            # TRUE if one of the parents of the node is a special object
            for p in parentList:
                if self.is_special_object(p):
                    return True
        else:
            return False 
Example #21
Source File: picker.py    From anima with MIT License 5 votes vote down vote up
def get_parent_list(self):
        """returns parent list
        """
        if not self._is_setup:
            return

        return self._parent_constraint.getTargetList() 
Example #22
Source File: picker.py    From anima with MIT License 5 votes vote down vote up
def get_parent_index(self, parent):
        """returns the given parents index
        """
        parent = pm.nodetypes.DagNode(parent)

        parents = self.get_parent_list()

        for i in range(0, len(parents)):
            if parents[i] == parent.name():
                return i

        return -1 
Example #23
Source File: general.py    From anima with MIT License 5 votes vote down vote up
def unshape_parent_nodes(cls):
        """Moves the shape node of a mesh to another transform node as a
        children if the mesh node has other meshes under it. Essentially
        cleaning the scene.
        """
        mesh_nodes_with_transform_children = []
        all_meshes = pm.ls(dag=1, type='mesh')

        for node in all_meshes:
            parent = node.getParent()
            tra_under_shape = pm.ls(
                parent.listRelatives(),
                type='transform'
            )
            if len(tra_under_shape):
                mesh_nodes_with_transform_children.append(parent)

        for node in mesh_nodes_with_transform_children:
            # duplicate the node
            dup = pm.duplicate(node)[0]

            # remove all descendents
            all_descendents = dup.listRelatives(ad=1)
            # remove the shape from the list
            all_descendents.remove(dup.getShape())

            pm.delete(all_descendents)

            # parent under the original node
            pm.parent(dup, node)

            # remove the shape of the original node
            pm.delete(node.getShape()) 
Example #24
Source File: render.py    From anima with MIT License 5 votes vote down vote up
def import_gpu_content(self):
        """imports the selected GPU content
        """
        import os

        imported_nodes = []

        for node in pm.ls(sl=1):
            gpu_node = node.getShape()
            gpu_path = gpu_node.getAttr('cacheFileName')

            new_nodes = pm.mel.eval(
                'AbcImport -mode import -reparent "%s" "%s";' % (node.fullPath(), os.path.expandvars(gpu_path))
            )

            # get imported nodes
            new_nodes = node.getChildren()
            new_nodes.remove(gpu_node)

            imported_node = None

            # filter material node
            for n in new_nodes:
                if n.name() != 'materials':
                    imported_node = n
                else:
                    pm.delete(n)

            if imported_node:
                imported_node.t.set(0, 0, 0)
                imported_node.r.set(0, 0, 0)
                imported_node.s.set(1, 1, 1)
                pm.parent(imported_node, world=1)

                imported_nodes.append(imported_node)

        pm.select(imported_nodes) 
Example #25
Source File: camera_tools.py    From anima with MIT License 5 votes vote down vote up
def create_frustum_curve(camera):
    """Creates a curve showing the frustum of the given camera

    :param camera:
    :return:
    """

    if isinstance(camera, pm.nt.Transform):
        camera_tranform = camera
        camera = camera_tranform.getShape()
    elif isinstance(camera, pm.nt.Camera):
        camera_tranform = camera.getParent()

    # validate the camera
    if not isinstance(camera, pm.nt.Camera):
        raise RuntimeError('Please select a camera')
    
    # create the outer box
    frame_curve = pm.curve(
        d=1,
        p=[(-0.5, 0.5, 0),
           (0.5, 0.5, 0),
           (0.5, -0.5, 0),
           (-0.5, -0.5, 0),
           (-0.5, 0.5, 0)],
        k=[0, 1, 2, 3, 4]
    )

    pm.parent(frame_curve, camera_tranform, r=True)
    # transform the frame curve
    frame_curve.tz.set(-10.0)

    exp = """float $flen = {camera}.focalLength;
float $hfa = {camera}.horizontalFilmAperture * 25.4;
{curve}.sx = {curve}.sy = -{curve}.translateZ * $hfa/ $flen;""".format(
        camera=camera.name(),
        curve=frame_curve.name()
    )
    pm.expression(s=exp, o='', ae=1, uc="all")

    return frame_curve 
Example #26
Source File: picker.py    From anima with MIT License 5 votes vote down vote up
def set_parent():
#    import oyObjectPicker as oyOP

    selList = pm.ls(sl=True)

    if len(selList) >= 2:
        parent = selList[0]
        _object = selList[1]

        set_objects_parent(_object, parent)

    else:
        pm.PopupError(
            "please select first the parent, secondly the child object!!!") 
Example #27
Source File: rigging.py    From anima with MIT License 5 votes vote down vote up
def replace_controller_shape(cls):
        selection = pm.ls(sl=1)
        if len(selection) < 2:
            return
        objects = selection[0]
        joints = selection[1]
        shape = pm.listRelatives(objects, s=True)
        joint_shape = pm.listRelatives(joints, s=True)
        parents = pm.listRelatives(objects, p=True)
        if len(parents):
            temp_list = pm.parent(objects, w=True)
            objects = temp_list
        temp_list = pm.parent(objects, joints)
        objects = temp_list[0]
        pm.makeIdentity(objects, apply=True, t=1, r=1, s=1, n=0)
        temp_list = pm.parent(objects, w=True)
        objects = temp_list[0]
        if len(joint_shape):
            pm.delete(joint_shape)
        for i in range(0, len(shape)):
            name = "%sShape%f" % (joints, (i + 1))
            shape[i] = pm.rename(shape[i], name)
            temp_list = pm.parent(shape[i], joints, r=True, s=True)
            shape[i] = temp_list[0]
        pm.delete(objects)
        pm.select(joints) 
Example #28
Source File: dpAutoRig.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def dpARLoadingWindow():
    """ Just create a Loading window in order to show we are working to user when calling dpAutoRigSystem.
    """
    loadingString = "Loading dpAutoRigSystem v%s ... " %DPAR_VERSION
    print loadingString,
    path = os.path.dirname(__file__)
    randImage = random.randint(0,7)
    clearDPARLoadingWindow()
    cmds.window('dpARLoadWin', title='dpAutoRigSystem', iconName='dpAutoRig', widthHeight=(285, 203), menuBar=False, sizeable=False, minimizeButton=False, maximizeButton=False)
    cmds.columnLayout('dpARLoadLayout')
    cmds.image('loadingImage', image=(path+"/Icons/dp_loading_0%i.png" %randImage), backgroundColor=(0.8, 0.8, 0.8), parent='dpARLoadLayout')
    cmds.text('versionText', label=loadingString, parent='dpARLoadLayout')
    cmds.showWindow('dpARLoadWin') 
Example #29
Source File: rigging.py    From anima with MIT License 5 votes vote down vote up
def create_switch_setup(self):
        """Creates the required IK/FK blend setup
        """
        if self.ik_hierarchy is None:
            raise RuntimeError("No IK hierarchy!")

        if self.fk_hierarchy is None:
            raise RuntimeError("No FK_hierarchy!")

        self.ik_fk_switch_handle, shape = pm.circle(normal=(1, 0, 0), radius=0.5)
        pm.parent(self.ik_fk_switch_handle, self.base_hierarchy.joints[0], r=1)
        pm.parent(self.ik_fk_switch_handle, self.base_hierarchy.joints[0].getParent())
        pm.addAttr(self.ik_fk_switch_handle, sn="ikFkSwitch", dv=0, at="float", min=0, max=1, k=True)

        # reverser
        reverser = pm.nt.Reverse()
        self.ik_fk_switch_handle.ikFkSwitch >> reverser.inputX

        for i in range(len(self.base_hierarchy.joints)):
            bj = self.base_hierarchy.joints[i]
            ikj = self.ik_hierarchy.joints[i]
            fkj = self.fk_hierarchy.joints[i]
            parent_constraint1 = pm.parentConstraint(ikj, bj)
            parent_constraint2 = pm.parentConstraint(fkj, bj)

            # get the weight alias list
            wal = pm.parentConstraint(parent_constraint1, q=1, wal=1)

            reverser.outputX >> wal[0]
            self.ik_fk_switch_handle.ikFkSwitch >> wal[1]

        # lock the transforms
        self.ik_fk_switch_handle.t.setKeyable(False)
        self.ik_fk_switch_handle.t.lock()
        self.ik_fk_switch_handle.r.setKeyable(False)
        self.ik_fk_switch_handle.r.lock()
        self.ik_fk_switch_handle.s.setKeyable(False)
        self.ik_fk_switch_handle.s.lock()
        self.ik_fk_switch_handle.v.setKeyable(False) 
Example #30
Source File: redshift.py    From anima with MIT License 5 votes vote down vote up
def get_parent(self):
        """gets the parent node or creates one
        """
        import pymel.core as pm

        parent_node_name = self.parent_name
        nodes_with_name = pm.ls('|%s' % parent_node_name)
        parent_node = None
        if nodes_with_name:
            parent_node = nodes_with_name[0]

        if not parent_node:
            # create one
            previous_parent = None
            current_node = None
            splits = self.parent_name.split("|")
            for i, node_name in enumerate(splits):
                full_node_name = '|' + '|'.join(splits[:i + 1])
                list_nodes = pm.ls(full_node_name)
                if list_nodes:
                    current_node = list_nodes[0]
                else:
                    current_node = pm.nt.Transform(name=node_name)
                if previous_parent:
                    pm.parent(current_node, previous_parent, r=1)
                previous_parent = current_node

            # parent_node = pm.nt.Transform(name=parent_node_name)
            parent_node = current_node

        return parent_node