def getPaletteBoundGeo(self, palName): """doc""" bGeoList = [] for desc in xg.descriptions(palName): bGeoList.extend(xg.boundGeometry(palName, desc)) bGeoList = list(set(bGeoList)) return bGeoList
def exportCurvesMel(palName, descName, fxmName): """Replace original "exportCurvesMel", since "xgmNullRender" will fail if scene is too large """ # select guides pm.select(xg.descriptionGuides(descName), replace=True) # guides to curves pm.mel.xgmCreateCurvesFromGuides(0, False) # add patch to selection pm.select(xg.boundGeometry(palName, descName), add=True)
def _get_scalps(self): """ Gets a list with the used scalps in the descriptions :return: List with the scalps names """ scalps = list() for description in xg.descriptions(str(self.collection_name)): scalpt = xg.boundGeometry(str(self.collection_name), str(description))[0] if scalpt not in scalps: scalps.append(scalpt) return scalps
def list_bound_geometry(description): """Return bounded meshes of the XGen Legacy description Args: description (str): XGen Legacy description name Return: (list): A list of bounded meshes' transform node name """ palette = get_palette_by_description(description) return list(xg.boundGeometry(palette, description))
def setupImportedMap(fileName, palName, descNames, repoProjPath): ''' When import palette or description, set up attributes with map texture. The setup steps include: 1, parses the imported file again; 2, read the "MapTextures" section; 3, for each map, create an attribute for bound geometry; then connect a texture node to the attribute. ''' # parse the file, get its path of pallete fp = open(fileName, 'r') for line in fp: #print line line = line.strip(' \t\r\n') if cmp(line, "Description") == 0: line = fp.next() line = line.strip(' \t\r\n') preDescription = line.split('\t', 3)[3] curDescription = descNames[0] for i in range(len(descNames)): if descNames[i] == preDescription: curDescription = descNames[i] line = fp.next() line = line.strip(' \t\r\n') while line and cmp(line, "endAttrs"): if line.startswith("xgDataPath"): xgDataPath = line.split("\t")[2] if line.startswith("xgProjectPath"): xgProjectPath = repoProjPath palPath = "" if xgDataPath.startswith("${PROJECT}"): palPath = xgDataPath.replace("${PROJECT}", xgProjectPath) # copy description dir projRoot = cmds.workspace(query=True, rootDirectory=True) curPalDir = os.path.join(projRoot, "xgen", "collections", palName) srcdir = os.path.join(palPath, preDescription) dstdir = os.path.join(curPalDir, curDescription) srcdir = os.path.normpath(srcdir) dstdir = os.path.normpath(dstdir) try: dir_util.copy_tree(srcdir, dstdir) except UnicodeDecodeError as e: pass else: cmds.error( 'The [xgDataPath] not starts with "${PROJECT}"') line = fp.next() line = line.strip(' \t\r\n') if cmp(line, "MapTextures") == 0: # [David] Not Sure about this area, relink 3dPaintTool map perhaps geoms = xg.boundGeometry(palName, curDescription) line = fp.next() line = line.strip(' \t\r\n') while line and cmp(line, "endAttrs"): segments = line.split("\t") isColor = cmp(segments[1], "regionMap") == 0 # create attribute for shape and assign texture if isColor: shapeAttrName = xg.createMayaAttr([0.5, 0.5, 0.5], segments[1], palName, curDescription) else: shapeAttrName = xg.createMayaAttr([0.5], segments[1], palName, curDescription) for geom in geoms: texNode = cmds.shadingNode("file", asTexture=True) place2dNode = cmds.shadingNode("place2dTexture", asUtility=True) mel.eval("fileTexturePlacementConnect( \"" + texNode + "\", \"" + place2dNode + "\" )") cmds.connectAttr(place2dNode + ".outUV", texNode + ".uv") cmds.connectAttr(place2dNode + ".outUvFilterSize", texNode + ".uvFilterSize") # [David] Check texture path if len(segments) > 2: cmds.setAttr(texNode + ".ftn", segments[2], type="string") else: cmds.warning('regionMap Path is Empty.') if isColor: ip = texNode + ".outColor" else: ip = texNode + ".outAlpha" shapeChildren = cmds.listRelatives(geoms, shapes=True) shapeAttrName2 = shapeChildren[0] + "." + shapeAttrName conn = cmds.listConnections(shapeAttrName2, destination=False, source=True, plugs=True) if conn: for c in conn: cmds.disconnectAttr(c, shapeAttrName2) cmds.connectAttr(ip, shapeAttrName2) line = fp.next() line = line.strip(' \t\r\n') fp.close()
xgen_item._expanded = False xgen_item._active = True def _collect_xgen_geometry(self, parent_item): try: import xgenm as xg except Exception, e: self.logger.debug(e) return icon_path = os.path.join(self.disk_location, os.pardir, "icons", "XGen.png") collection = xg.palettes()[0] xg_geometry = set() for descriptions in xg.descriptions(collection): geometry = xg.boundGeometry(collection, descriptions) for geo in geometry: xg_geometry.add(geo) _geometry = list(xg_geometry) self.logger.debug("XGen Geometry:%s" % _geometry) _geometry_grp = cmds.listRelatives(_geometry[0], parent=True)[0] xgen_item = parent_item.create_item("maya.session.xggeometry", "XGen Geometry", _geometry_grp) # set the icon for the item xgen_item.set_icon_from_path(icon_path) xgen_item.properties["geometry"] = _geometry_grp xgen_item._expanded = False xgen_item._active = True