コード例 #1
0
ファイル: libGeo.py プロジェクト: pritishd/PKD_Tools
    def export_hierarchy_obj(self):
        """Export the individual meshes in the hierarchy"""
        file_info = {}
        # Reverse the geo list so that the deepest geo is deleted first in case there is a geo inside geo
        geo_list = self.geo_list
        geo_list.reverse()
        for self.current_target in geo_list:
            pm.delete(self.current_target, ch=1)
            parent = pm.listRelatives(self.current_target, parent=True)
            pm.parent(self.current_target, w=True)
            pm.select(self.current_target)
            path = libFile.linux_path(libFile.join(self.export_dir, self.current_target + ".obj"))
            # Load the obj plugin
            cmds.file(path,
                      pr=1,
                      typ="OBJexport",
                      force=1,
                      options="groups=0;ptgroups=0;materials=0;smoothing=0;normals=0",
                      es=1)
            file_info[self.current_target] = path
            logger.info("Exporting\n%s" % file_info[self.current_target])
            if not self.new_scene and self.cleansing_mode:
                pm.delete(self.current_target)
                pm.refresh()
            else:
                pm.parent(self.current_target, parent)

            self.update_progress()

        # Write the geo file_info
        self.geo_file_info = file_info
コード例 #2
0
ファイル: libGeo.py プロジェクト: pritishd/PKD_Tools
 def import_hierarchy_geo(self):
     """Import all the obj objects"""
     file_info = self.geo_file_info
     for self.current_target in file_info.keys():
         cmds.file(file_info[self.current_target],
                   rpr="PKD_Temp",
                   i=1,
                   type="OBJ",
                   loadReferenceDepth="all",
                   ra=True,
                   mergeNamespacesOnClash=False,
                   options="mo=1")
         # Delete Existing geo if it exists
         if not self.cleansing_mode:
             if pm.objExists(self.current_target):
                 pm.delete(self.current_target)
         logger.info("Importing\n%s" % file_info[self.current_target])
         if self.cleansing_mode:
             os.remove(file_info[self.current_target])
         for top in pm.ls(assemblies=True, ud=True):
             if top.getShape():
                 if top.getShape().type() == "mesh" and top.name() == "PKD_Temp_Mesh":
                     top.rename(self.current_target)
                     pm.select(self.current_target)
                     mel.eval("polySetToFaceNormal")
                     mel.eval("polySoftEdge -a 180 -ch 1 %s" % self.current_target)
                     pm.delete(self.current_target, ch=1)
                     pm.refresh()
         self.update_progress()
コード例 #3
0
def change_tangents(tangent):
    """Function to change the default tangent based
    @param tangent (string) the type of default in and out tangent
    """
    pm.keyTangent(g=True, ott=tangent)
    if tangent == "step":
        pm.keyTangent(itt="clamped", g=True)
    else:
        pm.keyTangent(g=True, itt=tangent)
    logger.info("Current Tangents: %s" % tangent.capitalize())
コード例 #4
0
ファイル: libUtilities.py プロジェクト: pritishd/PKD_Tools
def change_tangents(tangent):
    """Function to change the default tangent based
    @param tangent (string) the type of default in and out tangent
    """
    pm.keyTangent(g=True, ott=tangent)
    if tangent == "step":
        pm.keyTangent(itt="clamped", g=True)
    else:
        pm.keyTangent(g=True, itt=tangent)
    logger.info("Current Tangents: %s" % tangent.capitalize())
コード例 #5
0
ファイル: utils.py プロジェクト: pritishd/PKD_Tools
def exportCrlShapes():
    """Export curve data from the existing curve to a json file"""
    curvesData = {}
    for top in pm.ls(assemblies=True, ud=True):
        if top.getShape().type() == "nurbsCurve":
            detailedInfo = {"cvs": [list(cv) for cv in top.getCVs()],
                            "form": top.f.get(),
                            "degree": top.degree(),
                            "knots": top.numKnots()}
            curvesData[top.name()] = detailedInfo

    libFile.write_json(CTRLS_INFO_INFO, curvesData)
    logger.info("Curve information written to: %s" % CTRLS_INFO_INFO)
コード例 #6
0
ファイル: utils.py プロジェクト: pritishd/PKD_Tools
def exportCrlShapes():
    """Export curve data from the existing curve to a json file"""
    curvesData = {}
    for top in pm.ls(assemblies=True, ud=True):
        if top.getShape().type() == "nurbsCurve":
            detailedInfo = {
                "cvs": [list(cv) for cv in top.getCVs()],
                "form": top.f.get(),
                "degree": top.degree(),
                "knots": top.numKnots()
            }
            curvesData[top.name()] = detailedInfo

    libFile.write_json(CTRLS_INFO_INFO, curvesData)
    logger.info("Curve information written to: %s" % CTRLS_INFO_INFO)
コード例 #7
0
ファイル: libGUI.py プロジェクト: pritishd/PKD_Tools
 def zero_out_bend(self):
     """Zero out the bend axis"""
     joint_list = None
     if self.joint:
         joint_list = libJoint.get_joint_children(self.joint)
     axis = self.bend_list.currentText()
     rotate_order = self.current_rotate_order
     if self.details:
         logger.info("Current rotate order: {}".format(self.current_rotate_order))
     self.current_rotate_order = libJoint.zero_out_bend(**locals()) or rotate_order
     if self.details:
         logger.info("New rotate order: {}".format(self.current_rotate_order))
     if self.joint and self.current_rotate_order:
         libUtilities.force_pynode(self.joint).rotateOrder.set(self.current_rotate_order)
     if rotate_order != self.current_rotate_order:
         # Update the gimbal data
         self.update_gimbal_axis()
コード例 #8
0
ファイル: libGUI.py プロジェクト: pritishd/PKD_Tools
    def set_ui_from_gimbal_data(self):
        def set_combo_box(combo_box, search):
            index = combo_box.findText(search, libPySide.QtCore.Qt.MatchFixedString)
            if index >= 0:
                combo_box.setCurrentIndex(index)

        gimbal_data = self.gimbal_data.copy()
        current_gimbal = gimbal_data["gimbal"]
        gimbal_data["gimbal"] = "roll"
        self.current_rotate_order = libJoint.get_rotate_order(gimbal_data)
        if self.details:
            logger.info(self.current_rotate_order)
        set_combo_box(self.up_combo, gimbal_data['twist'])
        set_combo_box(self.forward_combo, gimbal_data['roll'])
        self.set_bend_axis()

        set_combo_box(self.bend_list, gimbal_data['bend'])
        self.set_gimbal_axis(gimbal_data)
        set_combo_box(self.gimbal_list, self.gimbal_data[current_gimbal])
コード例 #9
0
    def set_ui_from_gimbal_data(self):
        def set_combo_box(combo_box, search):
            index = combo_box.findText(search,
                                       libPySide.QtCore.Qt.MatchFixedString)
            if index >= 0:
                combo_box.setCurrentIndex(index)

        gimbal_data = self.gimbal_data.copy()
        current_gimbal = gimbal_data["gimbal"]
        gimbal_data["gimbal"] = "roll"
        self.current_rotate_order = libJoint.get_rotate_order(gimbal_data)
        if self.details:
            logger.info(self.current_rotate_order)
        set_combo_box(self.up_combo, gimbal_data['twist'])
        set_combo_box(self.forward_combo, gimbal_data['roll'])
        self.set_bend_axis()

        set_combo_box(self.bend_list, gimbal_data['bend'])
        self.set_gimbal_axis(gimbal_data)
        set_combo_box(self.gimbal_list, self.gimbal_data[current_gimbal])
