예제 #1
0
def lidSurface_curveLocators( curveList, Uvalues=[0.0, 0.5, 1.0], locatorSize=0.02 ):
   for curve in curveList:
       for uVal in Uvalues:
           lLocatorAndNode = mc.pointCurveConstraint( "%s.u[%s]" % (curve,uVal), constructionHistory=1, replaceOriginal=1, weight=1 )
           loc = lLocatorAndNode[0]
           mc.xform( loc, centerPivots=1 )
           locShape = mc.listRelatives( loc, shapes=1 )[0]
           for axis in ["X", "Y", "Z"]:
               mc.setAttr( locShape+".localScale"+axis,locatorSize)
예제 #2
0
def displayConnect_curve( _obj ):
	# 타겟 오브젝트
    _pointA = _obj[0]
    _pointB = _obj[1]

	# 라인생성
    _curve = cmds.curve(d=1, p=[(0,0,0),(0,0,0)], k=[0,1] )
    _pointCurveConstraint1 = cmds.pointCurveConstraint( _curve+'.ep[0]',ch=True)
    _pointCurveConstraint2 = cmds.pointCurveConstraint( _curve+'.ep[1]',ch=True)

	# pointCurveConstraint로 생성된 로케이터를 타겟 오브젝트에 붙임
    cmds.pointConstraint( _pointA, _pointCurveConstraint1[0])
    cmds.pointConstraint( _pointB, _pointCurveConstraint2[0])

	# 로케이터 가림
    _locShape1 = cmds.listRelatives( _pointCurveConstraint1[0], s=True )
    _locShape2 = cmds.listRelatives( _pointCurveConstraint2[0], s=True )
    cmds.setAttr (_locShape1[0]+'.visibility', 0)
    cmds.setAttr (_locShape2[0]+'.visibility', 0)

	# return
    return [_curve, _pointCurveConstraint1[0], _pointCurveConstraint2[0] ]
예제 #3
0
def lidSurface_curveLocators(curveList,
                             Uvalues=[0.0, 0.5, 1.0],
                             locatorSize=0.02):
    for curve in curveList:
        for uVal in Uvalues:
            lLocatorAndNode = mc.pointCurveConstraint("%s.u[%s]" %
                                                      (curve, uVal),
                                                      constructionHistory=1,
                                                      replaceOriginal=1,
                                                      weight=1)
            loc = lLocatorAndNode[0]
            mc.xform(loc, centerPivots=1)
            locShape = mc.listRelatives(loc, shapes=1)[0]
            for axis in ["X", "Y", "Z"]:
                mc.setAttr(locShape + ".localScale" + axis, locatorSize)
예제 #4
0
def addPointOnCurve():
    """This function adds locators that control the curve"""

    epList = cmds.ls("{}.ep[*]".format(data.treadCircle), flatten=True)
    
    locatorList = []
    
    for ep in epList:
        cmds.select(ep, replace=True)

        # Append locators generated on constraint to their list
        locatorList.append(cmds.pointCurveConstraint(constructionHistory=True, replaceOriginal=True)[0])
        cmds.CenterPivot()

    return locatorList
예제 #5
0
def locatorEpCurve(curve,locatorScale=0.05,prefix=''):
	'''
	Creates locators for each edit point for the specified curve. Edit points
	are constrained to the locator world positions.
	
	@param curve: Curve to operate on
	@type curve: str
	@param locatorScale: Control the relative scale of the locators to the length of curve
	@type locatorScale: float
	@param prefix: Name prefix for newly created nodes
	@type prefix: str
	
	@return: A list containing the names of the locators driving the curve
	@returnType: list
	'''
	# Check curve
	if not isCurve(curve): raise Exception('Object '+curve+ ' is not a valid curve!')
	# Check curve shape
	curveShape=''
	if mc.objectType(curve) == 'transform':
		curveShape = mc.listRelatives(curve,s=1,ni=1)[0]
	else:
		curveShape = curve
		curve = mc.listRelatives(curve,p=1)[0]
	
	# Check prefix
	if not prefix: prefix = glTools.utils.stringUtils.stripSuffix(curve)
	
	# Get curve information
	spans = mc.getAttr(curve+'.spans')
	openCrv = not mc.getAttr(curve+'.form')
	numPt = spans + openCrv
	
	# Set locator scale
	locatorScale *= mc.arclen(curve)
	
	# Initialize return list
	locatorList=[]
	# Iterate over edit points
	for i in range(numPt):
		# Create point on curve deformer
		curveCon = mc.pointCurveConstraint(curveShape+'.ep['+str(i)+']',ch=1,rpo=1,w=1)
		locatorList.append(curveCon[0])
		# Create standin locatorList entries for tangency points
		if openCrv:
			if not i:
				# Get start tangency point position
				pos = mc.pointPosition(curveShape+'.cv[1]')
				coord = closestPoint(curve,pos)
				# Create point on curve deformer
				curveCon = mc.pointCurveConstraint(curveShape+'.u['+str(coord)+']',ch=1,rpo=1,w=1)
				locatorList.append(curveCon[0])
			if i == (numPt-2):
				# Get end tangency point position
				pos = mc.pointPosition(curveShape+'.cv['+str(numPt)+']')
				coord = closestPoint(curve,pos)
				# Create point on curve deformer
				curveCon = mc.pointCurveConstraint(curveShape+'.u['+str(coord)+']',ch=1,rpo=1,w=1)
				locatorList.append(curveCon[0])
	
	for i in range(len(locatorList)):
		# Scale and Center Locator Pivots
		localOffset = mc.getAttr(locatorList[i]+'.localPosition')[0]
		mc.setAttr(locatorList[i]+'.translate',localOffset[0],localOffset[1],localOffset[2])
		mc.setAttr(locatorList[i]+'.localPosition',0,0,0)
		mc.setAttr(locatorList[i]+'.localScale',locatorScale,locatorScale,locatorScale)
		# Rename Locator
		ind = str(i+1)
		if i<9: ind = '0' + ind
		locatorList[i] = mc.rename(locatorList[i],prefix+'ep'+ind+'_locator')
	
	# Return locator list
	return locatorList