Source code for zBuilder.nodes.ziva.zFiber

from zBuilder.nodes import Ziva
import maya.cmds as mc
import maya.mel as mm
import zBuilder.zMaya as mz
import logging

logger = logging.getLogger(__name__)


[docs]class FiberNode(Ziva): """ This node for storing information related to zFibers. """ type = 'zFiber' """ The type of node. """ MAP_LIST = ['weightList[0].weights', 'endPoints'] """ List of maps to store. """ def __init__(self, *args, **kwargs): Ziva.__init__(self, *args, **kwargs)
[docs] def get_map_meshes(self): """ This is the mesh associated with each map in obj.MAP_LIST. Typically it seems to coincide with mesh store in get_association. Sometimes it deviates, so you can override this method to define your own list of meshes against the map list. Returns: list(): of long mesh names. """ return [self.long_association[0], self.long_association[0]]
[docs] def build(self, *args, **kwargs): """ Builds the zFiber in maya scene. Args: attr_filter (dict): Attribute filter on what attributes to get. dictionary is key value where key is node type and value is list of attributes to use. tmp = {'zSolver':['substeps']} interp_maps (str): Interpolating maps. Defaults to ``auto`` permissive (bool): Pass on errors. Defaults to ``True`` """ attr_filter = kwargs.get('attr_filter', list()) permissive = kwargs.get('permissive', True) interp_maps = kwargs.get('interp_maps', 'auto') name = self.name mesh = self.association[0] if mc.objExists(mesh): # get exsisting node names in scene on specific mesh and in data existing_fibers = mm.eval('zQuery -t zFiber {}'.format(mesh)) data_fibers = self.builder.bundle.get_scene_items(type_filter='zFiber', association_filter=mesh) d_index = data_fibers.index(self) if existing_fibers: if d_index < len(existing_fibers): self.mobject = existing_fibers[d_index] mc.rename(existing_fibers[d_index], name) else: mc.select(mesh, r=True) results = mm.eval('ziva -f') self.mobject = results[0] mc.rename(results[0], name) else: mc.select(mesh, r=True) results = mm.eval('ziva -f') self.mobject = results[0] mc.rename(results[0], name) else: logger.warning( mesh + ' does not exist in scene, skipping zFiber creation') # set the attributes self.set_maya_attrs(attr_filter=attr_filter) self.set_maya_weights(interp_maps=interp_maps)