def sdk_call(mode_obj, attributes_obj, search_obj, replace_obj, mirror_obj, att_chk): sel_mode = mode_obj.getSelect() mode_opn = str(pm.radioButton(sel_mode, query=True, label=True)) srch_txt = search_obj.getText() rplc_txt = replace_obj.getText() attrs_sel = pm.textScrollList(attributes_obj, query=True, selectItem=True) mirror_val = pm.checkBox(mirror_obj, query=True, value=True) att_val = False if str(mode_opn) == "driver": att_val = pm.checkBox(att_chk, query=True, value=True) if not mirror_val: if srch_txt == "" or rplc_txt == "": copy_SDK.copySDK(curAttrs=attrs_sel, mode=mode_opn, createDriverAttr=att_val) else: copy_SDK.copySDK(curAttrs=attrs_sel, mode=mode_opn, search=srch_txt, replace=rplc_txt, createDriverAttr=att_val) else: if srch_txt == "" or rplc_txt == "": copy_SDK.copySDK(curAttrs=attrs_sel, mode=mode_opn, mirrorAttrs=attrs_sel, createDriverAttr=att_val) else: copy_SDK.copySDK(curAttrs=attrs_sel, mode=mode_opn, search=srch_txt, mirrorAttrs=attrs_sel, replace=rplc_txt, createDriverAttr=att_val) return None
def get_boolean_mode(): if pma.radioButton(addRadioB, query=True, select=True): return BOOLEANMODE_ADD if pma.radioButton(subRadioB, query=True, select=True): return BOOLEANMODE_SUBTRACT return None
if (pma.window(windowName, exists=True)): pma.deleteUI(windowName) window = pma.window(windowName, title=windowName, width=120, height=200) pma.columnLayout("mainColumn", adjustableColumn=True) ################################################################################################UI################################################# pma.gridLayout("nameGridLayout01", numberOfRowsColumns=(1, 4), cellWidthHeight=(40, 40), parent="mainColumn") pma.symbolButton("nameButton1", image="polyCube.png", width=40, height=40, backgroundColor=[0.2, 0.2, 0.2], parent="nameGridLayout01", command="creator(PRIMITIVE_CUBE)") pma.symbolButton("nameButton2", image="polyCylinder.png", width=40, height=40, backgroundColor=[0.2, 0.2, 0.2], parent="nameGridLayout01", command="creator(PRIMITIVE_CYLINDER)") pma.symbolButton("nameButton3", image="polySphere.png", width=40, height=40, backgroundColor=[0.2, 0.2, 0.2], parent="nameGridLayout01", command="creator(PRIMITIVE_SPHERE)") pma.columnLayout("columnLayoutName01", adjustableColumn=True, backgroundColor=[0.2, 0.2, 0.2]) pma.radioCollection("collection10", parent="columnLayoutName01") subRadioB = pma.radioButton("subRadio", select=True, label="Sub") addRadioB = pma.radioButton("addRadio", label="Add") pma.setParent('..') pma.setParent('..') ################################################################################################UI################################################# pma.separator(parent="mainColumn", height=20) pma.button("customMeshB", label="Use Custom Mesh", width=120, height=40, backgroundColor=[0.2, 0.2, 0.2], parent="mainColumn", command="creator(PRIMITIVE_CUSTOM)") pma.separator(parent="mainColumn", height=20) ################################################################################################UI################################################# pma.gridLayout("nameGridLayout03", numberOfRowsColumns=(1, 3), cellWidthHeight=(53, 40), parent="mainColumn") pma.button("hidSelB", label="Hide Sel", height=40, backgroundColor=[0.2, 0.2, 0.2], parent="nameGridLayout03", command="hider(0)") pma.button("hidAllB", label="Hide All", height=40, backgroundColor=[0.2, 0.2, 0.2], parent="nameGridLayout03",
def copySDK_UI(): WINDOW = 'copySDK' if pm.window(WINDOW, query=True, exists=True): pm.deleteUI(WINDOW) pm.window(WINDOW, title="copySDK", iconName='SDKcpy', widthHeight=(210, 370)) # Layout column_1 = pm.columnLayout(adjustableColumn=True) textlabel = pm.text(label="UI for script downloaded from\ highend3d.com\nContact Email : [email protected]", align="center", wordWrap=True) pm.separator(height=20, style='in', parent=column_1) col2 = pm.columnLayout(width=200, adjustableColumn=False, parent=column_1) row_col_1 = pm.rowColumnLayout(numberOfColumns=2, columnWidth=(1, 100), parent=column_1, columnOffset=(2, 'left', 10)) pm.separator(height=20, style='in', parent=column_1) col3 = pm.columnLayout(width=200, adjustableColumn=False, parent=column_1) row_col_2 = pm.rowColumnLayout(numberOfColumns=2, columnWidth=(1, 100), parent=column_1, columnOffset=(2, 'left', 10)) row_col_3 = pm.rowColumnLayout(numberOfColumns=2, columnWidth=(1, 100), parent=column_1, columnOffset=(2, 'left', 10)) pm.separator(height=20, style='in', parent=column_1) row_col_4 = pm.rowColumnLayout(numberOfColumns=2, columnWidth=(1, 100), parent=column_1, columnOffset=(2, 'left', 10)) row_col_5 = pm.rowColumnLayout(numberOfRows=2, parent=row_col_4) column_2 = pm.columnLayout(adjustableColumn=False, width=200, columnOffset=["both", 50], parent=column_1) # Widgets cr_attr_chk_bx = pm.checkBox('Create attribute', parent=column_2, editable=False) mode_lbl = pm.text(label="mode", align="center", parent=col2, width=200) mode_radio = pm.radioCollection(parent=column_1) rb1 = pm.radioButton(label='driven', parent=row_col_1, select=True, onCommand=lambda x: pm.checkBox( cr_attr_chk_bx, edit=True, editable=False)) rb1 = pm.radioButton(label='driver', parent=row_col_1, select=False, onCommand=lambda x: pm.checkBox( cr_attr_chk_bx, edit=True, editable=True)) ctr_replace_lbl = pm.text(label="controller", align="center", parent=col3, width=200) search_lbl = pm.text(label="search", align="center", parent=row_col_2, width=100) replace_lbl = pm.text(label="replace", align="center", parent=row_col_2, width=100) search_str = pm.TextField(text='', parent=row_col_3) replace_str = pm.TextField(text='', parent=row_col_3) refresh_button = pm.button( label='Refresh', parent=row_col_5, command=lambda x: populate_attr(field_obj=attr_list)) attr_list = pm.textScrollList('Attr', numberOfRows=10, parent=row_col_5, height=150, width=100, allowMultiSelection=True) populate_attr(field_obj=attr_list) mirror_chk_bx = pm.checkBox('mirror', parent=row_col_4) apply_button = pm.button( label='Apply', parent=column_2, width=100, command=lambda x: sdk_call(mode_radio, attr_list, search_str, replace_str, mirror_chk_bx, cr_attr_chk_bx)) pm.showWindow(WINDOW) pm.window(WINDOW, edit=True, widthHeight=(210, 370)) return None
def create_control_ui(self): btns = self.read_shapes() WINDOW = "create_control" chk_win = pm.window(WINDOW, query=True, exists=True) if chk_win: pm.deleteUI(WINDOW) pm.window(WINDOW, title="Create_Control", iconName="CC") main_split_col = pm.rowColumnLayout(parent=WINDOW, numberOfColumns=3) left_main_col = pm.columnLayout(parent=main_split_col, adjustableColumn=True) hlp_btn_col = pm.columnLayout(parent=left_main_col, columnOffset=("left", 110)) pm.button("?", parent=hlp_btn_col, width=50, command=lambda x: self.open_help()) pm.separator(parent=left_main_col, style="in", height=10) con_obj_col = pm.columnLayout(parent=left_main_col, columnOffset=("left", 70)) self.connect_chk_bx = pm.checkBox("Skinning/Constraint", parent=con_obj_col, value=True) pm.separator(parent=left_main_col, style="none") ctrl_typ_col = pm.rowColumnLayout(parent=left_main_col, numberOfColumns=3, columnOffset=(1, "left", 20), columnSpacing=(2, 10)) pm.text("Control type", parent=ctrl_typ_col) rad_col = pm.columnLayout(parent=ctrl_typ_col) self.ctr_typ_rad_collection = pm.radioCollection(parent=rad_col) self.skin_rad_btn = pm.radioButton( label='Skin', parent=rad_col, select=True, onCommand=lambda x: self.set_ui_edit_mode(flag="Skin")) self.con_rad_btn = pm.radioButton( label='Constraint', parent=rad_col, onCommand=lambda x: self.set_ui_edit_mode(flag="Constraint")) con_typ_col = pm.columnLayout(parent=ctrl_typ_col) self.pr_chk_bx = pm.checkBox("Parent", parent=con_typ_col, value=True, editable=False) self.sc_chk_bx = pm.checkBox("Scale", parent=con_typ_col, editable=False) jnt_opn_col = pm.columnLayout(parent=left_main_col, columnOffset=("left", 100)) self.jnt_cr_chk_bx = pm.checkBox( label="Create Joint", value=True, parent=jnt_opn_col, offCommand=lambda x: self.set_ui_edit_mode(flag="no_joint")) pm.separator(parent=left_main_col, height=10, style="in") pm.text("Control name", parent=left_main_col) re_name_col = pm.gridLayout(parent=left_main_col, numberOfRowsColumns=(2, 2), cellWidthHeight=(138, 20), allowEmptyCells=False) self.msh_nm_lbl = pm.text("Text from Mesh Name", parent=re_name_col) self.ctrl_nm_lbl = pm.text("Rename to Control", parent=re_name_col) self.msh_nm = pm.textField(text="_MSH", parent=re_name_col) self.ctrl_nm = pm.textField(text="_CTRL", parent=re_name_col) pm.separator(parent=left_main_col, height=10, style="none") new_name_col = pm.rowColumnLayout(parent=left_main_col, numberOfColumns=2, columnOffset=(1, "left", 10)) self.new_nm_chk_bx = pm.checkBox( label="Control Name: ", parent=new_name_col, changeCommand=lambda x: self.set_ui_edit_mode(flag="rename_field")) self.ctr_new_nm = pm.textField(text="Control", parent=new_name_col, width=150, editable=False) suf_name_col = pm.rowColumnLayout(parent=left_main_col, numberOfColumns=2, columnOffset=(1, "left", 10)) self.suf_lbl = pm.text("Control Suffix Text: ", parent=suf_name_col) self.suf_nm = pm.textField(text="_CTRL", parent=suf_name_col, width=163, editable=False) pm.separator(parent=left_main_col, height=10, style="none") zero_gp_col = pm.rowColumnLayout(parent=left_main_col, numberOfColumns=2, columnOffset=(1, "left", 50)) self.zero_gp_chk_bx = pm.checkBox( "Zero Node", parent=zero_gp_col, value=True, changeCommand=lambda x: self.set_ui_edit_mode(flag="zero_node")) self.zero_nd_txt = pm.textField(text="_CTRLT", parent=zero_gp_col) scl_lk_col = pm.columnLayout(parent=left_main_col, columnOffset=("left", 50)) self.scl_lk_chk_bx = pm.checkBox("Lock Scale/Visibility/Radius(Joint)", parent=scl_lk_col, value=True) scl_chk_col = pm.columnLayout(parent=left_main_col, columnOffset=("left", 50)) self.scl_ctr_chk_bx = pm.checkBox( "Scale Control to match object", value=True, parent=scl_chk_col, changeCommand=lambda x: self.set_ui_edit_mode(flag="no_scale")) scl_offset_col = pm.rowColumnLayout(parent=left_main_col, numberOfColumns=2, columnOffset=(1, "left", 30)) self.ctrl_off_sz_lbl = pm.text("Control size offset value", parent=scl_offset_col) self.scl_offset_val_txt = pm.textField(text="1", parent=scl_offset_col) pm.separator(parent=left_main_col, height=10, style="in") ctrl_pvt_col = pm.rowColumnLayout(parent=left_main_col, numberOfColumns=2, columnOffset=(1, "left", 80)) self.ctrl_pos_chk_bx = pm.checkBox( "Control at object pivot", parent=ctrl_pvt_col, value=True, changeCommand=lambda x: self.set_ui_edit_mode(flag="position")) pos_rad_col = pm.gridLayout(parent=left_main_col, numberOfRowsColumns=(3, 2), cellWidthHeight=(140, 20), allowEmptyCells=False) self.pos_rad_collection = pm.radioCollection(parent=pos_rad_col) self.top_rad_btn = pm.radioButton(label="Top(Y Axis)", parent=pos_rad_col, editable=False) self.bot_rad_btn = pm.radioButton(label="Bottom(Y Axis)", parent=pos_rad_col, select=True, editable=False) self.left_rad_btn = pm.radioButton(label="Left(X Axis)", parent=pos_rad_col, editable=False) self.right_rad_btn = pm.radioButton(label="Right(X Axis)", parent=pos_rad_col, editable=False) self.front_rad_btn = pm.radioButton(label="Front(Z Axis)", parent=pos_rad_col, editable=False) self.back_rad_btn = pm.radioButton(label="Back(Z Axis)", parent=pos_rad_col, editable=False) pm.separator(parent=main_split_col, height=10, style="in", horizontal=False) scr_lay = pm.scrollLayout(parent=main_split_col) grid_col = pm.gridLayout(parent=scr_lay, numberOfRowsColumns=(1, 5), autoGrow=True, cellWidthHeight=(50, 50), allowEmptyCells=False) for btn in btns: btn = btn.replace("\r", "") btn = btn.replace("\n", "") img = self.icon_path + btn + ".png" if os.path.exists(img): pm.iconTextButton(parent=grid_col, label=btn, style='iconOnly', image=img, command=partial(self.create_shape, nm=btn)) else: rgb = [ random.uniform(.5, 1), random.uniform(.5, 1), random.uniform(.5, 1) ] pm.iconTextButton(parent=grid_col, label=btn, style='iconAndTextVertical', backgroundColor=rgb, command=partial(self.create_shape, nm=btn)) pm.checkBox( self.connect_chk_bx, edit=True, changeCommand=lambda x: self.set_ui_edit_mode(flag="connect")) pm.showWindow(WINDOW) pm.window(WINDOW, edit=True, widthHeight=(540, 420)) return None
def get_position_selection(self): sel_opn = self.pos_rad_collection.getSelect() option_label = pm.radioButton(sel_opn, query=True, label=True) return option_label
def get_ctrl_type(self): sel_option = self.ctr_typ_rad_collection.getSelect() option_label = pm.radioButton(sel_option, query=True, label=True) return option_label
def spline_ik_setup_UI(): WINDOW = 'SplineIK' if pm.window(WINDOW, query=True, exists=True): pm.deleteUI(WINDOW) pm.window(WINDOW, title="Spline IK", iconName='SplineIK', widthHeight=(250, 310)) main_column = pm.columnLayout(adjustableColumn=True) pm.separator(height=5, style='in', parent=main_column) name_col = pm.rowColumnLayout(numberOfColumns=2, parent=main_column, columnOffset=(1, "left", 30), columnSpacing=(2, 5), columnWidth=(2, 130)) pm.separator(height=5, style='in', parent=main_column) joint_col = pm.rowColumnLayout(numberOfColumns=3, parent=main_column, columnOffset=(1, "left", 30), columnSpacing=(2, 5)) pm.separator(height=5, style='in', parent=main_column) dense_col = pm.rowColumnLayout(numberOfColumns=4, columnOffset=(1, "left", 5), parent=main_column, columnSpacing=(3, 10)) pm.separator(height=5, style='in', parent=main_column) curve_option_col = pm.rowColumnLayout(numberOfColumns=2, columnOffset=(1, "left", 5), parent=main_column, columnSpacing=(2, 70)) pm.separator(height=5, style='none', parent=main_column) curve_name_col = pm.rowColumnLayout(numberOfColumns=3, columnOffset=(1, "left", 40), parent=main_column, columnSpacing=(2, 5)) pm.separator(height=5, style='none', parent=main_column) curve_simplify_col = pm.rowColumnLayout(numberOfColumns=4, columnOffset=(1, "left", 5), parent=main_column, columnSpacing=(3, 5)) pm.separator(height=5, style='in', parent=main_column) stretch_col = pm.rowColumnLayout(numberOfColumns=2, columnWidth=(1, 100), parent=main_column, columnOffset=(1, "left", 5)) pm.separator(height=5, style='in', parent=main_column) global_scale_col = pm.rowColumnLayout(numberOfColumns=3, columnWidth=(1, 100), parent=main_column, columnOffset=(1, "left", 5), columnSpacing=(3, 10)) pm.separator(height=20, style='in', parent=main_column) ctrl_jnt_col = pm.rowColumnLayout(numberOfColumns=3, columnOffset=(1, "left", 5), parent=main_column, columnWidth=(3, 50), columnSpacing=(3, 5)) pm.separator(height=20, style='in', parent=main_column) create_btn_col = pm.rowColumnLayout(numberOfColumns=3, parent=main_column, columnOffset=(2, "left", 65), columnWidth=(2, 300)) pm.text(label="Ik name", parent=name_col) name_text = pm.TextField(text="", parent=name_col) pm.text(label="base joint", parent=joint_col) joint_name = pm.textField(text="", parent=joint_col) pm.button( label="<<", parent=joint_col, command=lambda x: joint_name.setText(str(pm.ls(selection=True)[0]))) dense_div_label = pm.text() dense_div_text = pm.textField() dense_chain_chb = pm.checkBox( "dense chain", parent=dense_col, changeCommand=lambda x: (dense_div_label.setEnable(dense_chain_chb.getValue()), dense_div_text.setEditable(dense_chain_chb.getValue()))) pm.separator(style='single', horizontal=False, parent=dense_col, width=20) pm.text(dense_div_label, edit=True, label="divisions", parent=dense_col, enable=dense_chain_chb.getValue()) pm.textField(dense_div_text, edit=True, text="3", parent=dense_col, editable=dense_chain_chb.getValue(), width=50) curve_label = pm.text(label="Curve", parent=curve_name_col) curve_text = pm.textField(text="", parent=curve_name_col, editable=False) curve_btn = pm.button( label="<<", parent=curve_name_col, enable=False, command=lambda x: curve_text.setText(str(pm.ls(selection=True)[0]))) spans_label = pm.text() spans_text = pm.TextField() curve_simple_chb = pm.checkBox( label="simplify curve", parent=curve_simplify_col, enable=True, changeCommand=lambda x: (spans_label.setEnable(curve_simple_chb.getValue()), spans_text.setEditable(curve_simple_chb.getValue()))) pm.separator(style='single', horizontal=False, parent=curve_simplify_col, width=5) pm.text(spans_label, edit=True, label="spans ", parent=curve_simplify_col, enable=curve_simple_chb.getValue()) pm.textField(spans_text, edit=True, text="3", parent=curve_simplify_col, editable=curve_simple_chb.getValue()) curve_create = pm.radioCollection(parent=curve_option_col) pm.radioButton( "AutoCurve", label="Auto Curve", select=True, parent=curve_option_col, onCommand=lambda x: (curve_btn.setEnable(False), curve_label.setEnable(False), curve_text.setEditable(False), curve_simple_chb.setEnable(True), spans_label.setEnable(curve_simple_chb.getValue()), spans_text.setEditable(curve_simple_chb.getValue()))) pm.radioButton( "UseCurve", label="use Curve", select=False, parent=curve_option_col, onCommand=lambda x: (curve_btn.setEnable(True), curve_label.setEnable(True), curve_text.setEditable(True), curve_simple_chb.setEnable(False), spans_label.setEnable(False), spans_text.setEditable(False))) stretch_scale_chb = pm.checkBox() global_scale_chb = pm.checkBox() scale_attr_text = pm.TextField() scale_label = pm.text() stretch_chb = pm.checkBox( label="stretch", parent=stretch_col, changeCommand=lambda x: (stretch_scale_chb.setEditable(stretch_chb.getValue()), global_scale_chb.setEditable(stretch_chb.getValue()), scale_attr_text.setEditable(stretch_chb.getValue() and global_scale_chb.getValue()), scale_label.setEnable(stretch_chb.getValue() and global_scale_chb. getValue()))) pm.checkBox(stretch_scale_chb, edit=True, label="connect scale", parent=stretch_col, editable=stretch_chb.getValue()) pm.checkBox(global_scale_chb, edit=True, label="global scale", parent=global_scale_col, editable=stretch_chb.getValue(), changeCommand=lambda x: (scale_attr_text.setEditable(global_scale_chb.getValue()), scale_label.setEnable(global_scale_chb.getValue()))) pm.text(scale_label, edit=True, label="scale attr", parent=global_scale_col, enable=(stretch_scale_chb.getValue() and stretch_chb.getValue)) pm.textField(scale_attr_text, edit=True, text="", parent=global_scale_col, editable=stretch_chb.getValue(), width=90) pm.text(label="number of control joints ", parent=ctrl_jnt_col) ctrl_jnt_num = pm.textField(text="3", parent=ctrl_jnt_col, width=50) pm.text(label="", parent=create_btn_col) pm.button(label="create", align="center", parent=create_btn_col, width=100, command=lambda x: call_fun(name_text.getText( ), joint_name.getText(), dense_chain_chb.getValue( ), int(dense_div_text.getText()), curve_create.getSelect( ), curve_text.getText(), curve_simple_chb.getValue( ), int(spans_text.getText()), stretch_chb.getValue( ), stretch_scale_chb.getValue(), int(ctrl_jnt_num.getText( )), global_scale_chb.getValue(), scale_attr_text.getText())) pm.showWindow(WINDOW) pm.window(WINDOW, edit=True, widthHeight=(250, 310)) return None
def get_placement_type(self): sel_option = self.jnt_typ_radio.getSelect() option_label = pm.radioButton(sel_option, query=True, label=True) return option_label
def tread_create_ui(self): self.WINDOW = 'Loop_Motion_Path' if pm.window(self.WINDOW, query=True, exists=True): pm.deleteUI(self.WINDOW) pm.window(self.WINDOW, title="Loop Motion Path", iconName='TR', widthHeight=(200, 220)) column_1 = pm.columnLayout(adjustableColumn=True) pm.separator(height=20, style='none', parent=column_1) self.tread_name = pm.TextField(text='Setup_Name', parent=column_1) pm.separator(height=20, style='none', parent=column_1) # get parent name row_col_1 = pm.rowColumnLayout(numberOfColumns=2, columnWidth=(1, 150), parent=column_1, columnOffset=(2, 'left', 10)) self.curve_name = pm.TextField(text='PathCurve', parent=row_col_1) pm.button(label='<<', parent=row_col_1, command=lambda x: self.set_path_name()) chk_bx_col = pm.rowColumnLayout(parent=column_1, numberOfColumns=2, columnWidth=(1, 20)) pm.text("", parent=chk_bx_col) self.dup_crv_chk_bx = pm.checkBox("Duplicate Curve", parent=chk_bx_col, value=True) pm.separator(height=20, style='in', parent=column_1) self.jnt_type_lbl = pm.text(label="object placement type", align="left", parent=column_1) pm.separator(height=5, style='none', parent=column_1) self.jnt_typ_radio = pm.radioCollection(parent=column_1) row_layout = pm.rowLayout(numberOfColumns=2, height=20, parent=column_1) sel_chk_bx_col = pm.rowColumnLayout(parent=column_1, numberOfColumns=2, columnWidth=(1, 20)) info_chk_bx_col = pm.ColumnLayout(parent=column_1) self.chk_bx_info = pm.text("", parent=info_chk_bx_col, enable=False) pm.text("", parent=sel_chk_bx_col) self.sel_obj_chk_bx = pm.checkBox("Use Selection On Curve", parent=sel_chk_bx_col, value=False, enable=False) self.divisions = pm.TextField(text='1', parent=column_1) pm.radioButton( label='uniform', parent=row_layout, select=True, onCommand=lambda x: self.ui_set_selection_enable(flag="uniform")) pm.radioButton( label='selection', parent=row_layout, onCommand=lambda x: self.ui_set_selection_enable(flag="selection")) pm.separator(height=20, style='none', parent=column_1) pm.text("Input sample object (default joint)", parent=column_1) sample_row_col = pm.rowColumnLayout(numberOfColumns=2, columnWidth=(1, 150), parent=column_1, columnOffset=(2, 'left', 10)) self.sample_name = pm.text(label="", parent=sample_row_col) pm.button(label='<<', parent=sample_row_col, command=lambda x: self.set_sample_object()) pm.separator(height=20, style='none', parent=column_1) pm.button(label='Create', parent=column_1, command=lambda x: self.setup_motion_path()) pm.showWindow(self.WINDOW) pm.window(self.WINDOW, edit=True, widthHeight=(200, 320)) return None