コード例 #10
0
 def zero_out_bend(self):
     """Zero out the bend axis"""
     joint_list = None
     if self.joint:
         joint_list = libJoint.get_joint_children(self.joint)
     axis = self.bend_list.currentText()
     rotate_order = self.current_rotate_order
     if self.details:
         logger.info("Current rotate order: {}".format(
             self.current_rotate_order))
     self.current_rotate_order = libJoint.zero_out_bend(
         **locals()) or rotate_order
     if self.details:
         logger.info("New rotate order: {}".format(
             self.current_rotate_order))
     if self.joint and self.current_rotate_order:
         libUtilities.force_pynode(self.joint).rotateOrder.set(
             self.current_rotate_order)
     if rotate_order != self.current_rotate_order:
         # Update the gimbal data
         self.update_gimbal_axis()
コード例 #11
0
ファイル: libGUI.py プロジェクト: pritishd/PKD_Tools
 def orient(self):
     """Orient the joint based on the widget values. Raises a error if incorrect combo is found"""
     up = self.up_combo.currentText()
     forward = self.forward_combo.currentText()
     if up == forward:
         sameComboMsg = libPySide.QCriticalBox()
         sameComboMsg.setText("<b><i>Up</i></b> axis and <b><i>Forward</i><b> axis are the same <br>"
                              "Please ensure that up and forward axis are different")
         sameComboMsg.setWindowTitle("Chosen axis error")
         sameComboMsg.exec_()
         pm.error("Same axis selected")
     joint = self.joint
     flip_forward = self.flip_forward_check.isChecked()
     flip_up = self.flip_up_check.isChecked()
     details = self.details
     self.current_rotate_order = libJoint.orient_joint(**locals())
     self.gimbal_data["flip_up"] = flip_up
     self.gimbal_data["flip_forward"] = flip_forward
     if self.details:
         logger.info("Current rotate order: {}".format(self.current_rotate_order))
     self.update_gimbal_axis()
     self.set_bend_axis()
コード例 #12
0
ファイル: libPySide.py プロジェクト: pritishd/PKD_Tools
    def _setup_(self):
        super(TestGUI, self)._setup_()
        logger.info("Child Info Called")
        # Create a series of rows, and in each row, put our buttons
        for row in self.rows:

            self.row_Hbox = QtGui.QGroupBox()
            self.layout = QtGui.QGridLayout()

            for button in self.buttons:
                # Label the button with it's list name
                self.push_button = QtGui.QPushButton(button, self)

                # Give each button a unique object name
                self.b_name = row + "_" + button
                self.push_button.setObjectName(self.b_name)

                # Add a QLine Edit to each particular button
                self.q_line_name = self.b_name + "_TextEdit"
                self.my_line_edit = QtGui.QLineEdit()
                self.my_line_edit.setText("Hi! I'm " + self.q_line_name)

                # Also give it a unique name
                self.my_line_edit.setObjectName(self.q_line_name)

                # Offset each button in the layout by it's index number
                self.layout.addWidget(self.push_button, 0,
                                      self.buttons.index(button))

                # Offset each QLine Edit in the layout to be underneath each button
                self.layout.addWidget(self.my_line_edit, 1,
                                      self.buttons.index(button))

                # Connect the button to an event
                self.push_button.clicked.connect(self.on_button_event)

            # Add the buttons to our layout
            self.row_Hbox.setLayout(self.layout)
            self.mainLayout.addWidget(self.row_Hbox)
コード例 #13
0
ファイル: libPySide.py プロジェクト: pritishd/PKD_Tools
    def show(self, *args, **kwargs):
        """Create Dockable UI"""

        # Set the docked object name
        dockedName = (self.objectName() + "Dock")
        # Set the default docked object name
        floatingState = self.init_float_state
        if cmds.dockControl(dockedName, q=1, ex=1):
            # If the docked UI exists get the float status before deleting
            floatingState = cmds.dockControl(dockedName, q=1, floating=1)
            # Delete the UI
            cmds.deleteUI(dockedName)
        try:
            self._dockedwidget_ = cmds.dockControl(
                dockedName,
                label=self.windowTitle(),
                allowedArea='all',
                area='right',
                floating=floatingState,
                content=self.objectName(),
                floatChangeCommand=self._autoResize_)
        except Exception, e:
            logger.info(str(e))
            logger.info("Maya dock window failed")
