def __init__(self): if pmel.window('LightLinks', q=1, ex=1): pmel.deleteUI('LightLinks') cmds.window('LightLinks', w=365, h=305, s=0) pmel.columnLayout('column') pmel.formLayout(p='column') pmel.rowLayout(nc=4) pmel.button(l='添加', w=85, h=25, c=partial(add_sel_lights, 0)) pmel.button(l='移除', w=85, h=25, c=partial(del_lights, 0)) pmel.button(l='移除所有', w=85, h=25, c=partial(del_all_lights, 0)) pmel.button(l='刷新', w=85, h=25, c=partial(refresh_lights, 0)) pmel.formLayout(p='column') pmel.rowLayout(nc=4) pmel.textScrollList('light_list', ams=True, w=260, h=200, da=1) pmel.text(l="", w=5) pmel.button(l='补光', w=70.5, h=25, c=partial(light_links, "fast_link", 0), bgc=(0.6, 0.5, 0)) pmel.formLayout(p='column') pmel.rowLayout(nc=4) pmel.button(l='断开所有', w=85, h=25, c=partial(light_links, "global_break", 0)) pmel.button(l='链接所有', w=85, h=25, c=partial(light_links, "global_make", 0)) pmel.button(l='断开选择', w=85, h=25, c=partial(light_links, "local_break", 0)) pmel.button(l='链接选择', w=85, h=25, c=partial(light_links, "local_make", 0)) pmel.formLayout(p='column') pmel.rowLayout(nc=4) pmel.button(l='查看列表里的灯光', w=172.5, h=25, c=partial(check_sel_lights, 0)) pmel.button(l='检查选择的灯光链接', w=172.5, h=25, bgc=(0.3, 0.35, 0), c=partial(check_light_links, 0)) pmel.formLayout('text_form', p='column') pmel.columnLayout(p='text_form', bgc=(0.15, 0.2, 0), w=347, h=20) pmel.text('warming:If you selected lights in scene,do first', p='text_form', h=20) pmel.showWindow('LightLinks')
def set_json_location(self): json_location = pm.fileDialog2(dialogStyle=2, fileFilter="JSON File (*.json);;", fileMode=0, okc=u"选择文件", cc=u"取消") if os.path.isfile(json_location[0]): pm.textFieldButtonGrp("ARFileLocationField", e=True, text=json_location[0]) self.ar_file_location = json_location[0] else: dict_data = {} mode = pm.radioButtonGrp(self.work_mode_control, q=True, sl=True) if mode == 1: dict_data = channel.face_unity_channels elif mode == 2: dict_data = channel.arkit_channels write_json(dict_data=dict_data, file_path=json_location[0]) pm.textFieldButtonGrp("ARFileLocationField", e=True, text=json_location[0]) self.ar_file_location = json_location[0] self.init_ar_channel_options(json_file=json_location[0]) pm.optionVar(sv=('ARFaceEditor_jsonFileLocation', self.ar_file_location)) if pm.textScrollList(self.ar_item_scroll, q=True, ni=True) > 1: pm.textScrollList(self.ar_item_scroll, e=True, sii=1) self.selected_ar_item_in_scroll() return
def ReplaceTarget(self): try: newSel = self.getList() selectItem = mc.pm.textScrollList(self.Targets, q=True, selectItem=True) pm.textScrollList(self.Targets, edit=True, append=newSel) pm.textScrollList(self.Targets, edit=True, ri=selectItem) # list management pm.select(selectItem) rpl = pm.selected() tempList = [x for x in rpl] nb = len(tempList) for i in range(0, nb): self.TargetList.remove(tempList[i]) nb2 = len(newSel) for i in range(0, nb2): self.TargetList.append(newSel[i]) pm.select(None) except: pass
def AppleseedAOVButtonCommand(self, args=None): log.debug("AppleseedAOVButtonCommand " + str(args)) aovDict = self.rendererTabUiDict['aovs'] label = pm.button(aovDict['aovButton'], query=True, label=True) if "Add selected Shaders" in label: log.debug("AppleseedAOVButtonCommand: adding selected shaders") selectedItems = pm.textScrollList(aovDict['aovSourceField'], query=True, selectItem=True) for item in selectedItems: log.debug("Adding " + item) node = pm.createNode(item) indices = self.renderGlobalsNode.AOVs.getArrayIndices() index = 0 if len(indices) > 0: index = indices[-1] + 1 node.message >> self.renderGlobalsNode.AOVs[index] self.AppleseedAOVUpdateDestList() if "Remove selected Shaders" in label: log.debug("AppleseedAOVButtonCommand: removing selected shaders") selectedItems = pm.textScrollList(aovDict['aovDestField'], query=True, selectItem=True) for item in selectedItems: shaderName = item.split(" ")[0] log.debug("Removing " + shaderName) shader = pm.PyNode(shaderName) attribute = shader.message.outputs(p=True)[0] pm.delete(shader) attribute.remove() self.AppleseedAOVUpdateDestList()
def deleteShotSculptFrame(): if editState == True: editSculptFrame() ssn = pm.optionMenu("selectedSSNode_menu", q=True, v=True) bshps = pm.getAttr(ssn + '.bshps') frame = pm.textScrollList("SculptLayers_tsl", q=True, si=True) result = pm.confirmDialog(title='Delete Sculpt-Frame', message='Are you sure you want to delete ' + frame[0] + "?", button=['Yes', 'No'], defaultButton='Yes', cancelButton='No', dismissString='No') if result == 'Yes': pm.deleteAttr(ssn + '.' + frame[0]) pm.textScrollList("SculptLayers_tsl", e=True, ri=str(frame[0])) for bshp in bshps: ##mel command: blendShapeDeleteTargetGroup + bshp + index index = getIndexByName(bshp, frame[0]) #remove the alias pm.aliasAttr(bshp + '.' + frame[0], remove=True) ##delete the target pm.removeMultiInstance(bshp + '.weight[' + str(index) + ']', b=True)
def __init__(self): ''' # class to sort and give info on shaders ''' self.layout = pm.rowColumnLayout(numberOfColumns= 3, columnWidth=([1, 150], [2, 150], [3, 250])) pm.columnLayout() pm.text(label= 'Shaders') self.shader_list = pm.textScrollList(width= 150, height= 200, selectCommand= pm.Callback(self.update_connections_list)) pm.button(label= 'Refresh', width= 150, command= pm.Callback(self.update_shader_list)) pm.setParent(self.layout) pm.columnLayout() pm.text(label='Connections') self.connections_list = pm.textScrollList(width= 150, height= 200, selectCommand= pm.Callback(self.write_info)) self.check_box = pm.checkBox(label= 'Select Node') pm.setParent(self.layout) pm.columnLayout() pm.text(label='Node Info') self.info_field = pm.scrollField(wordWrap= True, width= 250, height= 200) self.attr_check_box = pm.checkBox(label= 'Show All') self.update_shader_list()
def FindSourcesMainSource(self): geo = pm.selected() sourceNodes0 = [] for i, each in enumerate(pm.selected()): constraints = list( set([ x for x in each.inputs() if type(x) == pm.nodetypes.ParentConstraint or type(x) == pm.nodetypes.ScaleConstraint ])) if constraints: for constraint in constraints: sourceNodes0.extend([ sourceNode for sourceNode in pm.listConnections( constraint + '.target[0].targetParentMatrix', s=1) if (pm.objExists(sourceNode) and sourceNode not in sourceNodes0) ]) if sourceNodes0: for each in sourceNodes0: pm.select(None) pm.select(sourceNodes0, add=True) pm.select(geo, d=True) print("The main Sources is : " + each) else: pm.textScrollList(self.outputWin, edit=True, append=['Result: There is NO Sources ']) print("// Result: //") print('// Result: There is NO Sources //')
def read_py(self, *arg): if self.py_path and os.path.isfile(self.py_path): self.spp_.parse(self.py_path) self.update_ui() else: pmc.textScrollList(self.infos_ui, e=True, ra=True) pmc.textScrollList(self.infos_ui, e=True, a="//error: select a python file or no more exist...")
def FindSources(self): sourceNodes = [] for i, each in enumerate(pm.selected()): constraints = list( set([ x for x in each.inputs() if type(x) == pm.nodetypes.ParentConstraint or type(x) == pm.nodetypes.ScaleConstraint ])) if constraints: for constraint in constraints: sourceNodes.extend([ sourceNode for sourceNode in pm.listConnections( constraint + '.target[*].targetParentMatrix', s=1) if (pm.objExists(sourceNode) and sourceNode not in sourceNodes) ]) if sourceNodes: print(" The sources are : ") for i, each in enumerate(sourceNodes): pm.select(sourceNodes) print(" " + each, i) else: pm.textScrollList(self.outputWin, edit=True, append=['Result: There is NO Sources']) print("// Result: //") print('// Result: There is NO Sources //')
def GetSubject(self): self.targetNodes = [] constraints = pm.ls(type="constraint") pm.select(None) if constraints: for constraint in constraints: self.targetNodes.extend([ targetNode for targetNode in pm.listConnections( constraint + '.constraintParentInverseMatrix', d=1) if (pm.objExists(targetNode) and targetNode not in self.targetNodes) and len( pm.listConnections(constraint + '.target[*].targetParentMatrix', d=1)) > 1 ]) if self.targetNodes: pm.select(self.targetNodes) else: pm.select(None) pm.textScrollList( self.outputWin, edit=True, append=['Result:NO Double Constraints, THE SCENE IS CLEAN']) print("// Result: //") print("// Result:NO Double Constraints, THE SCENE IS CLEAN //")
def __init__(self): self.parti_nodes = [] self.scene_lights = [] self.parti_lights = [] self.parti_dict = {} self.parti_lights_dict = {} self.scene_lights_dict = {} pm.columnLayout(adjustableColumn= True) main = pm.rowColumnLayout(numberOfColumns= 3, columnWidth= ([1,180], [2, 180], [3,180])) pm.columnLayout(adjustableColumn= True) pm.text(label= 'Parti Volumes') self.parti_scroll = pm.textScrollList(width= 180, height= 125, selectCommand = pm.Callback(self.get_input_lights)) pm.button(label= 'Refresh', command= pm.Callback(self.refresh_nodes)) pm.setParent('..') pm.columnLayout(adjustableColumn= True) pm.text(label= 'Parti Lights') self.parti_light_scroll = pm.textScrollList(width= 180, height= 125) pm.rowColumnLayout(numberOfColumns= 2, columnWidth= ([1, 90], [2, 90])) pm.button(label= '+', command= pm.Callback(self.add_light)) pm.button(label= '-', command= pm.Callback(self.remove_light)) pm.setParent(main) pm.columnLayout(adjustableColumn= True) pm.text(label= 'Scene Lights') self.light_scroll = pm.textScrollList(width= 180, height= 125) pm.button(label= 'Refresh', command= pm.Callback(self.refresh_lights)) self.refresh_lights() self.refresh_nodes()
def _addClicked(self, *args): result = _pmCore.promptDialog(title='New Category', message="Enter Name: ", button=['OK', 'Cancel'], defaultButton='OK', cancelButton='Cancel', dismissString='Cancel') if result == 'OK': newCategory = _pmCore.promptDialog(query=True, text=True) _Database.addCategory(newCategory) _pmCore.textScrollList(self._textScrollList, edit=True, append=newCategory) self._updateCallback(newCategory)
def refresh_src_blend_shape_list(self): pm.textScrollList('blendShapeTargetList', edit=True, removeAll=True) src_blend_shape = self.get_src_blend_shape_name() if src_blend_shape is None: return if src_blend_shape == 'No Blend Shape Selected': return # The blend shape array is sparse, so keep a mapping from list indices to blend # shape weight indices. Note that for some reason, these are 1-based. self.src_blend_shape_map = {} # Add the blend shape targets in the source blend shape to the list. src_blend_shape = pm.ls(src_blend_shape)[0] weight_idx_list = src_blend_shape.weightIndexList() src_weights = src_blend_shape.attr('weight') for weight_idx in weight_idx_list: weight = src_weights.elementByLogicalIndex(weight_idx) target_name = pm.aliasAttr(weight, q=True) pm.textScrollList('blendShapeTargetList', edit=True, append=target_name) idx = pm.textScrollList('blendShapeTargetList', q=True, numberOfItems=True) self.src_blend_shape_map[idx] = weight
def _build_axis_info_frame(parent_layout): # Axis Info pm.frameLayout( label="Axis Info", # height=215, collapsable=True) pm.columnLayout(adj=True, columnAttach=('both', 5)) pm.textScrollList('tsl_externalAxes', allowMultiSelection=False, height=185, selectCommand=mimic_external_axes.axis_selected) pm.gridLayout(nc=2, cw=109, ch=25) pm.button(label='List Axes', annotation='Lists all external axes on selected robot', command=mimic_external_axes.list_axes) pm.button(label='Clear List', annotation='Clears list above', command=mimic_external_axes.clear_external_axis_list) pm.setParent('..') pm.button(label='Deselect', annotation='Deselects all axes in list above', command=mimic_external_axes.deselect_external_axis) pm.separator(height=10, style='out') pm.button(label='Remove Axis', annotation='Removes selected axis from robot', command=mimic_external_axes.remove_external_axis) pm.setParent(parent_layout)
def __init__(self, template): self.template = template self.win = "arnold_filter_list_win" if pm.window(self.win, exists=True): pm.deleteUI(self.win) pm.window(self.win, title="Add Light Filter", sizeable=False, resizeToFitChildren=True) #pm.windowPref(removeAll=True) pm.columnLayout(adjustableColumn=True, columnOffset=("both", 10), #columnAttach=('both',1), rowSpacing=10) self.scrollList = pm.textScrollList('alf_filter_list', nr=4, ams=False) pm.textScrollList(self.scrollList, e=True, doubleClickCommand=Callback(self.addFilterAndHide)) for label, nodeType in self.filters(): pm.textScrollList(self.scrollList, edit=True, append=label) pm.rowLayout(numberOfColumns=2, columnAlign2=("center", "center")) pm.button(width=100, label="Add", command=Callback(self.addFilterAndHide)) pm.button(width=100, label="Cancel", command=Callback(pm.deleteUI, self.win, window=True)) pm.setParent('..') pm.setParent('..') pm.showWindow(self.win)
def remove_io(*args): """ Removes IO from the robot it's attached to by deleting all of its attributes. The io controller and models are preserved. This function just breaks the connection between the robot and the io controller :param args: required by Maya to call a function from UI button required by Maya UI :return: """ # Get the selected item from the Mimic UI selection = pm.textScrollList('tsl_ios', selectItem=True, query=True)[0] # Split the selection into the robot's name and the IO name robot_str, io_name = selection.split(': ') pm.select(robot_str) robot = mimic_utils.get_robot_roots()[0] target_CTRL = mimic_utils.get_target_ctrl_path(robot) parent_attribute = '{}.io_{}'.format(target_CTRL, io_name) # Delete IO attribute on the robot controller pm.deleteAttr(parent_attribute) # Clear the io from the Mimic UI selection and reset the UI pm.textScrollList('tsl_ios', edit=True, removeItem=selection) if not pm.textScrollList('tsl_ios', query=True, numberOfItems=True): reset_io_UI() pm.select(target_CTRL) pm.headsUpMessage('IO \'{}\' removed successfully from {}'.format( io_name, robot))
def buildUI(self): pm.setUITemplate("attributeEditorTemplate", pushTemplate=True) with pm.frameLayout(label="Components", collapsable=False): with pm.columnLayout(adj=True): self.scrollList = pm.textScrollList(doubleClickCommand=self.componentClicked) pm.textScrollList(self.scrollList, edit=True, append=self.getComponentList()) pm.setUITemplate("attributeEditorTemplate", popTemplate=True)
def replace_item_in_list(self, index, item_name): pm.textScrollList( self.influence_list_text_scroll_list, e=True, rii=index ) pm.textScrollList( self.influence_list_text_scroll_list, e=True, ap=[index, item_name] )
def update_list(self): # clear the list pm.textScrollList(self.influence_list_text_scroll_list, e=1, ra=1) # remove joints from selection list sel_joints = pm.ls(sl=1, type="joint") pm.select(sel_joints, d=1) # get the vertex list without joints sel_list = pm.ls(sl=1) new_list = self.convert_to_vertex_list(sel_list) sel_list = new_list skin_cluster = self.get_skin_cluster_from_interface() # get joint names that influence currently selected vertices joints = self.get_joints_affecting_components(sel_list, skin_cluster) # and add the new joint names to the list # add the hold status to the name of the joint for joint in joints: display_string = joint.name() if joint.liw.get(): display_string = "%s (h)" % display_string pm.textScrollList( self.influence_list_text_scroll_list, e=1, append=display_string )
def shuffleSlice(self,*args): getSel = pm.ls(sl=1,fl=1) cols = pm.intSliderGrp("colsSlider",q=1,v=1) if len(getSel)>=1 and len(getSel)>=cols: array = getSel self.result = randomSplitList().randListFunc(array,cols) if pm.radioButtonGrp("radioBtnGrp",q=1,sl=1) == 1: pm.text("warningText",e=1,l="---===List All Parts===---") pm.textScrollList("listScroll",e=1,ra=1) for i in range(0,len(self.result)): pm.textScrollList("listScroll",e=1,append="{0}{1}".format("ShuffledPart_",(i+1))) elif pm.radioButtonGrp("radioBtnGrp",q=1,sl=1) == 2: pm.textScrollList("listScroll",e=1,ra=1) allGrps=[] for i in range(0,len(self.result)): grp = pm.group(n=("{0}{1}".format("ShuffledPart_",(i+1))),em=1) pm.parent(self.result[i],grp) allGrps.append(grp) pm.select(allGrps,r=1) elif len(getSel)==0: pm.textScrollList("listScroll",e=1,ra=1) pm.text("warningText",e=1,l="---===Select Something!!!===---") elif len(getSel)>0 and len(getSel)<cols: pm.textScrollList("listScroll",e=1,ra=1) pm.text("warningText",e=1,l="---===Too Much Parts!!!===---")
def set_joint_weight(self, value): selected_index = self.get_selected_index() joint_name = self.get_selected_item_in_list() temp3 = pm.ls(sl=1, type="joint") pm.select(temp3, d=1) sel_list = pm.ls(sl=1) pm.select(temp3, add=1) skin_cluster = self.get_skin_cluster(sel_list[0]) if not skin_cluster: # try to get it from the interface skin_cluster = self.get_skin_cluster_from_interface() if value: temp3 = pm.ls(sl=1, type="joint") joint_name = temp3[0] print("skin_cluster: %s" % skin_cluster) print("sel_list : %s" % sel_list) print("join_name : %s" % joint_name) print("value : %s" % value) pm.skinPercent(skin_cluster, sel_list, tv=[(joint_name, value)]) self.update_list() if value == 0: number_of_items = self.get_number_of_items() selected_index = selected_index if selected_index < number_of_items else number_of_items pm.textScrollList( self.influence_list_text_scroll_list, e=1, sii=selected_index )
def buildUI(self): pm.setUITemplate("attributeEditorTemplate", pushTemplate=True) self.passesParent = pm.setParent(query=True) frameLayout = None with pm.frameLayout(label="Passes", collapsable=False, parent=self.parent) as frameLayout: with pm.columnLayout(adj=True): with pm.rowLayout(adj=True, nc=2, cw=((1, 200), (2, 200)), h=350): with pm.frameLayout(label="Existing Passes", collapsable=False, h=350): self.availableAOVsListUI = pm.textScrollList( doubleClickCommand=self.AOVdoubleClicked) pm.textScrollList(self.availableAOVsListUI, edit=True, append=self.getAOVs()) with pm.frameLayout(label="Active Passes", collapsable=False, h=350): self.activeAOVsListUI = pm.textScrollList( selectCommand=self.exsistingAOVclicked, doubleClickCommand=self.exsistingAOVdoubleClicked) self.updateExistingAOVList() pm.setUITemplate("attributeEditorTemplate", popTemplate=True) pm.scriptJob(event=("NameChanged", self.nameChangedCallback), parent=frameLayout)
def getTargetShapes(self,*args): pm.textScrollList("targetShapeList",e=1,ra=1) self.bsNd = pm.textScrollList("blendshapeList",q=1,si=1) if len(self.bsNd) == 1: tgtShapes = pm.blendShape(self.bsNd[0],t=1,q=1) if len(tgtShapes)>0: listTarget = pm.textScrollList("targetShapeList",e=1,append=tgtShapes)
def deleteShotSculptNode(): global editState ssn = pm.optionMenu("selectedSSNode_menu", q=True, v=True) print ssn bshps = pm.getAttr(ssn + '.bshps') result = pm.confirmDialog(title='Delete Shot Sculpt Group', message='Are you sure you want to delete ' + ssn + "?", button=['Yes', 'No'], defaultButton='Yes', cancelButton='No', dismissString='No') if result == 'Yes': ##exit editmode if enabled if editState: editSculptFrame() pm.textScrollList("SculptLayers_tsl", e=True, ra=True) pm.delete(ssn, bshps) pm.deleteUI(str(ssn)) existing_ssns = pm.optionMenu('selectedSSNode_menu', q=True, ils=True) print existing_ssns if len(existing_ssns) < 1: pm.menuItem("-- None --", p="selectedSSNode_menu") else: loadShotSculptNode()
def OnWrapClick(ListA, ListB): MatchingType = getInputs('MatchingType') BaseList = pm.textScrollList(ListA, q=True, si=True) TargetList = pm.textScrollList(ListB, q=True, si=True) TotalList = [] MatchingTotal = [] for a in range(len(TargetList)): if MatchingType == 'Matching': # 1:1 Matching # print BaseList slBase = pm.ls(BaseList[a]) slTarget = pm.ls(TargetList[a]) temp = slBase + slTarget MatchingTotal.append(temp) else: # 1:n Matching slBase = pm.ls(BaseList[0]) slTarget = pm.ls(TargetList[a]) temp = slBase + slTarget TotalList.append(temp) if MatchingType == 'Matching': # 1:1 Matching if MatchingTotal == []: Error(MatchingTotal) return for a in MatchingTotal: WrapDeformer(a) else: # 1:n Matching if TotalList == []: Error(TotalList) return for a in TotalList: WrapDeformer(a) om.MGlobal.displayInfo("**<Wrap> has safely done!**")
def append_output_item(): # todo: bug fix - 属性应该是一对一,当前是一对多,后续版本应该强制验证 namespace = pm.textFieldGrp("namespaceField", q=True, text=True) source_controller = pm.textField("sourceObjectField", q=True, text=True) if namespace in source_controller: source_controller = source_controller.split(":")[1] key = "%s.%s" % (source_controller, pm.textScrollList( "sourceObjectAttrScrollList", q=True, si=True)[0]) target_controller = pm.textField("targetObjectField", q=True, text=True) if namespace in target_controller: target_controller = target_controller.split(":")[1] value = "%s.%s" % (target_controller, pm.textScrollList("targetObjectAttrScrollList", q=True, si=True)[0]) item = "%s:%s" % (key, value) print(item) current_items = pm.textScrollList("outputItemScrollList", q=True, ai=True) if item not in current_items: pm.textScrollList("outputItemScrollList", e=True, a=item) print("--------------")
def _build_io_info_frame(parent_layout): # IO Info pm.frameLayout( label="IO Info", # height=215, collapsable=True) pm.columnLayout(adj=True, columnAttach=('both', 5)) pm.textScrollList('tsl_ios', allowMultiSelection=False, height=198, selectCommand=mimic_io.io_selected) pm.gridLayout(nc=2, cw=109, ch=25) pm.button(label='List IOs', annotation='Lists all IOs on selected robot', command=mimic_io.list_ios) pm.button(label='Clear List', annotation='Clears list above', command=mimic_io.clear_io_list) pm.setParent('..') pm.button(label='Deselect', annotation='Deselects all axes in list above', command=mimic_io.deselect_io) pm.separator(height=10, style='out') pm.button(label='Remove IO', annotation='Removes selected axis from robot', command=mimic_io.remove_io) pm.setParent(parent_layout)
def remove_external_axis(*args): """ Removes external axis from the robot it's attached to by deleting all of its attributes. The axis controller and models are preserved. This function just breaks the connection between the robot and the axis :param *args: required by Maya UI :return: """ # Get the selected item from the Mimic UI selection = pm.textScrollList('tsl_externalAxes', selectItem=True, query=True)[0] # Split the selection into the robot's name and the external axis name robot, axis_name = selection.split(': ') target_CTRL = '{}|robot_GRP|target_CTRL'.format(robot) parent_attribute = '{}.externalAxis_{}'.format(target_CTRL, axis_name) # Remove connections between the axis controller and the robot external_axis_attribute_path = target_CTRL + '.' + axis_name external_axis_CTRL, driving_attribute = _get_external_axis_connections( external_axis_attribute_path) driving_axis = driving_attribute[-1] # Prep transformation string for Maya's limit attributes if 'translate' in driving_attribute: driving_attribute_trunc = 'Trans' else: driving_attribute_trunc = 'Rot' _enable_external_axis_limits(external_axis_CTRL, driving_attribute_trunc, driving_axis, enable=False) # Delete External Axis attribute on the robot controller pm.deleteAttr(parent_attribute) # Clear the axis from the Mimic UI selection and reset the UI pm.textScrollList('tsl_externalAxes', edit=True, removeItem=selection) if not pm.textScrollList('tsl_externalAxes', query=True, numberOfItems=True): reset_external_axis_UI() ''' # NEEDS Attention. This deletes parent constraint even if the axis # being removed isn't the one the robot is attached to if _check_if_robot_is_attached_to_external_axis(robot): pm.delete('{}|robot_GRP|local_CTRL|' \ 'localCTRL_externalAxisCTRL_parentConstraint' .format(robot)) pm.setAttr('{}|robot_GRP|local_CTRL.visibility'.format(robot), 1) ''' pm.headsUpMessage('External Axis \'{}\' removed successfully from {}' .format(axis_name, robot))
def initialiseLayout(self): #======================================================================= # Define Top Level Layout #======================================================================= self.widgets['top_level_layout'] = pm.verticalLayout() #======================================================================= # Define Layout #======================================================================= # Title Layout pm.setParent(self.widgets['top_level_layout']) self.widgets['title_layout'] = pm.horizontalLayout() pm.text('Multi Attributes') pm.text('Connection Index') pm.text('Connection Target') #List Layout pm.setParent(self.widgets['top_level_layout']) self.widgets['list_layout'] = pm.horizontalLayout() pm.setParent(self.widgets['list_layout']) self.widgets["attributes_list"] = pm.textScrollList(selectCommand=self.refresh_connections) pm.setParent(self.widgets['list_layout']) self.widgets["index_list"] = pm.textScrollList(ams=True) pm.setParent(self.widgets['list_layout']) self.widgets["connections_list"] = pm.textScrollList(enable=False) #refresh Button pm.setParent(self.widgets['top_level_layout']) self.widgets["refresh_button"] = pm.button(label="Load Selection", command=self.refresh) # Add Attribute pm.setParent(self.widgets['top_level_layout']) pm.separator() self.widgets['addAttr_layout'] = pm.horizontalLayout() pm.text('Add Attribute:') self.widgets['attr_name'] = pm.textField() self.widgets["add_button"] = pm.button(label="Add", c=self.addAttr_selected) # Misc Buttons pm.setParent(self.widgets['top_level_layout']) self.widgets['buttons_layout'] = pm.horizontalLayout() self.widgets["append_button"] = pm.button(label="Append", command=self.append_selected) self.widgets["remove_button"] = pm.button(label="Remove", command=self.remove_selected) self.widgets["clear_button"] = pm.button(label="Clear", command=self.clear_selected) #======================================================================= # Redistribute #======================================================================= self.widgets['addAttr_layout'].redistribute(1,2,1) self.widgets['list_layout'].redistribute() self.widgets['title_layout'].redistribute() self.widgets['buttons_layout'].redistribute() self.widgets['top_level_layout'].redistribute(1,10,1,1,1,1)
def deselect_external_axis(*args): """ Deselects item from external axis list in Mimic UI :param args: required by Maya to call a function from UI button :return: """ pm.textScrollList('tsl_externalAxes', edit=True, deselectAll=True) reset_external_axis_UI()
def deselect_external_axis(*args): """ Clear UI list selection :param args: :return: """ pm.textScrollList('tsl_externalAxes', edit=True, deselectAll=True) reset_external_axis_UI()
def AppleseedAOVSelectCommand(self, whichField): aovDict = self.rendererTabUiDict['aovs'] if whichField == "source": pm.button(aovDict['aovButton'], edit=True, enable=True, label="Add selected Shaders") pm.textScrollList(aovDict['aovDestField'], edit=True, deselectAll=True) if whichField == "dest": pm.button(aovDict['aovButton'], edit=True, enable=True, label="Remove selected Shaders") pm.textScrollList(aovDict['aovSourceField'], edit=True, deselectAll=True)
def refresh_allCam(self): self.allCam = pm.listCameras(o=False, p=True) pm.textScrollList(self.all_cams, edit=True, removeAll=True) pm.textScrollList( self.all_cams, edit=True, append=self.allCam, )
def remove_select_item(self): pm.textScrollList( self.task_scroll, e=True, ri=pm.textScrollList(self.task_scroll, q=True, si=True)) self.output_files = pm.textScrollList( self.task_scroll, q=True, ai=True) return
def clear_external_axis_list(*args): """ Clear previous UI list :param args: :return: """ pm.textScrollList('tsl_externalAxes', edit=True, removeAll=True) reset_external_axis_UI()
def deselect_io(*args): """ Deselects item from IO list in Mimic UI :param args: required by Maya to call a function from UI button :return: """ pm.textScrollList('tsl_ios', edit=True, deselectAll=True) reset_io_UI()
def clear_io_list(*args): """ Clears IO list in Mimic UI :param args: required by Maya to call a function from UI button :return: """ pm.textScrollList('tsl_ios', edit=True, removeAll=True) reset_io_UI()
def clear_external_axis_list(*args): """ Clears external axis list in Mimic UI :param args: required by Maya to call a function from UI button :return: """ pm.textScrollList('tsl_externalAxes', edit=True, removeAll=True) reset_external_axis_UI()
def spaddfile(arg): vail = ["png","tga","tif","jpg"] path = pm.textField('sptexpath',tx=1,q=1).replace("\\","/") if os.path.exists(path)==True: filelist = [i for i in pm.getFileList(fld=path) if i.split(".")[-1] in vail] pm.textScrollList("piclist",e=1,ra=1,a=filelist) else: print "路径错误!!",
def __init__(self): self.main_layout = pm.columnLayout(adjustableColumn= True) self.layout01 = pm.rowColumnLayout(numberOfColumns= 3, columnWidth=([1, 150],[2, 150], [3, 250])) pm.columnLayout() pm.text(label= 'Shaders') self.shader_scroll_list01 = pm.textScrollList(width= 150, height= 200, selectCommand= pm.Callback(self.get_output_geo)) pm.button(label= 'Refresh', width= 150, command= pm.Callback(self.update_shaders_list)) pm.setParent(self.layout01) pm.columnLayout() pm.text(label= 'Shader Geo') self.shader_geo_scroll_list = pm.textScrollList(width= 150, height= 200, allowMultiSelection= True) #self.check_box = pm.checkBox(label= 'select node') pm.setParent(self.layout01) pm.columnLayout() pm.text(label= 'Scene Geo') self.scene_geo_scroll_list = pm.textScrollList(width= 250, height= 200, allowMultiSelection= True) pm.button(label= 'Refresh', width= 275, command= pm.Callback(self.update_scene_geo_list)) pm.setParent(self.main_layout) self.layout02 = pm.rowColumnLayout(numberOfColumns= 2, columnWidth=([1, 275],[2, 275])) pm.columnLayout(adjustableColumn= True) pm.text(label= 'Shaders') self.shader_scroll_list02 = pm.textScrollList(width= 275, height= 200) pm.button(label= 'Assign', width= 275, command= pm.Callback(self.assign_to_geometry)) pm.setParent(self.layout02) pm.columnLayout(adjustableColumn= True) pm.text(label= 'Create Shaders') self.option_menu = pm.optionMenu( label='Material Type', width= 200) pm.menuItem( label='mia_material_x') pm.menuItem( label='blinn') pm.menuItem( label='lambert') pm.menuItem( label='phong') pm.menuItem( label='rampShader') pm.menuItem( label='anisotropic') pm.menuItem( label='phongE') pm.menuItem( label='useBackground') self.text_field = pm.textFieldGrp(label= 'Name', columnWidth2= [100, 150]) pm.button(label= 'Create and Assign Shader', command= pm.Callback(self.create_and_assign_shader)) self.update_scene_geo_list() self.update_shaders_list()
def createRig(self, *args): BlendSineRig.BlendSineRig( control=pm.textFieldButtonGrp(self.cnt_fld, q=1, text=1), name=pm.textFieldGrp(self.name_fld, q=1, text=1), numJnts=pm.textFieldGrp(self.numJnts_fld, q=1, text=1), curve=pm.textFieldButtonGrp(self.crv_fld, q=1, text=1), fwdBackCrvs=pm.textScrollList(self.fwd_sFld, q=1, ai=1), sideToSideCrvs=pm.textScrollList(self.side_sFld, q=1, ai=1), )
def order_by_ui(self, *args): self.order = pmc.checkBoxGrp(self.order_ui, q=True, v1=True) self.spp_.sort_objects(alphabetical=self.order, filter_str=pmc.textFieldGrp(self.filter_ui, q=True, text=True), filter_test=self.filter_test) pmc.textScrollList(self.infos_ui, e=True, ra=True) pmc.textScrollList(self.infos_ui, e=True, a=[o.repr_ for o in self.spp_.order_obj])
def groupPartsFunc(self,*args): allGrps=[] if len(pm.textScrollList("listScroll",q=1,ai=1))!=0: if len(self.result)==len(pm.textScrollList("listScroll",q=1,ai=1)): for i in range(0,len(self.result)): grp = pm.group(n=("{0}{1}".format("ShuffledPart_",(i+1))),em=1) pm.parent(self.result[i],grp) allGrps.append(grp) pm.select(allGrps,r=1)
def newShapeList(self,*args): getSel = pm.ls(sl=1,fl=1) listItems = pm.textScrollList("newShapeList",q=1,ai=1) if len(getSel)>=1: if len(listItems) == 0: pm.textScrollList("newShapeList",e=1,append=getSel) elif len(listItems) >= 1: for sel in getSel: if sel not in listItems: pm.textScrollList("newShapeList",e=1,append=sel)
def init_options_layout(self, *args): input_type = self.widgets["input_type"].getValue() if input_type == "Single Shape": control_type_list = ["Horizontal", "Vertical"] direction_list = ["Positive", "Negative"] shapes_list = ["Shape", None, None, None] if input_type == "Pair Shape": control_type_list = ["Rectangle", "Parallel"] direction_list = ["Positive", "Negative"] shapes_list = ["Shape Left", "Shape Right", None, None] if input_type == "Two Shapes": control_type_list = ["Horizontal", "Vertical"] direction_list = [] shapes_list = ["Pos Shape", "Neg Shape", None, None] if input_type == "Two Pair Shapes": control_type_list = ["Square", "Parallel"] direction_list = [] shapes_list = ["Shape Up Left", "Shape Up Right", "Shape Dn Left", "Shape Dn Right"] if input_type == "Four Shapes": control_type_list = ["Square"] direction_list = [] shapes_list = ["Shape North", "Shape East", "Shape South", "Shape West"] self.widgets["control_type"].removeAll() self.widgets["control_type"].append(control_type_list) pm.textScrollList(self.widgets["control_type"], e=True, selectIndexedItem=1) if direction_list: self.widgets["control_direction"].removeAll() self.widgets["control_direction"].append(direction_list) self.widgets["control_direction"].setEnable(True) else: self.widgets["control_direction"].removeAll() self.widgets["control_direction"].append("") self.widgets["control_direction"].setEnable(False) pm.textScrollList(self.widgets["control_direction"], e=True, selectIndexedItem=1) for i in range(1, 5): self.widgets["input_shape_%d" % i].setText("") self.widgets["input_shape_%d_text" % i].setLabel(shapes_list[i - 1]) if shapes_list[ i - 1 ] else self.widgets["input_shape_%d_text" % i].setLabel("") self.widgets["input_shape_%d" % i].setEnable(True) if shapes_list[i - 1] else self.widgets[ "input_shape_%d" % i ].setEnable(False) self.widgets["assign_input_shape_%d_button" % i].setEnable(True) if shapes_list[i - 1] else self.widgets[ "assign_input_shape_%d_button" % i ].setEnable(False)
def updateShape(self,*args): newShapes = pm.textScrollList("newShapeList",q=1,ai=1) curShapes = pm.textScrollList("curShapeList",q=1,ai=1) if len(newShapes) == len(curShapes) and len(curShapes)>0: for i,x in enumerate(curShapes): bsNd = pm.blendShape(newShapes[i],x) pm.setAttr(bsNd[0]+'.'+newShapes[i],1) pm.select(x,r=1) pm.delete(x,ch=1) pm.textScrollList("newShapeList",e=1,ri=newShapes[i]) pm.setAttr('{0}.visibility'.format(newShapes[i]),0) #pm.delete(newShapes[i])
def _deleteClicked(self, *args): current = _pmCore.textScrollList(self._textScrollList, query=True, selectItem=True) if not current: raise RuntimeError('Must select a category to delete.') current = current[0] if _Database.getAssetUnderCategory(current): raise RuntimeError('Can not delete category {0}, there are asset under this category.'.format(current)) _Database.deleteCategory(current) _pmCore.textScrollList(self._textScrollList, edit=True, removeItem=current) self._updateCallback(None, None, current)
def getBlendShapes(self,*args): getSel = pm.ls(sl=1,fl=1) if len(getSel) == 1: self.meshWithBS = getSel[0] bsNd = pm.ls(pm.listHistory(getSel[0]) or [],type='blendShape') itemInList = pm.textScrollList("blendshapeList",q=1,ai=1) if len(itemInList)>0: for x in bsNd: if x not in itemInList: listItems = pm.textScrollList("blendshapeList",e=1,append=x) else: listItems = pm.textScrollList("blendshapeList",e=1,append=bsNd)
def getCameras(self): allCameras = cmds.listCameras(perspective=True) selection = cmds.ls(sl=True) self.renderCameras = [i for i in allCameras if i in selection] for camera in allCameras: cmds.textScrollList( self.interface['Cameras'], edit=True, append=camera ) cmds.setAttr( getShapes(camera)[0] + '.renderable', 0) # cmds.menuItem( label=camera ) for camera in self.renderCameras: cmds.textScrollList( self.interface['Cameras'], edit=True, selectItem=camera) cmds.setAttr( getShapes(camera)[0] + '.renderable', 1)
def createRig(self, *args): BlendSineRig.BlendSineRig(control=pm.textFieldButtonGrp( self.cnt_fld, q=1, text=1), name=pm.textFieldGrp( self.name_fld, q=1, text=1), numJnts=pm.textFieldGrp( self.numJnts_fld, q=1, text=1), curve=pm.textFieldButtonGrp( self.crv_fld, q=1, text=1), fwdBackCrvs=pm.textScrollList( self.fwd_sFld, q=1, ai=1), sideToSideCrvs=pm.textScrollList( self.side_sFld, q=1, ai=1),)
def _buildupWindow(self): if isinstance(self._window, _pmCore.uitypes.Window) and self._window.exists(self._window.name()): _pmCore.deleteUI(self._window, window=True) self._window = _pmCore.window(title=self._winTitle) _pmCore.rowLayout(numberOfColumns=2, columnWidth2=[200, 100]) self._textScrollList = _pmCore.textScrollList(height=100) for category in _Database.getCategoryList(): _pmCore.textScrollList(self._textScrollList, edit=True, append=category) _pmCore.columnLayout() _pmCore.button(label='Add', width=100, height=30, command=self._addClicked) _pmCore.button(label='Rename', width=100, height=30, command=self._renameClicked) _pmCore.button(label='Delete', width=100, height=30, command=self._deleteClicked)
def AOVdoubleClicked(self): item = pm.textScrollList(self.availableAOVsListUI, query=True, selectItem=True)[0] passesNode = pm.createNode("coronaPassesNode", n=item) passesNode.passType.set(pm.textScrollList(self.availableAOVsListUI, query=True, sii=True)[0] - 1) ne = pm.PyNode("coronaGlobals").AOVs.numElements() if ne > 0: index = pm.PyNode("coronaGlobals").AOVs.elementByPhysicalIndex(ne - 1).logicalIndex() for i in range(index + 2): if not pm.PyNode("coronaGlobals").AOVs[i].isConnected(): passesNode.message >> pm.PyNode("coronaGlobals").AOVs[i] break else: passesNode.message >> pm.PyNode("coronaGlobals").AOVs[0] self.addAOVAttributes(passesNode) self.updateExistingAOVList()
def removeAOVs(self, *args): ''' delete the selected AOVs ''' sel = pm.textScrollList(self.activeLst, query=True, selectItem=True) if sel: global _updating _updating = True try: self.renderOptions.removeAOVs(sel) for aov in sel: pm.textScrollList(self.availableLst, edit=True, append=aov) pm.textScrollList(self.activeLst, edit=True, removeItem=aov) finally: _updating = False self.updateActiveAOVs()
def create(self): self.main_layout = pm.columnLayout(adjustableColumn= True, width= 400) main_frame = pm.frameLayout( label='%s' % (self.obj), collapsable= True) pm.columnLayout(adjustableColumn= False, width= 400) self.mapping_menu = pm.optionMenu( label='Mapping', width= 150, changeCommand= pm.Callback(self.mapping_type, self.obj)) pm.menuItem( label='Spherical') pm.menuItem( label='Angular') pm.setParent(main_frame) self.type_menu = pm.optionMenu( label='Type', width= 150, changeCommand= pm.Callback(self.file_type, self.obj)) pm.menuItem( label='Image File') pm.menuItem( label='Texture') self.image_field = pm.textFieldButtonGrp(label= 'Image Name', editable= False, columnWidth3= [100,200,100], buttonLabel= '<<<', buttonCommand= pm.Callback(self.load_image, self.obj)) self.list_field = pm.textScrollList(allowMultiSelection= False , width= 100, height= 100) pm.attrColorSliderGrp( at='%s.color' % (self.obj), columnWidth4= [100, 75, 175, 50]) pm.rowColumnLayout(numberOfColumns= 2, columnWidth= ([1, 200], [2, 200])) pm.button(label= 'List Ramps', command= pm.Callback(self.list_textures)) pm.button(label= 'Link Ramps', command= pm.Callback(self.link_texture, self.obj)) pm.button(label= 'Edit Ramps', command= pm.Callback(self.edit_ramp)) pm.button(label= 'Create Ramps', command= pm.Callback(self.create_ramp))
def gui(): ''' # gui for the script ''' win = 'rigid_body_win' if pm.window(win, exists= True): pm.deleteUI(win) if pm.windowPref(win, exists= True): pm.windowPref(win, remove= True) global obj_scroll_list, name_field, tab_layout my_win = pm.window(win, title= 'BAKE', toolbox= True, width= 300) tab_layout = pm.tabLayout() ui_creator = pm.columnLayout(adjustableColumn= False) name_field = pm.textFieldGrp(label = 'System Name', text= 'Name', columnWidth2= [145, 150]) obj_scroll_list = pm.textScrollList(width= 300, height= 200, allowMultiSelection= True) pm.rowColumnLayout(nc=3, columnWidth= ([1,100], [2,100], [1,100])) pm.button(label= 'Load', command= pm.Callback(load_objects), width= 100) pm.button(label= '+', command= pm.Callback(add_objects), width= 100) pm.button(label= '-', command= pm.Callback(remove_objects), width= 100) pm.setParent('..') pm.button(label= 'Create Baking System', height= 50, width= 300, command= pm.Callback(create_baking_system)) pm.tabLayout( tab_layout, edit=True, tabLabel=((ui_creator, 'Setup'))) my_win.show()
def removeAttrAndHide(self): #pm.window(self.win, edit=True, visible=False) attrLabels = pm.textScrollList(self.scrollList, q=True, si=True) if attrLabels: self.template.removeAttr([self._attributes[x] for x in attrLabels]) self.handleAttributes('remove') self.filterAttributes()
def doc_cmd_ui(self, *arg): if self.show_doc: si = pmc.textScrollList(self.infos_ui, q=True, sii=1) if si: obj = self.spp_.order_obj[si[0] - 1] if obj.doc is not None: print "%sDoc of : %s\n%s%s\n%s\n" % (self.line, obj.name, self.line, obj.doc, self.line)
def test_selectItemEmptyList(self): with ui.Window(self.win): with pm.formLayout(): tsl = pm.textScrollList() tsl.extend(['a','b','c']) # Make sure this is NOT None self.assertEqual(tsl.getSelectItem(), [])
def DeleteSelectedModule(self, *args): selectedModule = pm.textScrollList(self.UIElements["animationModule_textScroll"], query = True, selectItem = True)[0] selectedModuleNamespace = "%s:%s" %(self.selectedBlueprintModule, selectedModule) moduleNameInfo = utils.FindAllModuleNames("/Modules/Animation") modules = moduleNameInfo[0] moduleNames = moduleNameInfo[1] selectedModuleName = selectedModule.rpartition("_")[0] if selectedModuleName in moduleNames: moduleIndex = moduleNames.index(selectedModuleName) module = modules[moduleIndex] mod = __import__("Animation.%s" %module, (), (), [module]) reload(mod) moduleClass = getattr(mod, mod.CLASS_NAME) moduleInst = moduleClass(selectedModuleNamespace) moduleInst.Uninstall() self.RefreshAnimationModuleList()