def findFurthestPointInRangeFromObject(self):
     '''
     Find the furthest point in range on an axis. Useful for getting to the outershell of a surface
     '''
     try:
         self._str_funcName = 'findFurthestPointInRangeFromObject'
         log.debug(">>> %s >> "%self._str_funcName + "="*75)
         if len(mc.ls(surface))>1:
             raise StandardError,"findFurthestPointInRangeFromObject>>> More than one surface named: %s"%surface                                  
         #>>>First cast to get our initial range
         self.d_firstcast = findSurfaceIntersectionFromObjectAxis(surface, obj, axis, vector, maxDistance)
         if not self.d_firstcast.get('hit'):
             raise StandardError,"findFurthestPointInRangeFromObject>>> first cast failed to hit"
         self.baseDistance = distance.returnDistanceBetweenPoints(distance.returnWorldSpacePosition(obj),self.d_firstcast['hit'])                        
         log.debug("findFurthestPointInRangeFromObject>>>baseDistance: %s"%self.baseDistance)
         self.castDistance = self.baseDistance + pierceDepth
         log.debug("findFurthestPointInRangeFromObject>>>castDistance: %s"%castDistance)
         self.l_positions = []
         self.d_castReturn = findSurfaceIntersectionFromObjectAxis(surface, obj, axis, maxDistance = castDistance, singleReturn=False) or {}
         log.debug("2nd castReturn: %s"%self.d_castReturn)
         if self.d_castReturn.get('hits'):
             self.closestPoint = distance.returnFurthestPoint(distance.returnWorldSpacePosition(obj),self.d_castReturn.get('hits')) or False    
             self.d_castReturn['hit'] = self.closestPoint
         return self.d_castReturn
     except StandardError,error:
         for kw in [surface,obj,axis,pierceDepth,vector,maxDistance]:
             log.debug("%s"%kw)
         raise StandardError, " >> error"
예제 #2
0
def findFurthestPointInRangeFromObject(mesh,obj,axis = 'z+', pierceDepth = 4,
                                       vector = False, maxDistance = 1000):
    """ Find the furthest point in range on an axis. Useful for getting to the outershell of a mesh """
    try:
        _str_funcName = 'findFurthestPointInRangeFromObject'
        log.debug(">>> %s >> "%_str_funcName + "="*75)             
        if len(mc.ls(mesh))>1:
            raise StandardError,"findFurthestPointInRangeFromObject>>> More than one mesh named: %s"%mesh      
        #>>>First cast to get our initial range
        d_firstcast = findMeshIntersectionFromObjectAxis(mesh, obj, axis = axis, vector=vector, maxDistance = maxDistance)
        if not d_firstcast.get('hit'):
            raise StandardError,"findFurthestPointInRangeFromObject>>> first cast failed to hit"
    
        baseDistance = distance.returnDistanceBetweenPoints(distance.returnWorldSpacePosition(obj),d_firstcast['hit'])
        log.debug("findFurthestPointInRangeFromObject>>>baseDistance: %s"%baseDistance)
        castDistance = baseDistance + pierceDepth
        log.debug("findFurthestPointInRangeFromObject>>>castDistance: %s"%castDistance)
    
        l_positions = []
    
        d_castReturn = findMeshIntersectionFromObjectAxis(mesh, obj, axis=axis, maxDistance = castDistance, singleReturn=False) or {}
        log.debug("2nd castReturn: %s"%d_castReturn)
        if d_castReturn.get('hits'):
            closestPoint = distance.returnFurthestPoint(distance.returnWorldSpacePosition(obj),d_castReturn.get('hits')) or False
            d_castReturn['hit'] = closestPoint
        return d_castReturn
    except StandardError,error:
        for kw in [mesh,obj,axis,pierceDepth,vector,maxDistance]:
            log.debug("%s"%kw)
        raise StandardError, "%s >> error: %s"%(_str_funcName,error)
예제 #3
0
		
		if closestInRange:
		    try:
			d_castReturn = RayCast.findMeshIntersectionFromObjectAxis(mesh, mi_loc.mNode, axis=aimAxis, maxDistance = maxDistance) or {}
		    except StandardError,error:
			log.error("createMeshSliceCurve >> closestInRange error : %s"%error)
			return False
		    log.debug("closest in range castReturn: %s"%d_castReturn)		
		    d_hitReturnFromValue[rotateValue] = d_castReturn	
		    log.debug("From %s: %s" %(rotateValue,d_castReturn))
			
		else:
		    d_castReturn = RayCast.findMeshIntersectionFromObjectAxis(mesh, mi_loc.mNode, axis=aimAxis, maxDistance = maxDistance, singleReturn=False) or {}
		    log.debug("castReturn: %s"%d_castReturn)
		    if d_castReturn.get('hits'):
			closestPoint = distance.returnFurthestPoint(mi_loc.getPosition(),d_castReturn.get('hits')) or False
			d_castReturn['hit'] = closestPoint
			log.debug("From %s: %s" %(rotateValue,d_castReturn))
		    
		hit = d_castReturn.get('hit') or False
		d_rawHitFromValue[rotateValue] = hit
    
	    except StandardError,error:
		    raise StandardError,"createMeshSliceCurve>> error: %s"%error 
	    log.debug("rotateValue %s | raw hit: %s"%(rotateValue,hit))
	    if hit and not cgmMath.isVectorEquivalent(hit,d_rawHitFromValue.get(l_rotateSettings[i-1])):
		log.debug("last raw: %s"%d_rawHitFromValue.get(l_rotateSettings[i-1]))
		if markHits or posOffset:
		    mi_tmpLoc = cgmMeta.cgmObject(mc.spaceLocator(n='loc_%s'%i)[0])
		    mc.move (hit[0],hit[1],hit[2], mi_tmpLoc.mNode,ws=True)	
		    if posOffset: