Ejemplo n.º 1
0
 def _fnc_info(self):
     #>> validate ============================================================================
     #_validate our source
     _data = self.d_kws['data']
     if isinstance(type(_data),type(data)):
         self.mData = _data
     else:
         raise ValueError,"Not a data instance"
     
     if not _data.d_source:
         raise ValueError,"No source data on data object"
     if not _data.d_target:
         raise ValueError,"No target data on data object"
     if not _data.d_sourceInfluences:
         return self._FailBreak_("No influence data. Read a config file to the data object.")
     
     _influenceMode = self.d_kws.get('influenceMode')
     if _influenceMode in _d_influenceModes.keys():
         self._influenceMode = _influenceMode
         self.log_info("influenceMode: '{0}'".format(_influenceMode))
     else:
         return self._FailBreak_("Unknown influenceMode arg ['{0}'] | Valid args{1}".format(_influenceMode,_d_influenceModes.keys()))                
     
     self._b_nameMatch = cgmValid.boolArg(self.d_kws.get('nameMatch',False))
     self._b_addMissingInfluences = cgmValid.boolArg(self.d_kws.get('addMissingInfluences',False))
     self._b_case_addMissingInfluences = False
     self._l_missingInfluences = []
     
     #self.report()
     self._d_jointToWeighting = {}
     self._d_vertToWeighting = {}
     self._l_processed = []
     self._b_smooth = False#...whether to smooth at the end of the weight copy
Ejemplo n.º 2
0
        def _validate(self):
            assert type(self.d_kws['addExtraGroups']) in [int, bool]
            assert type(self.d_kws['addSpacePivots']) in [int, bool]

            i_obj = self.mi_control
            self.mi_control = cgmMeta.asMeta(i_obj,
                                             'cgmControl',
                                             setClass=True)

            self.str_mirrorAxis = VALID.stringArg(
                self.d_kws['mirrorAxis'], calledFrom=self._str_funcCombined)
            self.str_mirrorSide = VALID.stringArg(
                self.d_kws['mirrorSide'], calledFrom=self._str_funcCombined)
            self.b_makeMirrorable = VALID.boolArg(
                self.d_kws['makeMirrorable'],
                calledFrom=self._str_funcCombined)

            self._addMirrorAttributeBridges = self.d_kws.get(
                'addMirrorAttributeBridges') or False
            if self._addMirrorAttributeBridges:
                if type(self._addMirrorAttributeBridges) not in [list, tuple]:
                    raise StandardError, "[Bad addMirrorAttributeBridge arg]{arg: %s}" % self._addMirrorAttributeBridge
                for i, l in enumerate(self._addMirrorAttributeBridges):
                    if type(l) not in [list, tuple]:
                        raise StandardError, "[Bad addMirrorAttributeBridge arg: %s]{arg: %s}" % (
                            i, l)
            # Running lists ------------------------------------------------------------------------------------------
            self.ml_groups = []  #Holder for groups
            self.ml_constraintGroups = []
            self.ml_spacePivots = []
Ejemplo n.º 3
0
	def __func__(self):
	    """
	    """
	    self.mi_baseCurve = cgmMeta.validateObjArg(self.d_kws['baseCurve'],mayaType='nurbsCurve',noneValid=False)
	    self._str_funcCombined = self._str_funcCombined + "(%s)"%self.mi_baseCurve.p_nameShort
	    
	    self.str_arg = cgmValid.stringArg(self.d_kws['arg'],noneValid=True)
	    self.b_keepOriginal = cgmValid.boolArg(self.d_kws['keepOriginal'], calledFrom=self._str_funcCombined)
	    
	    if isEP(self.mi_baseCurve):
		log.warning("%s %s already an ep curve"%(self._str_reportStart,self.mi_baseCurve.p_nameShort))
		return False
	    
	    mi_crv = self.mi_baseCurve
	    if self.str_arg.lower() == 'ep':
		l_pos = []
		for cv in mi_crv.getComponents('cv'):
		    locatorName = locators.locMeObject(cv)
		    pos = distance.returnClosestUPosition(locatorName,mi_crv.mNode)
		    mc.delete(locatorName)
		    l_pos.append( pos )	
		if not self.b_keepOriginal:mi_crv.delete()
		return mc.curve(d = 2,ep = l_pos, os = True)
		#return curves.curveFromPosList(l_pos)
	    raise NotImplementedError,"arg: %s"%self.str_arg
Ejemplo n.º 4
0
        def _fnc_info(self):
            #>> validate ============================================================================
            #_validate our source
            _data = self.d_kws['data']
            if isinstance(type(_data), type(data)):
                self.mData = _data
            else:
                raise ValueError, "Not a data instance"

            if not _data.d_source:
                raise ValueError, "No source data on data object"
            if not _data.d_target:
                raise ValueError, "No target data on data object"
            if not _data.d_sourceInfluences:
                return self._FailBreak_(
                    "No influence data. Read a config file to the data object."
                )

            _influenceMode = self.d_kws.get('influenceMode')
            if _influenceMode in _d_influenceModes.keys():
                self._influenceMode = _influenceMode
                self.log_info("influenceMode: '{0}'".format(_influenceMode))
            else:
                return self._FailBreak_(
                    "Unknown influenceMode arg ['{0}'] | Valid args{1}".format(
                        _influenceMode, _d_influenceModes.keys()))

            if not self.mData.d_target:
                raise ValueError, "No target mesh"
            self._b_nameMatch = cgmValid.boolArg(
                self.d_kws.get('nameMatch', False))
            self._b_forceClosestComponent = cgmValid.boolArg(
                self.d_kws.get('forceClosestComponent', False))
            self._b_addMissingInfluences = cgmValid.boolArg(
                self.d_kws.get('addMissingInfluences', False))
            self._b_case_addMissingInfluences = False
            self._l_missingInfluences = []

            #self.report()
            self._d_jointToWeighting = {}
            self._d_vertToWeighting = {}
            self._l_processed = []
            self._b_smooth = False  #...whether to smooth at the end of the weight copy
Ejemplo n.º 5
0
 def _validate_(self):
     self.int_value = int(cgmValid.valueArg(self.d_kws['value'],noneValid=False))
     self.l_valueBuffer = [i for i in range(self.int_value)]
     self.b_testException = cgmValid.boolArg(self.d_kws['testException'])
     self.log_debug("Debug in _validate_")
     #For each of our test values, we're gonna create a transform and store it
     self.md_idxToObj = {}
     self.md_shortNameToIdx = {}
     self.log_error("Test error")
     self.log_warning("Test warning")	    
     self.log_toDo("Note to self -- do this sometime")
Ejemplo n.º 6
0
        def _validate_(self):
	    mc.file(new=True,f=True)
            self.int_iterations = int(cgmValid.valueArg(self.d_kws['iterations'],noneValid=False))
            self.int_children = int(cgmValid.valueArg(self.d_kws['childrenCount'],noneValid=False))
            self.b_po = cgmValid.boolArg(self.d_kws['parentOnly'],noneValid=False)            
	    
            self.l_valueBuffer = [i for i in range(self.int_iterations)]
            self.log_debug("Debug in _validate_")
            #For each of our test values, we're gonna create a transform and store it
            self.md_rootToChildren = {}
            self.l_times_1 = []
	    self.l_times_2 = []
	    self.l_roots_1  = []
	    self.l_roots_2 = []
Ejemplo n.º 7
0
        def _validate(self):
            assert type(self.d_kws['addExtraGroups']) in [int,bool]
            assert type(self.d_kws['addSpacePivots']) in [int,bool]

            i_obj = self.mi_control
            self.mi_control = cgmMeta.asMeta(i_obj,'cgmControl', setClass=True)

            self.str_mirrorAxis = cgmValid.stringArg(self.d_kws['mirrorAxis'],calledFrom = self._str_funcCombined)
            self.str_mirrorSide = cgmValid.stringArg(self.d_kws['mirrorSide'],calledFrom = self._str_funcCombined)
            self.b_makeMirrorable = cgmValid.boolArg(self.d_kws['makeMirrorable'],calledFrom = self._str_funcCombined)

            self._addMirrorAttributeBridges = self.d_kws.get('addMirrorAttributeBridges') or False
            if self._addMirrorAttributeBridges :
                if type(self._addMirrorAttributeBridges ) not in [list,tuple]:raise StandardError,"[Bad addMirrorAttributeBridge arg]{arg: %s}"%self._addMirrorAttributeBridge 
                for i,l in enumerate(self._addMirrorAttributeBridges):
                    if type(l) not in [list,tuple]:raise StandardError,"[Bad addMirrorAttributeBridge arg: %s]{arg: %s}"%(i,l) 			
            # Running lists ------------------------------------------------------------------------------------------
            self.ml_groups = []#Holder for groups
            self.ml_constraintGroups = []
            self.ml_spacePivots = []
Ejemplo n.º 8
0
        def _validate(self):
            #>> validate ============================================================================
            self.mi_obj = cgmMeta.validateObjArg(self.d_kws['objToAttach'],
                                                 cgmMeta.cgmObject,
                                                 noneValid=False)
            self.mi_targetSurface = cgmMeta.validateObjArg(
                self.d_kws['targetSurface'], noneValid=False)
            self.mi_orientation = VALID.simpleOrientation(
                self.d_kws['orientation'])
            self._str_funcCombined = self._str_funcCombined + "(%s,%s)" % (
                self.mi_obj.p_nameShort, self.mi_targetSurface.p_nameShort)

            self.l_shapes = mc.listRelatives(self.mi_targetSurface.mNode,
                                             shapes=True)
            if len(self.l_shapes) > 1:
                log.debug(
                    "More than one shape found. Using 0. targetSurface : %s | shapes: %s"
                    % (self.mi_targetSurface.p_nameShort, self.l_shapes))
            self.mi_shape = cgmMeta.validateObjArg(self.l_shapes[0],
                                                   cgmMeta.cgmNode,
                                                   noneValid=False)
            self.b_createControlLoc = VALID.boolArg(
                self.d_kws['createControlLoc'],
                calledFrom=self._str_funcCombined)
            self.b_createUpLoc = VALID.boolArg(
                self.d_kws['createUpLoc'], calledFrom=self._str_funcCombined)
            self.b_parentToFollowGroup = VALID.boolArg(
                self.d_kws['parentToFollowGroup'],
                calledFrom=self._str_funcCombined)
            self.b_attachControlLoc = VALID.boolArg(
                self.d_kws['attachControlLoc'],
                calledFrom=self._str_funcCombined)
            self.b_connectOffset = VALID.boolArg(
                self.d_kws['connectOffset'], calledFrom=self._str_funcCombined)
            self.b_pointAttach = VALID.boolArg(
                self.d_kws['pointAttach'], calledFrom=self._str_funcCombined)

            self.f_offset = VALID.valueArg(self.d_kws['f_offset'],
                                           calledFrom=self._str_funcCombined)
            #Get info ============================================================================
            self.d_closestInfo = distance.returnClosestPointOnSurfaceInfo(
                self.mi_obj.mNode, self.mi_targetSurface.mNode)
            self.d_closestInfo = DIST.get_closest_point_data_from_mesh(
                self.mi_obj.mNode, self.mi_targetSurface.mNode)
            #Running Lists ============================================================================
            self.md_return = {}
