def update_info(self): try: item = self.gmcUIInst.component_listView.selectedIndexes()[0] comp_name = item.data() module = shifter.importComponentGuide(comp_name) reload(module) info_text = ("{}\n".format(module.DESCRIPTION) + "\n-------------------------------\n\n" + "Author: {}\n".format(module.AUTHOR) + "Url: {}\n".format(module.URL) + "Version: {}\n".format(str(module.VERSION)) + "Type: {}\n".format(module.TYPE) + "Name: {}\n".format(module.NAME)) except IndexError: info_text = "" self.gmcUIInst.info_plainTextEdit.setPlainText(info_text)
def inspect_settings(tabIdx=0, *args): """Open the component or root setting UI. Args: tabIdx (int, optional): Tab index to be open when open settings *args: None Returns: None: None if nothing is selected """ oSel = pm.selected() if oSel: root = oSel[0] else: pm.displayWarning("please select one object from the componenet guide") return comp_type = False guide_root = False while root: if pm.attributeQuery("comp_type", node=root, ex=True): comp_type = root.attr("comp_type").get() break elif pm.attributeQuery("ismodel", node=root, ex=True): guide_root = root break root = root.getParent() pm.select(root) if comp_type: guide = shifter.importComponentGuide(comp_type) wind = pyqt.showDialog(guide.componentSettings, dockable=True) wind.tabs.setCurrentIndex(tabIdx) return wind elif guide_root: module_name = "mgear.shifter.guide" level = -1 if sys.version_info < (3, 3) else 0 guide = __import__(module_name, globals(), locals(), ["*"], level) wind = pyqt.showDialog(guide.guideSettings, dockable=True) wind.tabs.setCurrentIndex(tabIdx) return wind else: pm.displayError("The selected object is not part of component guide")
def get_component_list(self): comp_list = [] compDir = shifter.getComponentDirectories() trackLoadComponent = [] for path, comps in compDir.items(): pm.progressWindow(title='Loading Components', progress=0, max=len(comps)) for comp_name in comps: pm.progressWindow(e=True, step=1, status='\nLoading: %s' % comp_name) if comp_name == "__init__.py": continue elif comp_name in trackLoadComponent: pm.displayWarning( "Custom component name: %s, already in default " "components. Names should be unique. This component is" " not loaded" % comp_name) continue else: trackLoadComponent.append(comp_name) if not os.path.exists( os.path.join(path, comp_name, "__init__.py")): continue try: module = shifter.importComponentGuide(comp_name) if PY2: reload(module) else: importlib.reload(module) comp_list.append(module.TYPE) except Exception as e: pm.displayWarning( "{} can't be load. Error at import".format(comp_name)) pm.displayError(e) pm.displayError(traceback.format_exc()) pm.progressWindow(e=True, endProgress=True) return comp_list
def _get_chain_segments_length(self, chain_root): module = shifter.importComponentGuide(chain_root.comp_type.get()) componentGuide = getattr(module, "Guide") comp_guide = componentGuide() comp_guide.setFromHierarchy(chain_root) return len(comp_guide.pos)