#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
八轴修型
父子约束给上一层级的骨骼就行了
右边的用正方向 左边的负方向
import rig_drive
reload(rig_drive)
rig_drive.shapeHelper_UV_UI()
"""
import maya.cmds as mc
class shapeHelper_UV_UI():
def __init__(self):
self.UI()
def UI(self):
if mc.window("shapeHelper_UV_UI_window", exists=True):
mc.deleteUI("shapeHelper_UV_UI_window")
self.a=mc.window("shapeHelper_UV_UI_window",title="shapeHelper_UV_UI")
self.b=mc.scrollLayout(horizontalScrollBarThickness=16,verticalScrollBarThickness=16,cr=1)
mc.columnLayout(adjustableColumn=True, columnAlign="center")
self.radio=mc.radioButtonGrp( label=u'方向', labelArray2=[u'正方向', u'负方向'], numberOfRadioButtons=2, columnWidth3=(100, 50, 50), columnAlign3=["center", "center", "center"], select=1,adj=2)
self.text_=mc.textFieldGrp(l=u'命名' ,adj=2,cw2=[100,80],cat=(1,'left',39))
self.radius=mc.floatSliderGrp( label='Radius', field=True, minValue=0.01, maxValue=10.0, value=1, columnWidth3=[97, 50, 100], columnAlign3=["center", "center", "center"])
self.check_=mc.checkBoxGrp( ncb=2, label=u'几轴驱动', labelArray2=[u'4轴', u'8轴 ',],cw3=(100,50,50),adj=2,cat=(1,'left',22),v1=1)
mc.button(label=u'执行', enable=True,c=lambda *args:self.operation())
mc.frameLayout( l=u'添加', collapse=True, collapsable=True,w=200,bgc=(0.5,0,1),ec=lambda *args:self.edit_window_Fun(1,50),cc=lambda *args:self.edit_window_Fun(0,50))
self.radio_add=mc.radioButtonGrp( nrb=2, label=u'添加驱动', la2=[u'4轴', u'8轴 ',])
mc.button(label=u'执行',c=lambda *args:self.add_driven_Fun())
mc.setParent( '..')
mc.frameLayout( l=u'删除', collapse=True, collapsable=True,w=200,bgc=(0.5,0,1),ec=lambda *args:self.edit_window_Fun(1,50),cc=lambda *args:self.edit_window_Fun(0,50))
self.radio_del=mc.radioButtonGrp( nrb=2, label=u'删除驱动', la2=[u'4轴', u'8轴 ',],cw3=(100,50,50),adj=2,cat=(1,'left',22))
mc.button(label=u'执行',c=lambda *args:self.del_driven_Fun())
mc.setParent( '..')
mc.setParent( '..')
mc.window(self.a,e=1,wh=(410,160),s=1)
mc.showWindow( self.a )
def edit_window_Fun(self,open_close,new_h):
old_h=mc.window(self.a,h=1,q=1)
print old_h
if open_close==1:
mc.window(self.a,e=1,h=old_h+new_h)
print old_h+new_h
else:
mc.window(self.a,e=1,h=old_h-new_h)
print old_h-new_h
'创建 M1 M2sphere 函数'
def sphere_fun(self,name_sphere,ssw_,esw_,s_,nsp_,r_,ro_):
sphere_=mc.sphere(ch=True, name=name_sphere, r=r_, s=s_, nsp=nsp_, axis=[0, 1, 0],ssw=ssw_,esw=esw_)[0]
mc.xform(sphere_,ws=1,ro=ro_)
mc.makeIdentity(sphere_,apply=1,t=1,r=1,s=1)
mc.DeleteHistory(sphere_)
'创建 目标loc 函数'
def aimloc_fun(self,aimloc_name,aimloc_name_grp):
mc.spaceLocator(p=(0,0,0),n=aimloc_name)
mc.group(aimloc_name,n=aimloc_name_grp)
'创建M1 M2 closetriont节点和关联 函数'
def closetroint_fun(self,closetpoint_name,sphere_,aimloc_,closetpoint_range_name,tag_name,one_two):
sphere_shape=mc.listRelatives(sphere_,s=1)[0]
aimloc_shape=mc.listRelatives(aimloc_,s=1)[0]
closetpoint_name_=mc.createNode('closestPointOnSurface',n=closetpoint_name)
mc.connectAttr(aimloc_+'.worldPosition[0]',closetpoint_name_+'.inPosition')
mc.connectAttr(sphere_shape+'.worldSpace[0]',closetpoint_name_+'.inputSurface')
U=mc.getAttr(sphere_shape+'.spansU')
V=mc.getAttr(sphere_shape+'.spansV')
setRange_=mc.createNode('setRange',n=closetpoint_range_name)
mc.setAttr(setRange_+'.oldMaxX',U)
mc.setAttr(setRange_+'.oldMaxY',V)
mc.setAttr(setRange_+'.maxX',1)
mc.setAttr(setRange_+'.maxY',1)
mc.connectAttr(closetpoint_name_+'.parameterU',setRange_+'.valueX')
mc.connectAttr(closetpoint_name_+'.parameterV',setRange_+'.valueY')
mc.addAttr(closetpoint_name_,ln='closepiont_%s'%one_two,at='double')
mc.addAttr(setRange_,ln='closepiont_%s_range'%one_two,at='double')
mc.connectAttr(tag_name+'.closepiont_%s'%one_two,closetpoint_name_+'.closepiont_%s'%one_two)
mc.connectAttr(tag_name+'.closepiont_%s_range'%one_two,setRange_+'.closepiont_%s_range'%one_two)
'创建M1 M2 条件节点和关联 函数'
def connectAttr_M_sphere_condition_fun(self,condition_st,condition_ed,setrange_,tag_name,one_two):
condition_st_=mc.createNode('condition',n=condition_st)
mc.setAttr(condition_st_+'.operation',3)
mc.setAttr(condition_st_+'.secondTerm',0.201)
mc.setAttr(condition_st_+'.colorIfFalseR',999)
mc.connectAttr(setrange_+'.outValueY',condition_st_+'.firstTerm')
mc.connectAttr(setrange_+'.outValueY',condition_st_+'.colorIfTrueR')
condition_ed_=mc.createNode('condition',n=condition_ed)
mc.setAttr(condition_ed_+'.operation',4)
mc.setAttr(condition_ed_+'.secondTerm',0.801)
mc.setAttr(condition_ed_+'.colorIfFalseR',999)
mc.connectAttr(condition_st_+'.outColorR',condition_ed_+'.firstTerm')
mc.connectAttr(setrange_+'.outValueX',condition_ed_+'.colorIfTrueR')
mc.connectAttr(setrange_+'.outValueY',condition_ed_+'.colorIfTrueG')
mc.addAttr(condition_st_,ln='condition_%s_st'%one_two,at='double')
mc.addAttr(condition_ed_,ln='condition_%s_ed'%one_two,at='double')
mc.connectAttr(tag_name+'.condition_%s_st'%one_two,condition_st_+'.condition_%s_st'%one_two)
mc.connectAttr(tag_name+'.condition_%s_ed'%one_two,condition_ed_+'.condition_%s_ed'%one_two)
'分割M1 M2区域 函数'
def division_sphere_fun(self,scope_name_st,scope_name_ed,sphere_condition,scope_1,scope_2):
mc.createNode('condition',n=scope_name_st)
mc.setAttr(scope_name_st+'.operation',3)
mc.setAttr(scope_name_st+'.secondTerm',scope_1)
mc.setAttr(scope_name_st+'.colorIfFalseR',999)
mc.connectAttr(sphere_condition+'.outColorG',scope_name_st+'.firstTerm')
mc.connectAttr(sphere_condition+'.outColorG',scope_name_st+'.colorIfTrueR')
mc.createNode('condition',n=scope_name_ed)
mc.setAttr(scope_name_ed+'.operation',4)
mc.setAttr(scope_name_ed+'.secondTerm',scope_2)
mc.setAttr(scope_name_ed+'.colorIfFalseR',0)
mc.setAttr(scope_name_ed+'.colorIfFalseG',0)
mc.connectAttr(scope_name_st+'.outColorR',scope_name_ed+'.firstTerm')
mc.connectAttr(sphere_condition+'.outColorR',scope_name_ed+'.colorIfTrueR')
mc.connectAttr(sphere_condition+'.outColorG',scope_name_ed+'.colorIfTrueG')
'把区间变为 0-1 函数'
def scope_to_setrange_fun(self,setrange_st,setrange_ed,scopr_condition,oldmin_,oldmax_,tag_name,X8orX4):
mc.createNode('setRange',n=setrange_st)
mc.setAttr(setrange_st+'.maxX',1)
mc.setAttr(setrange_st+'.oldMinX',oldmin_)
mc.setAttr(setrange_st+'.oldMaxX',oldmax_)
mc.connectAttr(scopr_condition+'.outColorG',setrange_st+'.valueX')
mc.createNode('setRange',n=setrange_ed)
mc.setAttr(setrange_ed+'.oldMaxX',1)
mc.setAttr(setrange_ed+'.oldMaxY',1)
mc.connectAttr(scopr_condition+'.outColorR',setrange_ed+'.valueX')
mc.connectAttr(scopr_condition+'.outColorR',setrange_ed+'.valueY')
mc.connectAttr(setrange_st+'.outValueX',setrange_ed+'.maxX')
reverse_=mc.createNode('reverse',n=setrange_st+'_reverse')
mc.connectAttr(setrange_st+'.outValueX',reverse_+'.inputX')
reverse_condition=mc.createNode('condition',n=setrange_st+'_reverse_condition')
mc.connectAttr(reverse_+'.outputX',reverse_condition+'.firstTerm')
mc.connectAttr(reverse_+'.outputX',reverse_condition+'.colorIfFalseR')
mc.setAttr(reverse_condition+'.operation',0)
mc.setAttr(reverse_condition+'.colorIfTrueR',0)
mc.setAttr(reverse_condition+'.secondTerm',1)
mc.connectAttr(reverse_condition+'.outColorR',setrange_ed+'.maxY')
self.connect_8Xor4X_Fun(tag_name,[reverse_,reverse_condition],X8orX4)
'创建标签物体 函数'
def tag_fun(self,tag_name,size,ON_OFF_4X,ON_OFF_8X):
tag_=mc.curve(d=1,p=[(size,0,0),(-0.5*size,0,size),(-0.5*size,0,-1*size),(size,0,0),(-0.5*size,size,0),(-0.5*size,0,0),(-0.5*size,-1*size,0),(size,0,0)],n=tag_name)
shape=mc.listRelatives (tag_,s=1)[0]
mc.rename(shape,tag_name+'Shape')
if ON_OFF_4X==1:
mc.addAttr(tag_,ln='_4X',at='enum',en='____:',k=1)
mc.setAttr(tag_+'._4X',l=1)
attribute_4X=['_4X_positive_Z','_4X_positive_Y','_4X_negative_Z','_4X_negative_Y']
for i in range(4):
mc.addAttr(tag_,ln=attribute_4X[i],at='double',k=1)
if ON_OFF_8X==1:
mc.addAttr(tag_,ln='_8X',at='enum',en='____:',k=1)
mc.setAttr(tag_+'._8X',l=1)
attribute_8X=['_8X_positive_YZ','_8X_positive_Z','_8X_positive_ZY','_8X_positive_Y','_8X_negative_YZ','_8X_negative_Z','_8X_negative_ZY','_8X_negative_Y']
for i in range(8):
mc.addAttr(tag_,ln=attribute_8X[i],at='double',k=1)
mc.addAttr(tag_,ln='closepiont_1',at='double')
mc.addAttr(tag_,ln='closepiont_2',at='double')
mc.addAttr(tag_,ln='closepiont_1_range',at='double')
mc.addAttr(tag_,ln='closepiont_2_range',at='double')
mc.addAttr(tag_,ln='condition_1_st',at='double')
mc.addAttr(tag_,ln='condition_2_st',at='double')
mc.addAttr(tag_,ln='condition_1_ed',at='double')
mc.addAttr(tag_,ln='condition_2_ed',at='double')
'创建 关联 加减节点 函数'
def connectAttr_plusMinusAverage(self,pma_name,intput_pma_1,intput_pma_2,output_pma,tag_name,X8orX4):
mc.createNode('plusMinusAverage',n=pma_name)
mc.setAttr(pma_name+'.input3D[0]',1,1,1)
mc.setAttr(pma_name+'.input3D[1]',1,1,1)
mc.connectAttr(intput_pma_1+'.outValueX',pma_name+'.input3D[0].input3Dx')
mc.connectAttr(intput_pma_2+'.outValueY',pma_name+'.input3D[1].input3Dx')
#mc.connectAttr(pma_name+'.output3Dx',output_pma)
md=mc.createNode('multiplyDivide',n=pma_name+'_size')
mc.setAttr(md+'.input2X',2)
mc.connectAttr(pma_name+'.output3Dx',md+'.input1X')
mc.connectAttr(md+'.outputX',output_pma)
self.connect_8Xor4X_Fun(tag_name,[md],X8orX4)
def operation(self):
name=mc.textFieldGrp( self.text_,q=1,tx=1 )
Rad=mc.floatSliderGrp(self.radius,q=1,value=1)
ON_OFF_4X=mc.checkBoxGrp(self.check_,q=1,v1=1)
ON_OFF_8X=mc.checkBoxGrp(self.check_,q=1,v2=1)
'创建 M1 M2sphere '
sphere_M1=name+'_M1_sphere'
self.sphere_fun(sphere_M1,ssw_=30,esw_=330,s_=20,nsp_=10,r_=Rad,ro_=(0,180,90))
sphere_M2=name+'_M2_sphere'
self.sphere_fun(sphere_M2,ssw_=30,esw_=330,s_=20,nsp_=10,r_=Rad,ro_=(0,0,90))
###
'创建标签物体'
tag_name=name+'_sphere_tag'
self.tag_fun(tag_name,Rad,ON_OFF_4X,ON_OFF_8X)
###
sphere_grp=mc.group(sphere_M1,sphere_M2,tag_name,n=name+'_sphere_grp')
'创建 目标loc'
aimloc_name=name+'_aimloc'
aimloc_name_grp=name+'_aimloc_grp'
self.aimloc_fun(aimloc_name,aimloc_name_grp)
mc.setAttr(aimloc_name_grp+'.tx',Rad*4)
###
if mc.radioButtonGrp(self.radio,q=1,select=1) !=1:
mc.setAttr(sphere_grp+'.ry',180)
mc.makeIdentity(sphere_grp,apply=1,t=1,r=1,s=1)
mc.setAttr(aimloc_name_grp+'.tx',Rad*-4)
else:
pass
'创建M1 M2 closetriont节点和关联 '
closetroint_M1_name=name+'_closetpoint_M1'
closetpoint_range_name_M1=closetroint_M1_name+'_setRange'
self.closetroint_fun(closetroint_M1_name,sphere_M1,aimloc_name,closetpoint_range_name_M1,tag_name,'1')
closetroint_M2_name=name+'_closetpoint_M2'
closetpoint_range_name_M2=closetroint_M2_name+'_setRange'
self.closetroint_fun(closetroint_M2_name,sphere_M2,aimloc_name,closetpoint_range_name_M2,tag_name,'2')
###
'M1 M2 条件节点和关联'
condition_M1_st=name+'_M1_condition_st'
condition_M1_ed=name+'_M1_condition_ed'
self.connectAttr_M_sphere_condition_fun(condition_M1_st,condition_M1_ed,closetpoint_range_name_M1,tag_name,'1')
condition_M2_st=name+'_M2_condition_st'
condition_M2_ed=name+'_M2_condition_ed'
self.connectAttr_M_sphere_condition_fun(condition_M2_st,condition_M2_ed,closetpoint_range_name_M2,tag_name,'2')
if ON_OFF_4X==1:
self.create_4X(name,tag_name,condition_M1_ed,condition_M2_ed)
if ON_OFF_8X==1:
self.create_8X(name,tag_name,condition_M1_ed,condition_M2_ed)
def create_8X(self,name,tag_name,condition_M1_ed,condition_M2_ed):
'创建8X '
'分割M1 M2 区域 8X'
M1_scope_1_name_st=name+'_M1_8X_scope_1_st'
M1_scope_1_name_ed=name+'_M1_8X_scope_1_ed'
M1_scope_2_name_st=name+'_M1_8X_scope_2_st'
M1_scope_2_name_ed=name+'_M1_8X_scope_2_ed'
M1_scope_3_name_st=name+'_M1_8X_scope_3_st'
M1_scope_3_name_ed=name+'_M1_8X_scope_3_ed'
M1_scope_4_name_st=name+'_M1_8X_scope_4_st'
M1_scope_4_name_ed=name+'_M1_8X_scope_4_ed'
M2_scope_1_name_st=name+'_M2_8X_scope_1_st'
M2_scope_1_name_ed=name+'_M2_8X_scope_1_ed'
M2_scope_2_name_st=name+'_M2_8X_scope_2_st'
M2_scope_2_name_ed=name+'_M2_8X_scope_2_ed'
M2_scope_3_name_st=name+'_M2_8X_scope_3_st'
M2_scope_3_name_ed=name+'_M2_8X_scope_3_ed'
M2_scope_4_name_st=name+'_M2_8X_scope_4_st'
M2_scope_4_name_ed=name+'_M2_8X_scope_4_ed'
M1_scope_all_name_st=[M1_scope_1_name_st,M1_scope_2_name_st,M1_scope_3_name_st,M1_scope_4_name_st]
M1_scope_all_name_ed=[M1_scope_1_name_ed,M1_scope_2_name_ed,M1_scope_3_name_ed,M1_scope_4_name_ed]
M2_scope_all_name_st=[M2_scope_1_name_st,M2_scope_2_name_st,M2_scope_3_name_st,M2_scope_4_name_st]
M2_scope_all_name_ed=[M2_scope_1_name_ed,M2_scope_2_name_ed,M2_scope_3_name_ed,M2_scope_4_name_ed]
scope_st=[0.201,0.351,0.501,0.651]
scope_ed=[0.351,0.501,0.651,0.801]
for i in range(4):
self.division_sphere_fun(M1_scope_all_name_st[i],M1_scope_all_name_ed[i],condition_M1_ed,scope_st[i],scope_ed[i])
self.division_sphere_fun(M2_scope_all_name_st[i],M2_scope_all_name_ed[i],condition_M2_ed,scope_st[i],scope_ed[i])
M_scope_all_name=M1_scope_all_name_st+M1_scope_all_name_ed+M2_scope_all_name_st+M2_scope_all_name_ed
self.connect_8Xor4X_Fun(tag_name,M_scope_all_name,8)
###
'把区间变为 0-1 8X'
M1_scope_setrange_st_1=name+'_M1_8X_setrange_1_st'
M1_scope_setrange_st_2=name+'_M1_8X_setrange_2_st'
M1_scope_setrange_st_3=name+'_M1_8X_setrange_3_st'
M1_scope_setrange_st_4=name+'_M1_8X_setrange_4_st'
M1_scope_setrange_ed_1=name+'_M1_8X_setrange_1_ed'
M1_scope_setrange_ed_2=name+'_M1_8X_setrange_2_ed'
M1_scope_setrange_ed_3=name+'_M1_8X_setrange_3_ed'
M1_scope_setrange_ed_4=name+'_M1_8X_setrange_4_ed'
M2_scope_setrange_st_1=name+'_M2_8X_setrange_1_st'
M2_scope_setrange_st_2=name+'_M2_8X_setrange_2_st'
M2_scope_setrange_st_3=name+'_M2_8X_setrange_3_st'
M2_scope_setrange_st_4=name+'_M2_8X_setrange_4_st'
M2_scope_setrange_ed_1=name+'_M2_8X_setrange_1_ed'
M2_scope_setrange_ed_2=name+'_M2_8X_setrange_2_ed'
M2_scope_setrange_ed_3=name+'_M2_8X_setrange_3_ed'
M2_scope_setrange_ed_4=name+'_M2_8X_setrange_4_ed'
M1_scope_setrange_st_all=[M1_scope_setrange_st_1,M1_scope_setrange_st_2,M1_scope_setrange_st_3,M1_scope_setrange_st_4]
M1_scope_setrange_ed_all=[M1_scope_setrange_ed_1,M1_scope_setrange_ed_2,M1_scope_setrange_ed_3,M1_scope_setrange_ed_4]
M2_scope_setrange_st_all=[M2_scope_setrange_st_1,M2_scope_setrange_st_2,M2_scope_setrange_st_3,M2_scope_setrange_st_4]
M2_scope_setrange_ed_all=[M2_scope_setrange_ed_1,M2_scope_setrange_ed_2,M2_scope_setrange_ed_3,M2_scope_setrange_ed_4]
for i in range(4):
self.scope_to_setrange_fun(M1_scope_setrange_st_all[i],M1_scope_setrange_ed_all[i],M1_scope_all_name_ed[i],scope_st[i],scope_ed[i]-0.001,tag_name,8)
self.scope_to_setrange_fun(M2_scope_setrange_st_all[i],M2_scope_setrange_ed_all[i],M2_scope_all_name_ed[i],scope_st[i],scope_ed[i]-0.001,tag_name,8)
M_scope_setrange_all=M1_scope_setrange_st_all+M1_scope_setrange_ed_all+M2_scope_setrange_st_all+M2_scope_setrange_ed_all
self.connect_8Xor4X_Fun(tag_name,M_scope_setrange_all,8)
###
'创建 关联 加减节点 8X'
pma_name_1=name+'_8X_pma_1'
pma_name_2=name+'_8X_pma_2'
pma_name_3=name+'_8X_pma_3'
pma_name_4=name+'_8X_pma_4'
pma_name_5=name+'_8X_pma_5'
pma_name_6=name+'_8X_pma_6'
pma_name_7=name+'_8X_pma_7'
pma_name_8=name+'_8X_pma_8'
pma_name_all=[pma_name_1,pma_name_2,pma_name_3,pma_name_4,pma_name_5,pma_name_6,pma_name_7,pma_name_8]
intput_pma_1_all=[M1_scope_setrange_ed_1,M1_scope_setrange_ed_2,M1_scope_setrange_ed_3,M1_scope_setrange_ed_4,M2_scope_setrange_ed_1,M2_scope_setrange_ed_2,M2_scope_setrange_ed_3,M2_scope_setrange_ed_4]
intput_pma_2_all=[M1_scope_setrange_ed_2,M1_scope_setrange_ed_3,M1_scope_setrange_ed_4,M2_scope_setrange_ed_1,M2_scope_setrange_ed_2,M2_scope_setrange_ed_3,M2_scope_setrange_ed_4,M1_scope_setrange_ed_1]
attribute_8X=['_8X_positive_YZ','_8X_positive_Z','_8X_positive_ZY','_8X_positive_Y','_8X_negative_YZ','_8X_negative_Z','_8X_negative_ZY','_8X_negative_Y']
for i in range(8):
self.connectAttr_plusMinusAverage(pma_name_all[i],intput_pma_1_all[i],intput_pma_2_all[i],tag_name+'.'+attribute_8X[i],tag_name,8)
self.connect_8Xor4X_Fun(tag_name,pma_name_all,8)
def create_4X(self,name,tag_name,condition_M1_ed,condition_M2_ed):
'创建4X '
'分割M1 M2 区域 4X '
M1_4X_scope_1_name_st=name+'_M1_4X_scope_1_st'
M1_4X_scope_2_name_st=name+'_M1_4X_scope_2_st'
M1_4X_scope_1_name_ed=name+'_M1_4X_scope_1_ed'
M1_4X_scope_2_name_ed=name+'_M1_4X_scope_2_ed'
M2_4X_scope_1_name_st=name+'_M2_4X_scope_1_st'
M2_4X_scope_2_name_st=name+'_M2_4X_scope_2_st'
M2_4X_scope_1_name_ed=name+'_M2_4X_scope_1_ed'
M2_4X_scope_2_name_ed=name+'_M2_4X_scope_2_ed'
M1_4X_scope_all_name_st=[M1_4X_scope_1_name_st,M1_4X_scope_2_name_st]
M1_4X_scope_all_name_ed=[M1_4X_scope_1_name_ed,M1_4X_scope_2_name_ed]
M2_4X_scope_all_name_st=[M2_4X_scope_1_name_st,M2_4X_scope_2_name_st]
M2_4X_scope_all_name_ed=[M2_4X_scope_1_name_ed,M2_4X_scope_2_name_ed]
scope_4X_st=[0.201,0.501]
scope_4X_ed=[0.501,0.801]
for i in range(2):
self.division_sphere_fun(M1_4X_scope_all_name_st[i],M1_4X_scope_all_name_ed[i],condition_M1_ed,scope_4X_st[i],scope_4X_ed[i])
self.division_sphere_fun(M2_4X_scope_all_name_st[i],M2_4X_scope_all_name_ed[i],condition_M2_ed,scope_4X_st[i],scope_4X_ed[i])
M_4X_scope_all_name=M1_4X_scope_all_name_st+M1_4X_scope_all_name_ed+M2_4X_scope_all_name_st+M2_4X_scope_all_name_ed
self.connect_8Xor4X_Fun(tag_name,M_4X_scope_all_name,4)
###
'把区间变为 0-1 4X '
M1_4X_scope_setrange_st_1=name+'_M1_4X_setrange_1_st'
M1_4X_scope_setrange_st_2=name+'_M1_4X_setrange_2_st'
M1_4X_scope_setrange_ed_1=name+'_M1_4X_setrange_1_ed'
M1_4X_scope_setrange_ed_2=name+'_M1_4X_setrange_2_ed'
M2_4X_scope_setrange_st_1=name+'_M2_4X_setrange_1_st'
M2_4X_scope_setrange_st_2=name+'_M2_4X_setrange_2_st'
M2_4X_scope_setrange_ed_1=name+'_M2_4X_setrange_1_ed'
M2_4X_scope_setrange_ed_2=name+'_M2_4X_setrange_2_ed'
M1_4X_scope_setrange_st_all=[M1_4X_scope_setrange_st_1,M1_4X_scope_setrange_st_2]
M1_4X_scope_setrange_ed_all=[M1_4X_scope_setrange_ed_1,M1_4X_scope_setrange_ed_2]
M2_4X_scope_setrange_st_all=[M2_4X_scope_setrange_st_1,M2_4X_scope_setrange_st_2]
M2_4X_scope_setrange_ed_all=[M2_4X_scope_setrange_ed_1,M2_4X_scope_setrange_ed_2]
for i in range(2):
self.scope_to_setrange_fun(M1_4X_scope_setrange_st_all[i],M1_4X_scope_setrange_ed_all[i],M1_4X_scope_all_name_ed[i],scope_4X_st[i],scope_4X_ed[i]-0.001,tag_name,4)
self.scope_to_setrange_fun(M2_4X_scope_setrange_st_all[i],M2_4X_scope_setrange_ed_all[i],M2_4X_scope_all_name_ed[i],scope_4X_st[i],scope_4X_ed[i]-0.001,tag_name,4)
M_4X_scope_setrange_all=M1_4X_scope_setrange_st_all+M1_4X_scope_setrange_ed_all+M2_4X_scope_setrange_st_all+M2_4X_scope_setrange_ed_all
self.connect_8Xor4X_Fun(tag_name,M_4X_scope_setrange_all,4)
###
'创建 关联 加减节点 8X'
pma_4X_name_1=name+'_4X_pma_1'
pma_4X_name_2=name+'_4X_pma_2'
pma_4X_name_3=name+'_4X_pma_3'
pma_4X_name_4=name+'_4X_pma_4'
pma_4X_name_all=[pma_4X_name_1,pma_4X_name_2,pma_4X_name_3,pma_4X_name_4]
intput_pma_4X_1_all=[M1_4X_scope_setrange_ed_1,M1_4X_scope_setrange_ed_2,M2_4X_scope_setrange_ed_1,M2_4X_scope_setrange_ed_2]
intput_pma_4X_2_all=[M1_4X_scope_setrange_ed_2,M2_4X_scope_setrange_ed_1,M2_4X_scope_setrange_ed_2,M1_4X_scope_setrange_ed_1]
attribute_4X=['_4X_positive_Z','_4X_positive_Y','_4X_negative_Z','_4X_negative_Y']
for i in range(4):
self.connectAttr_plusMinusAverage(pma_4X_name_all[i],intput_pma_4X_1_all[i],intput_pma_4X_2_all[i],tag_name+'.'+attribute_4X[i],tag_name,4)
self.connect_8Xor4X_Fun(tag_name,pma_4X_name_all,4)
def connect_8Xor4X_Fun(self,tag_name,con,X8orX4):
if X8orX4==8:
xx='X8'
xx2='_8X'
else:
xx='X4'
xx2='_4X'
for i in con:
mc.addAttr(i,ln=xx,at='double',k=1)
mc.connectAttr(tag_name+'.%s'%xx2,i+'.%s'%xx)
def del_driven_Fun(self):
'删除驱动'
sel=mc.ls(sl=1)[0]
xx=mc.radioButtonGrp(self.radio_del,q=1,sl=1)
if xx==1:
if mc.objExists (sel+'._4X')==1:
all_node=mc.listConnections (sel+'._4X')
mc.delete(all_node)
mc.setAttr(sel+'._4X',l=0)
for i in ['._4X','._4X_positive_Z','._4X_positive_Y','._4X_negative_Z','._4X_negative_Y']:
mc.deleteAttr(sel+i)
else:
pass
else:
if mc.objExists (sel+'._8X')==1:
all_node=mc.listConnections (sel+'._8X')
mc.delete(all_node)
mc.setAttr(sel+'._8X',l=0)
for i in ['._8X','._8X_positive_YZ','._8X_positive_Z','._8X_positive_ZY','._8X_positive_Y','._8X_negative_YZ','._8X_negative_Z','._8X_negative_ZY','._8X_negative_Y']:
mc.deleteAttr(sel+i)
else:
pass
def add_driven_Fun(self):
'添加驱动'
sel=mc.ls(sl=1)[0]
xx=mc.radioButtonGrp(self.radio_add,q=1,sl=1)
name=sel
condition_M1_ed=mc.listConnections (sel+'.condition_1_ed')[0]
condition_M2_ed=mc.listConnections (sel+'.condition_2_ed')[0]
if xx==1:
if mc.objExists (sel+'._4X')==1:
pass
else:
mc.addAttr(sel,ln='_4X',at='enum',en='____:',k=1)
mc.setAttr(sel+'._4X',l=1)
attribute_4X=['_4X_positive_Z','_4X_positive_Y','_4X_negative_Z','_4X_negative_Y']
for i in range(4):
mc.addAttr(sel,ln=attribute_4X[i],at='double',k=1)
self.create_4X(name,sel,condition_M1_ed,condition_M2_ed)
else:
if mc.objExists (sel+'._8X')==1:
pass
else:
mc.addAttr(sel,ln='_8X',at='enum',en='____:',k=1)
mc.setAttr(sel+'._8X',l=1)
attribute_8X=['_8X_positive_YZ','_8X_positive_Z','_8X_positive_ZY','_8X_positive_Y','_8X_negative_YZ','_8X_negative_Z','_8X_negative_ZY','_8X_negative_Y']
for i in range(8):
mc.addAttr(sel,ln=attribute_8X[i],at='double',k=1)
self.create_8X(name,sel,condition_M1_ed,condition_M2_ed)
mc.select(sel)
if __name__ == '__main__':
shapeHelper_UV_UI()
上一篇
从maya获取到单独的panel放到自己写的界面上
2024-05-10
下一篇
删除残留插件
2024-05-10