Ejemplo n.º 9
0
	def _validate(self):
	    #>> validate ============================================================================
	    self.mi_obj = cgmMeta.validateObjArg(self.d_kws['objToAttach'],cgmMeta.cgmObject,noneValid=False)
	    self.mi_targetSurface = cgmMeta.validateObjArg(self.d_kws['targetSurface'],mayaType='nurbsSurface',noneValid=False)
	    self.mi_orientation = cgmValid.simpleOrientation( self.d_kws['orientation'] )
	    self._str_funcCombined = self._str_funcCombined + "(%s,%s)"%(self.mi_obj.p_nameShort,self.mi_targetSurface.p_nameShort)
	    
	    self.l_shapes = mc.listRelatives(self.mi_targetSurface.mNode,shapes=True)
	    if len(self.l_shapes)>1:
		log.debug( "More than one shape found. Using 0. targetSurface : %s | shapes: %s"%(self.mi_targetSurface.p_nameShort,self.l_shapes) )
	    self.mi_shape = cgmMeta.validateObjArg(self.l_shapes[0],cgmMeta.cgmNode,noneValid=False)
	    self.b_createControlLoc = cgmValid.boolArg(self.d_kws['createControlLoc'],calledFrom=self._str_funcCombined)
	    self.b_createUpLoc = cgmValid.boolArg(self.d_kws['createUpLoc'],calledFrom=self._str_funcCombined)
	    self.b_parentToFollowGroup = cgmValid.boolArg(self.d_kws['parentToFollowGroup'],calledFrom=self._str_funcCombined)
	    self.b_attachControlLoc = cgmValid.boolArg(self.d_kws['attachControlLoc'],calledFrom=self._str_funcCombined)
	    self.b_connectOffset = cgmValid.boolArg(self.d_kws['connectOffset'],calledFrom=self._str_funcCombined)
	    self.b_pointAttach = cgmValid.boolArg(self.d_kws['pointAttach'],calledFrom=self._str_funcCombined)
	    
	    self.f_offset = cgmValid.valueArg(self.d_kws['f_offset'], calledFrom=self._str_funcCombined)
	    #Get info ============================================================================
	    self.d_closestInfo = distance.returnClosestPointOnSurfaceInfo(self.mi_obj.mNode,self.mi_targetSurface.mNode)
	    
	    #Running Lists ============================================================================
	    self.md_return = {}
 def test_true(self):
     self.assertTrue(
         validateArgs.boolArg(True),
         "validateArgs.boolArg did not return True for True"
     )
Ejemplo n.º 11
0
	def __func__(self):
	    """
	    """
	    _str_funcName = self._str_funcCombined
	    points = self.d_kws['points']
	    int_points = cgmValid.valueArg(self.d_kws['points'],minValue=1,calledFrom = _str_funcName)
	    f_insetSplitFactor = cgmValid.valueArg(self.d_kws['insetSplitFactor'],calledFrom = _str_funcName)	
	    f_startSplitFactor = cgmValid.valueArg(self.d_kws['startSplitFactor'],calledFrom = _str_funcName)		
	    f_minU = cgmValid.valueArg(self.d_kws['minU'], noneValid=True, calledFrom = _str_funcName)
	    f_maxU = cgmValid.valueArg(self.d_kws['maxU'], noneValid=True, calledFrom = _str_funcName)    
	    f_points = float(int_points)
	    int_spans = int(cgmValid.valueArg(self.d_kws['points'],minValue=5,autoClamp=True,calledFrom = _str_funcName))
	    b_cullStartEnd = cgmValid.boolArg(self.d_kws['cullStartEnd'], calledFrom = _str_funcName)
	    
	    if f_insetSplitFactor is not False or f_startSplitFactor is not False:
		if not isFloatEquivalent(f_minU,0):
		    raise StandardError,"Min U must be 0 when f_insetSplitFactor or f_startSplitFactor are used"
	    
	    try:#>>> Divide stuff
		#==========================	
		l_spanUPositions = []    
		l_uValues = [f_minU]
	
		if f_startSplitFactor is not False:
		    if points < 5:
			raise StandardError,"Need at least 5 points for startSplitFactor. Points : %s"%(points)
		    log.debug("%s >> f_startSplitFactor : %s"%(_str_funcName,f_startSplitFactor))  
		    #Figure out our u's
		    f_base = f_startSplitFactor * f_maxU 
		    l_uValues.append( f_base )
		    f_len = f_maxU - (f_base *2)	
		    int_toMake = f_points-4
		    f_factor = f_len/(int_toMake+1)
		    log.debug("%s >> f_maxU : %s"%(_str_funcName,f_maxU)) 
		    log.debug("%s >> f_len : %s"%(_str_funcName,f_len)) 	
		    log.debug("%s >> int_toMake : %s"%(_str_funcName,int_toMake)) 						
		    log.debug("%s >> f_base : %s"%(_str_funcName,f_base)) 			
		    log.debug("%s >> f_factor : %s"%(_str_funcName,f_factor))               
		    for i in range(1,int_points-3):
			l_uValues.append(((i*f_factor + f_base)))
		    l_uValues.append(f_maxU - f_base)
		    l_uValues.append(f_maxU)
		    log.debug("%s >> l_uValues : %s"%(_str_funcName,l_uValues))  	
		    
		elif f_insetSplitFactor is not False:
		    log.debug("%s >> f_insetSplitFactor : %s"%(_str_funcName,f_insetSplitFactor))  
		    #Figure out our u's
		    
		    f_base = f_insetSplitFactor * f_maxU 
		    f_len = f_maxU - (f_base *2)	
		    f_factor = f_len/(f_points-1)
		    
		    #f_base = (f_maxU - f_minU) * f_insetSplitFactor
		    #f_len = (f_maxU - f_base) - (f_minU + f_base)
		    #f_factor = f_len/(f_points-1)
		    log.debug("%s >> f_maxU : %s"%(_str_funcName,f_maxU)) 
		    log.debug("%s >> f_base : %s"%(_str_funcName,f_base)) 					    
		    log.debug("%s >> f_len : %s"%(_str_funcName,f_len)) 			
		    log.debug("%s >> f_factor : %s"%(_str_funcName,f_factor))               
		    for i in range(1,int_points-1):
			l_uValues.append(((i*f_factor)+f_base))
		    l_uValues.append(f_maxU)
		    log.debug("%s >> l_uValues : %s"%(_str_funcName,l_uValues))

		else:
		    #Figure out our u's
		    log.debug("%s >> Regular mode. Points = %s "%(_str_funcName,int_points))
		    if int_points == 1:
			l_uValues = [((f_maxU - f_minU)/2)+f_minU]
		    elif int_points == 2:
			l_uValues = [f_minU,f_maxU]
		    elif int_points == 3:
			l_uValues.append(((f_maxU - f_minU)/2)+f_minU)
			l_uValues.append(f_maxU)
		    else:
			f_factor = (f_maxU-f_minU)/(f_points-1)
			log.debug("%s >> f_maxU : %s"%(_str_funcName,f_maxU)) 
			log.debug("%s >> f_factor : %s"%(_str_funcName,f_factor))               
			for i in range(1,int_points-1):
			    l_uValues.append((i*f_factor)+f_minU)
			l_uValues.append(f_maxU)
		    log.debug("%s >> l_uValues : %s"%(_str_funcName,l_uValues))  
		    
		if b_cullStartEnd and len(l_uValues)>3:
		    l_uValues = l_uValues[1:-1]
	    except Exception,error:raise StandardError,"Divide fail | %s"%error
    
	    return l_uValues	    
Ejemplo n.º 12
0
	def __func__(self):
	    """
	    """
	    _str_funcName = self._str_funcCombined
	    curve = self.d_kws['curve']
	    points = self.d_kws['points']
	    mi_crv = cgmMeta.validateObjArg(self.d_kws['curve'],cgmMeta.cgmObject,mayaType='nurbsCurve',noneValid=False)
	    int_points = cgmValid.valueArg(self.d_kws['points'],minValue=1,calledFrom = _str_funcName)
	    f_insetSplitFactor = cgmValid.valueArg(self.d_kws['insetSplitFactor'],calledFrom = _str_funcName)	
	    f_startSplitFactor = cgmValid.valueArg(self.d_kws['startSplitFactor'],calledFrom = _str_funcName)		
	    f_kwMinU = cgmValid.valueArg(self.d_kws['minU'], noneValid=True, calledFrom = _str_funcName)	
	    f_kwMaxU = cgmValid.valueArg(self.d_kws['maxU'], noneValid=True, calledFrom = _str_funcName)	    
	    f_points = float(int_points)
	    int_spans = int(cgmValid.valueArg(self.d_kws['points'],minValue=5,autoClamp=True,calledFrom = _str_funcName))
	    b_rebuild = cgmValid.boolArg(self.d_kws['rebuildForSplit'],calledFrom = _str_funcName)
	    b_markPoints = cgmValid.boolArg(self.d_kws['markPoints'],calledFrom = _str_funcName)
	    b_reverseCurve = cgmValid.boolArg(self.d_kws['reverseCurve'],calledFrom = _str_funcName)
	    
	    try:#>>> Rebuild curve
		if b_rebuild:
		    useCurve = mc.rebuildCurve (curve, ch=0, rpo=0, rt=0, end=1, kr=0, kcp=0, kep=1, kt=0, s=int_spans, d=3, tol=0.001)[0]
		else:
		    useCurve = mc.duplicate(curve)[0]
		    
		if b_reverseCurve:
		    useCurve = mc.reverseCurve(useCurve,rpo = True)[0]
	    except Exception,error:raise StandardError,"Rebuild fail | %s"%error
	    
	    try:#>>> Divide stuff
		#==========================	
		l_spanUPositions = []
		str_bufferU = mc.ls("%s.u[*]"%useCurve)[0]
		log.debug("%s >> u list : %s"%(_str_funcName,str_bufferU))       
		f_maxU = float(str_bufferU.split(':')[-1].split(']')[0])
		l_uValues = [0]
		
		if points == 1:
		    l_uValues = [f_maxU/2]
		elif f_startSplitFactor is not False:
		    if points < 5:
			raise StandardError,"Need at least 5 points for startSplitFactor. Points : %s"%(points)
		    log.debug("%s >> f_startSplitFactor : %s"%(_str_funcName,f_startSplitFactor))  
		    #Figure out our u's
		    f_base = f_startSplitFactor * f_maxU 
		    l_uValues.append( f_base )
		    f_len = f_maxU - (f_base *2)	
		    int_toMake = f_points-4
		    f_factor = f_len/(int_toMake+1)
		    log.debug("%s >> f_maxU : %s"%(_str_funcName,f_maxU)) 
		    log.debug("%s >> f_len : %s"%(_str_funcName,f_len)) 	
		    log.debug("%s >> int_toMake : %s"%(_str_funcName,int_toMake)) 						
		    log.debug("%s >> f_base : %s"%(_str_funcName,f_base)) 			
		    log.debug("%s >> f_factor : %s"%(_str_funcName,f_factor))               
		    for i in range(1,int_points-3):
			l_uValues.append(((i*f_factor + f_base)))
		    l_uValues.append(f_maxU - f_base)
		    l_uValues.append(f_maxU)
		    log.debug("%s >> l_uValues : %s"%(_str_funcName,l_uValues))  	
		    
		elif f_insetSplitFactor is not False:
		    log.debug("%s >> f_insetSplitFactor : %s"%(_str_funcName,f_insetSplitFactor))  
		    #Figure out our u's
		    f_base = f_insetSplitFactor * f_maxU 
		    f_len = f_maxU - (f_base *2)	
		    f_factor = f_len/(f_points-1)
		    log.debug("%s >> f_maxU : %s"%(_str_funcName,f_maxU)) 
		    log.debug("%s >> f_len : %s"%(_str_funcName,f_len)) 			
		    log.debug("%s >> f_base : %s"%(_str_funcName,f_base)) 			
		    log.debug("%s >> f_factor : %s"%(_str_funcName,f_factor))               
		    for i in range(1,int_points-1):
			l_uValues.append((i*f_factor))
		    l_uValues.append(f_maxU)
		    log.debug("%s >> l_uValues : %s"%(_str_funcName,l_uValues))  			
		elif f_kwMinU is not False or f_kwMaxU is not False:
		    log.debug("%s >> Sub mode. "%(_str_funcName))
		    if f_kwMinU is not False:
			if f_kwMinU > f_maxU:
			    raise StandardError, "kw minU value(%s) cannot be greater than maxU(%s)"%(f_kwMinU,f_maxU)
			f_useMinU = f_kwMinU
		    else:f_useMinU = 0.0
		    if f_kwMaxU is not False:
			if f_kwMaxU > f_maxU:
			    raise StandardError, "kw maxU value(%s) cannot be greater than maxU(%s)"%(f_kwMaxU,f_maxU)	
			f_useMaxU = f_kwMaxU
		    else:f_useMaxU = f_maxU
		    
		    if int_points == 1:
			l_uValues = [(f_useMaxU - f_useMinU)/2]
		    elif int_points == 2:
			l_uValues = [f_useMaxU,f_useMinU]		    
		    else:
			l_uValues = [f_useMinU]
			f_factor = (f_useMaxU - f_useMinU)/(f_points-1)
			log.debug("%s >> f_maxU : %s"%(_str_funcName,f_useMaxU)) 
			log.debug("%s >> f_factor : %s"%(_str_funcName,f_factor))               
			for i in range(1,int_points-1):
			    l_uValues.append((i*f_factor) + f_useMinU)
			l_uValues.append(f_useMaxU)
		else:
		    #Figure out our u's
		    log.debug("%s >> Regular mode. Points = %s "%(_str_funcName,int_points))
		    if int_points == 3:
			l_uValues.append(f_maxU/2)
			l_uValues.append(f_maxU)
		    else:
			f_factor = f_maxU/(f_points-1)
			log.debug("%s >> f_maxU : %s"%(_str_funcName,f_maxU)) 
			log.debug("%s >> f_factor : %s"%(_str_funcName,f_factor))               
			for i in range(1,int_points-1):
			    l_uValues.append(i*f_factor)
			l_uValues.append(f_maxU)
		    log.debug("%s >> l_uValues : %s"%(_str_funcName,l_uValues))  
	    except Exception,error:raise StandardError,"Divide fail | %s"%error
    
	    for u in l_uValues:
		try:l_spanUPositions.append(mc.pointPosition("%s.u[%f]"%(useCurve,u)))
		except StandardError,error:raise StandardError,"Failed on pointPositioning: %s"%u			
	    log.debug("%s >> l_spanUPositions | len: %s | list: %s"%(_str_funcName,len(l_spanUPositions),l_spanUPositions))  
    
	    try:
		if b_markPoints:
		    ml_built = []
		    for i,pos in enumerate(l_spanUPositions):
			buffer =  mc.spaceLocator(n = "%s_u_%f"%(useCurve,(l_uValues[i])))[0] 
			ml_built.append( cgmMeta.cgmObject(buffer))
			log.debug("%s >> created : %s | at: %s"%(_str_funcName,ml_built[-1].p_nameShort,pos))              											
			mc.xform(ml_built[-1].mNode, t = (pos[0],pos[1],pos[2]), ws=True)
		    
		    if len(ml_built)>1:
			try:f_distance = distance.returnAverageDistanceBetweenObjects([o.mNode for o in ml_built]) * .5
			except StandardError,error:raise StandardError,"Average distance fail. Objects: %s| error: %s"%([o.mNode for o in ml_built],error)
			try:
			    for o in ml_built:
				o.scale = [f_distance,f_distance,f_distance]
			except StandardError,error:raise StandardError,"Scale fail : %s"%error
	    except StandardError,error:log.error("Mark points fail. error : %s"%(error))
	    mc.delete(useCurve)#Delete our use curve
	    return l_spanUPositions
