Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ----- get namespace here -----
- ns = cmds.ls("Alice_Ear_Muffins*:*:Geo_Grp")[0].split(":")[0]
- # ----- import latest ncloth Rig -----
- path = 'Y:/{}/assets/type/Character/{}/products/nClothRig/'.format(os.environ['TT_PROJCODE'],ns.rsplit('_',1)[0])
- tempFileList = os.listdir(path)
- tempFileList.sort()
- latestVer = tempFileList[-1]
- cfxWorks = path+'/'+latestVer
- from abc_sim_workflow import abc_tech_cache_util
- abc_tech_cache_util.insert_tech_cache_v2(
- cfxWorks,
- group_depth = ['nCloth_Rig'],
- insert_ns = [ns,'DYN'],
- ns_div=':',
- mode='reference'
- )
- rig_ns = ns+':DYN'
- abc_ns = ns+':ABC'
- # ----- using connect mesh method to connect ncloth sim mesh and animation output mesh -----
- for mesh in cmds.ls(abc_ns+':*proxyMesh'):
- # query the mesh and shape names
- anim_output_mesh=mesh
- anim_output_shape=cmds.listRelatives(mesh)[0]
- ncloth_input_mesh=rig_ns+':'+mesh.split(':')[-1]
- ncloth_input_shape=cmds.listRelatives(ncloth_input_mesh)[0]
- cmds.connectAttr(anim_output_shape+'.outMesh',ncloth_input_shape+'.inMesh', force=True)
- # ----- using connect mesh method to connect attract to mesh and animation output mesh -----
- for mesh in cmds.ls(abc_ns+':*proxyMesh'):
- # query the mesh and shape names
- anim_output_mesh=mesh
- anim_output_shape=cmds.listRelatives(mesh)[0]
- a2m_mesh=rig_ns+':'+mesh.split(':')[-1].split('__sim__')[0]+'__a2m__mesh'
- a2m_shape=cmds.listRelatives(a2m_mesh)[0]
- cmds.connectAttr(anim_output_shape+'.outMesh',a2m_mesh+'.inMesh', force=True)
- # ----- match anim offset -----
- cmds.matchTransform(rig_ns+':nclothRig_ctrl',abc_ns+':C_Main_Ground_Ctrl')
- from abc_sim_workflow.sim_obj_set_creator import preb_export_sets_ui_funcs
- reload(preb_export_sets_ui_funcs)
- sets_by_tags,obj_dict = preb_export_sets_ui_funcs.SetQuery.get_set_dicts(ass_list = [ns.rsplit('_',1)[0]],parse_data = True,use_cmdsls=False)
- asset_name = ns.rsplit('_',1)[0]
- cmds.group(n=abc_ns+':collision_mesh_grp',em=1)
- cmds.parent(abc_ns+':collision_mesh_grp',abc_ns+':Cloth')
- cmds.select(cl=1)
- for cld_set in sets_by_tags[asset_name]['Cloth']['cld']:
- obj_list = [obj_.replace('__ns__',abc_ns) for obj_ in obj_dict[asset_name]['Cloth'][cld_set]]
- collider_mesh_name = abc_ns+':'+cld_set+'_colliderMesh'
- #combine or duplicate collider meshes
- if len(obj_list)>1:
- cmds.select(obj_list)
- cmds.CombinePolygons()
- cmds.rename(collider_mesh_name)
- else:
- cmds.duplicate([obj.replace('__ns__',rig_ref_ns) for obj in collider_set_objs][0],n=collider_mesh_name)
- cmds.parent(collider_mesh_name,abc_ns+':collision_mesh_grp')
- for mesh in cmds.ls(abc_ns+':*_colliderMesh'):
- # query the mesh and shape names
- anim_output_mesh=mesh
- anim_output_shape=cmds.listRelatives(mesh)[0]
- ncloth_input_mesh=rig_ns+':'+mesh.split(':')[-1]
- ncloth_input_shape=cmds.listRelatives(ncloth_input_mesh)[0]
- cmds.connectAttr(anim_output_shape+'.outMesh',ncloth_input_shape+'.inMesh', force=True)
- # ----- wrap all the collider mesh into the master collision mesh -----
- for colliderMesh in cmds.ls(ns+'_ClothRig:*_colliderMesh'):
- command_utils.create_wrap_deformer(colliderMesh,ns+':Master_Collider_Geo',n='',exclusiveBind = 1)
- from abc_sim_workflow import abc_tech_ui_funcs
- abc_tech_ui_funcs.SimObjSetQuery.get_sets_in_scene()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement