maya_class_04

旧街凉风 提交于 2019-12-29 21:44:59
# -*- coding: utf-8 -*-
# .@FileName:maya_study4
# ..:XingLian
import pymel.core as pm
import os
import glob


'''
创建referen
'''
def create_reference(file_dir):
    file_list = glob.glob('{}/*.ma'.format(file_dir))
    for i in file_list:
        pm.createReference(i, typ='mayaAscii', ns=os.path.split(i)[-1])


'''
批量创建小球
'''
def create_ui():
    window = 'sphere_ui'
    if pm.window(window, q=1, ex=1):
        pm.deleteUI(window)
        cmds.windowPref(window, r=1)
    pm.window(window, t=u'测试题二',wh=(250, 100), tlc=(200, 1400))
    pm.columnLayout('main_layout')
    pm.intSliderGrp('sphere_num_slider', l=u'小球数量', f=1, min=1, v=1,
                    cw3=(60, 40, 125), cat=[(1, 'left', 10), (3, 'both', 5)])
    pm.floatSliderGrp('redius_size_slider', l=u'小球半径', f=1, v=1,
                      fmn=0.01, fmx=20, min=0.01, max=2, pre=2, s=0.01, 
                      cw3=(60, 40, 125), cat=[(1, 'left', 10), (3, 'both', 5)])
    pm.button('create_sphere_butt', l=u'走你!!!', w=250, h=40, c=create_sphere_func)    
    cmds.showWindow(window)

def create_sphere_func(*args, **kwargs):
    sphere_num = pm.intSliderGrp('sphere_num_slider', q=1, v=1)
    redius = pm.floatSliderGrp('redius_size_slider', q=1, v=1)
    for i in range(sphere_num):
        sphere = pm.polySphere(r=redius, n='sphere_mo{:0>2}'.format(i))[0]
        sphere.tx.set(i%10*redius*2)
        sphere.tz.set(i//10*redius*2)


'''
playblaset
'''
def only_mesh_playblast():
    model_panel = pm.getPanel(typ='modelPanel') 
    vis_panel = pm.getPanel(vis=1)
    x = [i for i in vis_panel if i in model_panel][0]
    pm.modelPanel(x, e=1, cam='user_cam')
    pm.modelEditor(x, e=1, alo=0)
    pm.modelEditor(x, e=1, pm=1)
    pm.playblast()
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!