Ejemplo n.º 13
0
 def test_true(self):
     self.assertTrue(validateArgs.boolArg(True),
                     "validateArgs.boolArg did not return True for True")
Ejemplo n.º 14
0
 def test_false(self):
     self.assertFalse(
         validateArgs.boolArg(False),
         "validateArgs.boolArg did not return False for False")
 def test_one(self):
     self.assertTrue(
         validateArgs.boolArg(1),
         "validateArgs.boolArg did not return True for 1"
     )
 def test_zero(self):
     self.assertFalse(
         validateArgs.boolArg(0),
         "validateArgs.boolArg did not return False for 0"
     )
Ejemplo n.º 17
0
 def test_zero(self):
     self.assertFalse(validateArgs.boolArg(0),
                      "validateArgs.boolArg did not return False for 0")
Ejemplo n.º 18
0
        def __func__(self):
            """
	    """
            _str_funcName = self._str_funcCombined
            points = self.d_kws['points']
            int_points = cgmValid.valueArg(self.d_kws['points'],
                                           minValue=1,
                                           calledFrom=_str_funcName)
            f_insetSplitFactor = cgmValid.valueArg(
                self.d_kws['insetSplitFactor'], calledFrom=_str_funcName)
            f_startSplitFactor = cgmValid.valueArg(
                self.d_kws['startSplitFactor'], calledFrom=_str_funcName)
            f_minU = cgmValid.valueArg(self.d_kws['minU'],
                                       noneValid=True,
                                       calledFrom=_str_funcName)
            f_maxU = cgmValid.valueArg(self.d_kws['maxU'],
                                       noneValid=True,
                                       calledFrom=_str_funcName)
            f_points = float(int_points)
            int_spans = int(
                cgmValid.valueArg(self.d_kws['points'],
                                  minValue=5,
                                  autoClamp=True,
                                  calledFrom=_str_funcName))
            b_cullStartEnd = cgmValid.boolArg(self.d_kws['cullStartEnd'],
                                              calledFrom=_str_funcName)

            if f_insetSplitFactor is not False or f_startSplitFactor is not False:
                if not isFloatEquivalent(f_minU, 0):
                    raise StandardError, "Min U must be 0 when f_insetSplitFactor or f_startSplitFactor are used"

            try:  #>>> Divide stuff
                #==========================
                l_spanUPositions = []
                l_uValues = [f_minU]

                if f_startSplitFactor is not False:
                    if points < 5:
                        raise StandardError, "Need at least 5 points for startSplitFactor. Points : %s" % (
                            points)
                    log.debug("%s >> f_startSplitFactor : %s" %
                              (_str_funcName, f_startSplitFactor))
                    #Figure out our u's
                    f_base = f_startSplitFactor * f_maxU
                    l_uValues.append(f_base)
                    f_len = f_maxU - (f_base * 2)
                    int_toMake = f_points - 4
                    f_factor = f_len / (int_toMake + 1)
                    log.debug("%s >> f_maxU : %s" % (_str_funcName, f_maxU))
                    log.debug("%s >> f_len : %s" % (_str_funcName, f_len))
                    log.debug("%s >> int_toMake : %s" %
                              (_str_funcName, int_toMake))
                    log.debug("%s >> f_base : %s" % (_str_funcName, f_base))
                    log.debug("%s >> f_factor : %s" %
                              (_str_funcName, f_factor))
                    for i in range(1, int_points - 3):
                        l_uValues.append(((i * f_factor + f_base)))
                    l_uValues.append(f_maxU - f_base)
                    l_uValues.append(f_maxU)
                    log.debug("%s >> l_uValues : %s" %
                              (_str_funcName, l_uValues))

                elif f_insetSplitFactor is not False:
                    log.debug("%s >> f_insetSplitFactor : %s" %
                              (_str_funcName, f_insetSplitFactor))
                    #Figure out our u's

                    f_base = f_insetSplitFactor * f_maxU
                    f_len = f_maxU - (f_base * 2)
                    f_factor = f_len / (f_points - 1)

                    #f_base = (f_maxU - f_minU) * f_insetSplitFactor
                    #f_len = (f_maxU - f_base) - (f_minU + f_base)
                    #f_factor = f_len/(f_points-1)
                    log.debug("%s >> f_maxU : %s" % (_str_funcName, f_maxU))
                    log.debug("%s >> f_base : %s" % (_str_funcName, f_base))
                    log.debug("%s >> f_len : %s" % (_str_funcName, f_len))
                    log.debug("%s >> f_factor : %s" %
                              (_str_funcName, f_factor))
                    for i in range(1, int_points - 1):
                        l_uValues.append(((i * f_factor) + f_base))
                    l_uValues.append(f_maxU)
                    log.debug("%s >> l_uValues : %s" %
                              (_str_funcName, l_uValues))

                else:
                    #Figure out our u's
                    log.debug("%s >> Regular mode. Points = %s " %
                              (_str_funcName, int_points))
                    if int_points == 1:
                        l_uValues = [((f_maxU - f_minU) / 2) + f_minU]
                    elif int_points == 2:
                        l_uValues = [f_minU, f_maxU]
                    elif int_points == 3:
                        l_uValues.append(((f_maxU - f_minU) / 2) + f_minU)
                        l_uValues.append(f_maxU)
                    else:
                        f_factor = (f_maxU - f_minU) / (f_points - 1)
                        log.debug("%s >> f_maxU : %s" %
                                  (_str_funcName, f_maxU))
                        log.debug("%s >> f_factor : %s" %
                                  (_str_funcName, f_factor))
                        for i in range(1, int_points - 1):
                            l_uValues.append((i * f_factor) + f_minU)
                        l_uValues.append(f_maxU)
                    log.debug("%s >> l_uValues : %s" %
                              (_str_funcName, l_uValues))

                if b_cullStartEnd and len(l_uValues) > 3:
                    l_uValues = l_uValues[1:-1]
            except Exception, error:
                raise StandardError, "Divide fail | %s" % error
Ejemplo n.º 19
0
 def test_one(self):
     self.assertTrue(validateArgs.boolArg(1),
                     "validateArgs.boolArg did not return True for 1")
Ejemplo n.º 20
0
def register(
    controlObject=None,  #(mObject - None) -- The object to use as a control
    typeModifier=None,  #(string - None) -- Tag for cgmTypeModifier for naming
    copyTransform=None,  #(mObject - None) -- Object to copy the transform of for our control object
    copyPivot=None,  #(mObject - None) -- Object to copy the pivot of for our control object
    shapeParentTo=None,  #'(mObject - None) -- Object to shape parent our control curve to to use that transform
    useShape=None,  #'(mObject - None) -- Object to use the curve shape of for our control
    setRotateOrder=None,  #'(rotateOrder - None) -- Argument for a rotate order to set
    autoLockNHide=None,  #'(bool - None) -- Try to set lock and hide
    mirrorAxis=None,  #'(string - None) -- Mirror axis to set - using red9's setup terms
    mirrorSide=None,  #'(string/int - None) -- Mirror side - using red9's setup terms
    makeMirrorable=True,  #'(bool - True) -- Setup for mirrorability (using red9) -- implied by other mirror args
    addDynParentGroup=False,  #'(False) -- Add a dynParent group setup
    addExtraGroups=False,  #'(int - False) -- Number of nested extra groups desired
    addConstraintGroup=False,  #'(bool - False) -- If a group just above the control is desired for consraining
    freezeAll=False,  #'(bool - False) -- Freeze all transforms on the control object
    noFreeze=False,
    addSpacePivots=False,  #'(int - False) -- Number of space pivots to generate and connect
    controlType=None,  #'(string - None) -- Tag for cgmType
    aim=None,  #'(string/int - None) -- aim axis to use
    up=None,  #'(string/int - None) -- up axis to use
    out=None,  #'(string/int - None) -- out axis to use
    makeAimable=None,  #'(mObject - False) -- Make object aimable -- implied by aim/up/out):
    **kws):

    _str_func = 'register'
    """
    [{'step':'validate','call':self._validate},
    {'step':'Copy Transform','call':self._copyTransform},
    {'step':'Shape Parent','call':self._shapeParent},
    {'step':'Copy Pivot','call':self._copyPivot},
    {'step':'Naming','call':self._naming},
    {'step':'Aim Setup','call':self._aimSetup},
    {'step':'Rotate Order','call':self._rotateOrder},
    {'step':'Initial Freeze','call':self._initialFreeze},
    {'step':'Groups Setup','call':self._groupsSetup},
    {'step':'Space Pivot','call':self._spacePivots},
    {'step':'Mirror Setup','call':self._mirrorSetup},	                        
    {'step':'Freeze','call':self._freeze},
    {'step':'Mirror Attribute Bridges','call':self._mirrorAttributeBridges_},	                        
    {'step':'lock N Hide','call':self._lockNHide},
    {'step':'Return build','call':self._returnBuild}]
    """
    try:
        #Validate ================================================================================================
        mi_control = cgmMeta.validateObjArg(controlObject,
                                            'cgmControl',
                                            setClass=True)

        str_mirrorAxis = VALID.stringArg(mirrorAxis, calledFrom=_str_func)
        str_mirrorSide = cgmGeneral.verify_mirrorSideArg(
            mirrorSide)  #VALID.stringArg(mirrorSide,calledFrom = _str_func)
        b_makeMirrorable = VALID.boolArg(makeMirrorable, calledFrom=_str_func)

        _addMirrorAttributeBridges = kws.get('addMirrorAttributeBridges',
                                             False)
        addForwardBack = kws.get('addForwardBack', False)

        if _addMirrorAttributeBridges:
            if type(_addMirrorAttributeBridges) not in [list, tuple]:
                raise ValueError, "[Bad addMirrorAttributeBridge arg]{arg: %s}" % _addMirrorAttributeBridge
            for i, l in enumerate(_addMirrorAttributeBridges):
                if type(l) not in [list, tuple]:
                    raise ValueError, "[Bad addMirrorAttributeBridge arg: %s]{arg: %s}" % (
                        i, l)

        # Running lists ------------------------------------------------------------------------------------------
        ml_groups = []  #Holder for groups
        ml_constraintGroups = []
        ml_spacePivots = []

        #Copy Transform ================================================================================================
        if copyTransform is not None:
            mTarget = cgmMeta.validateObjArg(copyTransform,
                                             'cgmObject',
                                             noneValid=True)
            if not mTarget:
                raise StandardError, "Failed to find suitable copyTransform object: '%s" % copyTransform

            #Need to move this to default cgmNode stuff
            mBuffer = mi_control
            i_newTransform = cgmMeta.cgmObject(
                rigging.groupMeObject(mTarget.mNode, False))
            for a in mc.listAttr(mi_control.mNode, userDefined=True):
                ATTR.copy_to(mi_control.mNode, a, i_newTransform.mNode)
            curves.parentShapeInPlace(i_newTransform.mNode,
                                      mi_control.mNode)  #Parent shape
            i_newTransform.parent = mi_control.parent  #Copy parent
            mi_control = cgmMeta.asMeta(i_newTransform,
                                        'cgmControl',
                                        setClass=True)
            mc.delete(mBuffer.mNode)

        #ShapeParent ================================================================================================
        if shapeParentTo:
            i_target = cgmMeta.validateObjArg(shapeParentTo, 'cgmObject')
            CORERIG.shapeParent_in_place(i_target.mNode, mi_control.mNode)
            i_target = cgmMeta.asMeta(i_target, 'cgmControl', setClass=True)
            #mi_control.delete()
            mi_control = i_target  #replace the control with the joint

        if useShape is not None:
            i_shape = cgmMeta.validateObjArg(useShape,
                                             cgmMeta.cgmObject,
                                             mayaType='nurbsCurve')
            curves.parentShapeInPlace(mi_control.mNode, i_shape.mNode)

        #Copy Pivot ============================================================================================
        if copyPivot is not None:
            if issubclass(type(copyPivot), cgmMeta.cgmNode):
                i_target = copyPivot
            elif mc.objExists(copyPivot):
                i_target = cgmMeta.cgmObject(copyPivot)
            else:
                raise StandardError, "Failed to find suitable copyTransform object: '%s" % copyPivot

            #Need to move this to default cgmNode stuff
            mi_control.doCopyPivot(i_target.mNode)

        #Naming ============================================================================================
        mi_control.addAttr('cgmType', 'controlAnim', lock=True)
        if typeModifier is not None:
            mi_control.addAttr('cgmTypeModifier', str(typeModifier), lock=True)
        mi_control.doName()  #mi_control.doName(nameShapes=True)

        #Rotate Order ============================================================================================
        _rotateOrder = False
        if setRotateOrder is not None:
            _rotateOrder = setRotateOrder
        elif controlType in __d_rotateOrderDefaults__.keys():
            _rotateOrder = __d_rotateOrderDefaults__[controlType]
        elif mi_control.getAttr('cgmName') in __d_rotateOrderDefaults__.keys():
            _rotateOrder = __d_rotateOrderDefaults__[mi_control.getAttr(
                'cgmName')]
        else:
            log.debug("|{0}| >> Rotate order not set on: {1}".format(
                _str_func, mi_control.p_nameShort))

        #Set it ---------------------------------------------------------------
        if _rotateOrder:
            mRotateOrder = VALID.simpleOrientation(_rotateOrder)
            #dictionary.validateRotateOrderString(_rotateOrder)

            mc.xform(mi_control.mNode, rotateOrder=mRotateOrder.p_string)

        #Initial Freeze ============================================================================================
        if freezeAll:
            mc.makeIdentity(mi_control.mNode, apply=True, t=1, r=1, s=1, n=0)

        #Groups ============================================================================================
        if addDynParentGroup or addSpacePivots or mi_control.getAttr(
                'cgmName') == 'cog' or _addMirrorAttributeBridges:
            mi_control.addAttr('________________',
                               attrType='int',
                               keyable=False,
                               hidden=False,
                               lock=True)
            ATTR.reorder(mi_control.mNode, '________________', top=True)
        #Aim Setup ============================================================================================
        if aim is not None or up is not None or makeAimable:
            mi_control._verifyAimable()

        #First our master group:
        i_masterGroup = (cgmMeta.asMeta(mi_control.doGroup(True),
                                        'cgmObject',
                                        setClass=True))
        i_masterGroup.doStore('cgmName', mi_control)
        i_masterGroup.addAttr('cgmTypeModifier', 'master', lock=True)
        i_masterGroup.doName()
        mi_control.connectChildNode(i_masterGroup, 'masterGroup', 'groupChild')

        if addDynParentGroup:
            i_dynGroup = (cgmMeta.cgmObject(mi_control.doGroup(True)))
            i_dynGroup = cgmRigMeta.cgmDynParentGroup(dynChild=mi_control,
                                                      dynGroup=i_dynGroup)
            i_dynGroup.doName()
            """
            i_zeroGroup = (cgmMeta.cgmObject(mi_control.doGroup(True)))
            i_zeroGroup.addAttr('cgmTypeModifier','zero',lock=True)
            i_zeroGroup.doName()
            mi_control.connectChildNode(i_zeroGroup,'zeroGroup','groupChild')"""

        if addExtraGroups:
            for i in range(addExtraGroups):
                i_group = (cgmMeta.asMeta(mi_control.doGroup(True),
                                          'cgmObject',
                                          setClass=True))
                if type(
                        addExtraGroups
                ) == int and addExtraGroups > 1:  #Add iterator if necessary
                    i_group.addAttr('cgmIterator', str(i + 1), lock=True)
                    i_group.doName()
                ml_groups.append(i_group)
            mi_control.msgList_connect("extraGroups", ml_groups, 'groupChild')

        if addConstraintGroup:  #ConstraintGroups
            i_constraintGroup = (cgmMeta.asMeta(mi_control.doGroup(True),
                                                'cgmObject',
                                                setClass=True))
            i_constraintGroup.addAttr('cgmTypeModifier',
                                      'constraint',
                                      lock=True)
            i_constraintGroup.doName()
            ml_constraintGroups.append(i_constraintGroup)
            mi_control.connectChildNode(i_constraintGroup, 'constraintGroup',
                                        'groupChild')

        #Space Pivot ============================================================================================
        if addSpacePivots:
            parent = mi_control.getMessage('masterGroup')[0]
            for i in range(int(addSpacePivots)):
                #i_pivot = rUtils.create_spaceLocatorForObject(mi_control.mNode,parent)
                i_pivot = SPACEPIVOTS.create(mi_control.mNode, parent)
                ml_spacePivots.append(i_pivot)
                #log.info("spacePivot created: {0}".format(i_pivot.p_nameShort))

        #Mirror Setup ============================================================================================
        if str_mirrorSide is not None or b_makeMirrorable:
            for mObj in [mi_control] + ml_spacePivots:
                mi_control._verifyMirrorable()
                l_enum = cgmMeta.cgmAttr(mi_control, 'mirrorSide').p_enum
                if str_mirrorSide in l_enum:
                    #log.debug("|{0}| >> Rotate order not set on: {1}".format(_str_func,mi_control.p_nameShort))
                    #log.debug("%s >> %s >> found in : %s"%(_str_funcCombined, "mirrorSetup", l_enum))
                    mi_control.mirrorSide = l_enum.index(str_mirrorSide)
                if str_mirrorAxis:
                    mi_control.mirrorAxis = str_mirrorAxis
            for mObj in mi_control.msgList_get('spacePivots'):
                mObj._verifyMirrorable()
                mi_control.doConnectOut('mirrorAxis',
                                        mObj.mNode + '.mirrorAxis')
                mi_control.doConnectOut('mirrorSide',
                                        mObj.mNode + '.mirrorSide')

                #cgmMeta.cgmAttr(mObj,'mirrorSide').doConnectIn(mi_control,'mirrorSide')
                #cgmMeta.cgmAttr(mi_control,'mirrorAxis').doCopyTo(mObj,connectTargetToSource = 1)
                #ATTR.connect(mObj.mNode + '.mirrorAxis',"{0}.mirrorAxis".format(mi_control.mNode))
                #ATTR.connect(mObj.mNode + 'mirrorSide',"{0}.mirrorSide".format(mi_control.mNode))

        #Freeze ============================================================================================
        if not shapeParentTo and noFreeze is not True:
            if not freezeAll:
                if mi_control.getAttr(
                        'cgmName'
                ) == 'cog' or controlType in __l_fullFreezeTypes__:
                    mc.makeIdentity(mi_control.mNode,
                                    apply=True,
                                    t=1,
                                    r=1,
                                    s=1,
                                    n=0)
                else:
                    mc.makeIdentity(mi_control.mNode,
                                    apply=True,
                                    t=1,
                                    r=0,
                                    s=1,
                                    n=0)
            else:
                mc.makeIdentity(mi_control.mNode,
                                apply=True,
                                t=1,
                                r=1,
                                s=1,
                                n=0)

        #Mirror attriubte Bridges ==========================================================================
        if addForwardBack:
            mPlug_forwardBackDriver = cgmMeta.cgmAttr(mi_control,
                                                      "forwardBack",
                                                      attrType='float',
                                                      keyable=True)
            try:
                mPlug_forwardBackDriven = cgmMeta.validateAttrArg(
                    [mi_control, addForwardBack])['mi_plug']
            except Exception, error:
                raise StandardError, "push pull driver | %s" % (error)

            if str_mirrorSide.lower() == 'right':
                arg_forwardBack = "%s = -%s" % (
                    mPlug_forwardBackDriven.p_combinedShortName,
                    mPlug_forwardBackDriver.p_combinedShortName)
            else:
                arg_forwardBack = "%s = %s" % (
                    mPlug_forwardBackDriven.p_combinedShortName,
                    mPlug_forwardBackDriver.p_combinedShortName)

            mPlug_forwardBackDriven.p_locked = True
            mPlug_forwardBackDriven.p_hidden = True
            mPlug_forwardBackDriven.p_keyable = False
            NodeF.argsToNodes(arg_forwardBack).doBuild()

        if _addMirrorAttributeBridges:
            for l_bridge in _addMirrorAttributeBridges:
                _attrName = VALID.stringArg(l_bridge[0])
                _attrToBridge = VALID.stringArg(l_bridge[1])
                if not mi_control.hasAttr(_attrToBridge):
                    raise StandardError, "['%s' lacks the bridge attr '%s']" % (
                        mi_control.p_nameShort, _attrToBridge)

                mPlug_attrBridgeDriver = cgmMeta.cgmAttr(mi_control,
                                                         _attrName,
                                                         attrType='float',
                                                         keyable=True)
                try:
                    mPlug_attrBridgeDriven = cgmMeta.validateAttrArg(
                        [mi_control, _attrToBridge])['mi_plug']
                except Exception, error:
                    raise StandardError, "[validate control attribute bridge attr]{%s}" % (
                        error)

                if str_mirrorSide.lower() == 'right':
                    arg_attributeBridge = "%s = -%s" % (
                        mPlug_attrBridgeDriven.p_combinedShortName,
                        mPlug_attrBridgeDriver.p_combinedShortName)
                else:
                    arg_attributeBridge = "%s = %s" % (
                        mPlug_attrBridgeDriven.p_combinedShortName,
                        mPlug_attrBridgeDriver.p_combinedShortName)

                mPlug_attrBridgeDriven.p_locked = True
                mPlug_attrBridgeDriven.p_hidden = True
                mPlug_attrBridgeDriven.p_keyable = False
                NodeF.argsToNodes(arg_attributeBridge).doBuild()
 def test_false(self):
     self.assertFalse(
         validateArgs.boolArg(False),
         "validateArgs.boolArg did not return False for False"
     )