コード例 #14
0
 def orient(self):
     """Orient the joint based on the widget values. Raises a error if incorrect combo is found"""
     up = self.up_combo.currentText()
     forward = self.forward_combo.currentText()
     if up == forward:
         sameComboMsg = libPySide.QCriticalBox()
         sameComboMsg.setText(
             "<b><i>Up</i></b> axis and <b><i>Forward</i><b> axis are the same <br>"
             "Please ensure that up and forward axis are different")
         sameComboMsg.setWindowTitle("Chosen axis error")
         sameComboMsg.exec_()
         pm.error("Same axis selected")
     joint = self.joint
     flip_forward = self.flip_forward_check.isChecked()
     flip_up = self.flip_up_check.isChecked()
     details = self.details
     self.current_rotate_order = libJoint.orient_joint(**locals())
     self.gimbal_data["flip_up"] = flip_up
     self.gimbal_data["flip_forward"] = flip_forward
     if self.details:
         logger.info("Current rotate order: {}".format(
             self.current_rotate_order))
     self.update_gimbal_axis()
     self.set_bend_axis()
コード例 #15
0
ファイル: libGeo.py プロジェクト: pritishd/PKD_Tools
def convert_joint_to_cluster(targetGeo, skipList=None, info=False):
    """
    Convert a skin cluster to a cluster based setup on a target geometery
    @param info: Whether to just query the data for in case we are building it later
    @param skipList: The joints which need to be skipped
    @param targetGeo: (string/pynode) The geometry which has the skin cluster
    @param skipList: (list) Any joints which should not processed such as a base joint
    @return A dictionary of cluster with the name of the joints as keys

    """
    if skipList is None:
        skipList = []
        # Convert to PyNode
    targetGeo = libUtilities.force_pynode(targetGeo)
    skin_name = libUtilities.get_target_defomer(targetGeo, "skinCluster")
    skin = libUtilities.force_pynode(skin_name)
    # Create the dictionary
    clusterInfo = {}
    # Progress Info
    pm.progressWindow(title='Converting Skin To Cluster', progress=0, status='Progress: 0%')
    totalJnts = len(skin.getInfluence()) - len(skipList)
    currentJnt = 0.0

    # Go through Each Joint
    for jnt in sorted(skin.getInfluence()):
        if jnt.name() in skipList:
            continue
        # Get the vertex affected and the weight
        vertZip, weightList = skin.getPointsAffectedByInfluence(jnt)
        if not vertZip:
            raise RuntimeError("Current Joint Has No Vertices:%s" % jnt)
        pm.select(vertZip)

        # Iterate through selection and decompress vertix group into individual index
        vertices = libUtilities.indexize_vertice_group(pm.selected())

        joint_position = pm.xform(jnt, q=1, ws=1, rp=1)
        # Select Vertices
        if info:
            clusterInfo[jnt.name()] = {"vertices": libUtilities.stringList(vertices),
                                       "weight": weightList,
                                       "position": joint_position}
        else:
            libUtilities.select_vertices(targetGeo, vertices)
            # Make a cluster
            cluster_info = weighted_cluster(targetGeo, vertices, weightList, joint_position)

            # Add to dictionary
            clusterInfo[jnt.name()] = cluster_info

        # Update Progress
        currentJnt += 1.0
        currentProgress = (currentJnt / totalJnts) * 100
        pm.progressWindow(edit=True, progress=currentProgress, status=('Progress: ' + str(int(currentProgress)) + '%'))
        pm.refresh()
        if info:
            logger.info("Info gathered: " + jnt.name())
        else:
            logger.info("Converted: " + jnt.name())

    pm.progressWindow(endProgress=1)
    return clusterInfo
コード例 #16
0
ファイル: libGeo.py プロジェクト: pritishd/PKD_Tools
 def cleanse_geo(self):
     """Cleanse the model of all issues with the help of obj"""
     self.export_all()
     self.setup_cleanse_scene()
     self.import_all()
     logger.info("Scene Is Cleansed")