def editCmd(self): """""" self.influence = sel = self.__selectInfluence() if cmds.objectType(self.influence, isType='joint'): self._type = 'joint' deformers = cmds.listConnections('%s.wm' % self.influence, d=1, s=0, t='skinCluster', et=1) elif cmds.listRelatives(self.influence, s=1, typ='clusterHandle'): self._type = 'cluster' deformers = cmds.listConnections('%s.wm' % self.influence, d=1, s=0, t='cluster', et=1) else: cmds.error("%s is unsupported type!" % self.influence) try: infObjs = cmds.listConnections('%s.og' % deformers[0]) cmds.select(infObjs) except TypeError: cmds.error("Can't find geometry deformed by %s" % self.influence) # Get into component select mode cmds.selectMode(object=True) cmds.selectMode(component=True) self.toggleButton()
def bGFAll(self, *args): allGeo = [] cmds.selectMode(q=True, co=True) for i in range(1, 4): cmds.polySelectConstraint(m=3, t=0x0008, sz=i) cmds.polySelectConstraint(dis=True) bGFPolys = cmds.polyEvaluate(fc=True) allGeo.append(bGFPolys) print allGeo try: cmds.textField(self.bGF_results, e=True, tx=("%s Triangle(s)" % int(allGeo[0]) + '\n' + "%s Quad(s)" % int(allGeo[1]) + '\n' + "%s N-Gons(s)" % int(allGeo[2]))) except: cmds.textField(self.bGF_results, e=True, tx=("Nothing is selected."))
def getTris(q=False): ''' Selects Triangles in Selection Args: q(boolean): if true function returns the selection. Return: result(list): the triangles in the selection ''' cmds.selectMode(co=True) cmds.selectType(smp=False, sme=True, smf=False, smu=False, pv=False, pe=True, pf=False, puv=False) cmds.polySelectConstraint(mode=3, t=0x0008, size=1) cmds.polySelectConstraint(disable=True) nPolys = cmds.polyEvaluate(faceComponent=True) print >> sys.stderr, str(nPolys) + ' Triangles(s) Selected.', if q: result = cmds.ls(sl=True, fl=True) return result
def transfertSelection(): """ Transfers a component selection to another object. :return: Definition succes. :rtype: bool """ selection = cmds.ls(sl=True, long=True) targetObject = "" for item in selection: if "." not in item: targetObject = item break if targetObject != "": cmds.hilite(targetObject, replace=True) cmds.selectMode(component=True) nextSelection = [] for item in selection: if item != targetObject: if "." in item: itemTokens = item.split(".") nextSelection.append(targetObject + "." + itemTokens[1]) nextSelection and cmds.select(nextSelection) return True
def getSelected(self): #check to make sure a mesh is selected msh = cmds.ls(sl=1, o=1, type='mesh') if msh: skin = self.findRelatedSkinCluster(msh[0]) if not skin: cmds.warning('Cannot find a skinCluster related to [' + msh + ']') return False self.currentSkin = skin self.currentMesh = msh[0] cmds.selectMode(component=1) sel = cmds.ls(sl=1, flatten = 1) if sel: msh = msh[0] vtx = None if sel != msh: if sel: vtx = len(sel) else: vtx = 0 self.currentVerts = sel return sel, msh, vtx, skin else: print('Please select a mesh.') return False
def displacePointsInsideMesh(plane, mesh, height, sse, ssd): """ Select vertices of plane that are inside mesh and displace those vertices (with amount height) :param plane: object to displace :param mesh: shape for select vertices to displace :param height: height of displacement :param sse: enable soft selection 0 False 1 True :param ssd: soft select distance :return: None """ cmd.selectMode(component=True) cmd.softSelect(sse=sse, ssd=ssd) vtxNumber = len(cmd.getAttr(plane+'.vtx[:]')) for i in range(0, vtxNumber): v = plane+'.vtx[%d]' % i cmd.select(v, r=True) vPosition = cmd.xform(v, query=True, translation=True, worldSpace=True) if test_if_inside_mesh(mesh, vPosition): cmd.move(height, y=True, r=True) cmd.softSelect(sse=0) cmd.selectMode(o=True)
def build(self, *a, **kw): if mc.draggerContext(self.name, query=True, exists=True): # if it exists, delete it mc.setToolTo('selectSuperContext') mc.selectMode(object=True) mc.deleteUI(self.name) imageFilePath = ('cgmDefault.png') mc.draggerContext(self.name, image1=imageFilePath, undoMode=self.undoMode, projection=self.projection, space=self.space, initialize=self.initialPress, pressCommand=self.press, releaseCommand=self.release, finalize=self.finalize, *a, **kw) if self.projection == 'plane': mc.draggerContext(self.name, e=True, plane=self.plane ) # if our projection is 'plane', set the plane if self.dragOption: mc.draggerContext( self.name, e=True, dragCommand=self.drag) # If drag mode, turn it on
def set_mask(*masks): """Set selection masks in maya. if the current mask is the given mask toggle object component mode. This is the default mode maya uses when switching selection masks. You will be able to continue selecting components but also select other objects as maya objects. Usage: set_mask('vertex', 'controlVertex', 'latticePoint') set_mask('meshComponents') """ component_masks = {mask: True for mask in masks} if (cmds.selectMode(q=True, component=True) and any(cmds.selectType(q=True, **{mask: True}) for mask in component_masks.iterkeys())): cmds.selectMode(object=True) cmds.selectType(ocm=True, alc=False) cmds.selectType(ocm=True, **component_masks) cmds.selectType(**component_masks) cmds.hilite(mampy.daglist().cmdslist()) else: cmds.selectMode(component=True) cmds.selectType(allComponents=False) cmds.selectType(**component_masks)
def CL_Displace_noShape(height, sse=0, ssd=0): curves = cmd.ls(type='nurbsCurve') checkClosed(curves) checkPlanar(curves) checkIntersection(curves) sel = cmd.ls(sl=True) if len(sel) == 0: raise Exception("Selezionare il piano!") print '--------- Selection is: ' + sel[0] + ' ---------' cmd.selectMode(component=True) cmd.softSelect(sse=sse, ssd=ssd) count = 1 for c in curves: vtxNumber = len(cmd.getAttr(sel[0]+'.vtx[:]')) for i in range(0, vtxNumber): v = sel[0]+'.vtx[%d]' % i vPosition = cmd.xform(v, query=True, translation=True, worldSpace=True) if testIfInsideCurve(vPosition, c, (1, 0, 0)): cmd.move(height, v, y=True, r=True) print "Terminato displacement livello " + str(count) count += 1 cmd.softSelect(sse=0) cmd.selectMode(o=True) cmd.polyTriangulate(sel[0])
def exit_tool_and_mask(): """Exit current tool or toggle selection mode. When working with other contexts in maya use this function to exit the current context and return to selection context; if you are using base tools ('select', move, rotate, scale) toggle selection mode instead. Usage: tool_select() """ # base_tools = ['{}SuperContext'.format(i) for i in ('select', 'move', 'rotate', 'scale')] if not cmds.currentCtx() == 'selectSuperContext': cmds.setToolTo('selectSuperContext') else: if cmds.selectMode(q=True, object=True): hilited = mampy.daglist(hl=True) if hilited: cmds.hilite(hilited.cmdslist(), toggle=True) cmds.select(hilited.cmdslist()) else: cmds.selectMode(component=True) else: cmds.selectMode(object=True)
def transfertSelection(): """ This definition transfers a component selection to another object. :return: Definition succes. ( Boolean ) """ selection = cmds.ls(sl=True, long=True) targetObject = str() for item in selection: if "." not in item: targetObject = item break if targetObject != "": cmds.hilite(targetObject, replace=True) cmds.selectMode(component=True) nextSelection = [] for item in selection: if item != targetObject: if "." in item: itemTokens = item.split(".") nextSelection.append(targetObject + "." + itemTokens[1]) nextSelection and cmds.select(nextSelection) return True
def getSelected(self): #check to make sure a mesh is selected msh = cmds.ls(sl=1, o=1, type='mesh') if msh: skin = self.findRelatedSkinCluster(msh[0]) if not skin: cmds.warning('Cannot find a skinCluster related to [' + msh + ']') return False self.currentSkin = skin self.currentMesh = msh[0] cmds.selectMode(component=1) sel = cmds.ls(sl=1, flatten=1) if sel: msh = msh[0] vtx = None if sel != msh: if sel: vtx = len(sel) else: vtx = 0 self.currentVerts = sel return sel, msh, vtx, skin else: print('Please select a mesh.') return False
def rotCtrlShapeX (_isPositive): sel = cmds.ls(selection = True) for controlName in sel: #clear the selection cmds.select(clear = True) #error catching, in case something other than a #curve or circle is selected cmds.selectMode(component = True) try: #selects the cvs in a nurbs curve or circle cmds.select(controlName+".cv[0:"+ str(getCVs(controlName)-1) + "]") except: #prints the reason for the failure print "Button not Activated: Control to Scale Must be a Curve or Circle" #does the rotation if (_isPositive == True): cmds.rotate(90,0,0, os = True, r = True) else: cmds.rotate(-90,0,0, os = True, r = True) #select all of the controls that were originally selected cmds.selectMode(object = True) cmds.select(sel)
def create(self,*args,**kwargs ): # Delete if it exists if cmds.draggerContext(self.name,query=True,exists=True): cmds.setToolTo('selectSuperContext') cmds.selectMode(object=True) cmds.deleteUI(self.name) cmds.draggerContext( self.name, image1 = self.IMAGE, undoMode = self.undoMode, projection = self.projection, space = self.space, initialize = self._initialize, pressCommand = self._press, releaseCommand = self._release, finalize = self._finalize, cursor=self.cursor, drawString="Test", *args,**kwargs ) if self.projection == 'plane': cmds.draggerContext(self.name,e=True, plane=self.plane) if self.enable_drag: cmds.draggerContext(self.name,e=True, dragCommand=self._drag) self.set_tool()
def part_transfer(self): self.init_bake_data()#辞書初期化 #print('part_transfer :', self.transfer_comp) temp_node_dict = {} temp_nodes = [] for node in self.hl_nodes: #スキンクラスタがないとき用に元のメッシュにバインド情報だけ移す weight.transfer_weight(self.marged_mesh, node, transferWeight=False) self.adust_skin_influences(node)#インフルエンスを合わせる #ダミーに転写する temp_node = cmds.duplicate(node, rc=True) temp_node = cmds.ls(temp_node, l=True)[0] weight.transfer_weight(self.marged_mesh, temp_node) temp_node_dict[node] = temp_node temp_nodes.append(temp_node) #ダミーと元のウェイトを全取得 cmds.selectMode(o=True) #cmds.select(cl=True) cmds.select(self.hl_nodes, temp_nodes) self.store_weight_data() for node in self.hl_nodes: vtxArray = self.node_vtxArray_dict[node] #print('node vtx array :', node , vtxArray) temp_node = temp_node_dict[node] org_infs = self.influences_dict[node] temp_infs = self.influences_dict[temp_node] #inf_id_list = range(len(org_weights_list[0])) #inf_id_list = [temp_infs.index(inf) for inf in org_infs] #インフルエンスの並び順がずれていることがあるので名前でソートする inf_id_list = [org_infs.index(inf) for inf in temp_infs] # print('adust weight data ;', node, vtxArray) # print('org_infs :', org_infs) # print('temp_infs :', temp_infs) # print('new_inf_list', inf_id_list) #ウェイトを整理する org_weights_list = self.node_weight_dict[node] trans_weights_list = self.node_weight_dict[temp_node] #print('get org weight :', org_weights_list) #print('get trans weight :', trans_weights_list) new_weights = [] org_weights = [] for id in vtxArray: new_weights += trans_weights_list[id] org_weights += org_weights_list[id] #print('bake inf ids :', inf_id_list) #ノードごとのMArray群辞書にキャスト self.bake_node_id_dict[node] += vtxArray self.bake_node_weight_dict[node] += new_weights self.bake_node_inf_dict[node] += inf_id_list self.org_node_weight_dict[node] += org_weights self.undo_node_weight_dict[node] = [org_weights_list[id] for id in vtxArray] self.redo_node_weight_dict[node] = [trans_weights_list[id] for id in vtxArray] self.om_bake_skin_weight() cmds.delete(temp_nodes)
def restore_context_and_axis(): global current_mode global pre_mode current_mode = cmds.selectMode(q=True, o=True) current_tool = cmds.currentCtx() target_tool_list = [ 'scaleSuperContext', 'RotateSuperContext', 'moveSuperContext', 'selectSuperContext' ] #選択オブジェクトが切り替わったときだけ切り替え実行 if cmds.selectMode(q=True, co=True): if cmds.ls(sl=True, type='transform'): #複合選択モードの時は逃げる print 'multi selection mode return :' return if cmds.ls(sl=True, set=True): #複合選択モードの時は逃げる print 'multi selection mode return :' return if 'pre_sel_comp' in globals(): current_selection = cmds.ls(sl=True) if pre_sel_comp != current_selection: if current_tool in target_tool_list: if not cmds.ls(sl=True): if pre_sel_comp: #print 'newsel' try: cmds.select(pre_sel_comp[0]) except: pass if cmds.ls(sl=True): sb.window.select_xyz_from_manip( ) #事前に選択したハンドル方向をなるべくキープする if current_selection != cmds.ls(sl=True): cmds.select(current_selection, r=True) global pre_sel_comp pre_sel_comp = cmds.ls(sl=True) #Flatにすると比較が無駄に重くなるので注意 if cmds.selectMode(q=True, o=True): if 'pre_sel_obj' in globals(): current_selection = cmds.ls(sl=True, o=True) if pre_sel_obj != current_selection: if current_tool in target_tool_list: #print 'ajust context' if not cmds.ls(sl=True): if cmds.ls(hl=True): #ラティスポイントとかの時は逃げる return if pre_sel_obj: #print 'newsel' try: cmds.select(pre_sel_obj[0]) except: pass if cmds.ls(sl=True): sb.window.select_xyz_from_manip( ) #事前に選択したハンドル方向をなるべくキープする if current_selection != cmds.ls(sl=True): cmds.select(current_selection, r=True) cmds.setToolTo('selectSuperContext') cmds.setToolTo(current_tool) global pre_sel_obj pre_sel_obj = cmds.ls(sl=True, o=True) pre_mode = current_mode
def getFacesInFrustum(container,obj): obj = 'pHelix131' container = 'frust_camera_frustum_geo' # select faces in container(frustum) allVtx = cmds.ls('{0}.vtx[:]'.format(obj),fl=True) allIn = [] for vtx in allVtx: location = cmds.pointPosition(vtx,w=True) test = pyRayIntersect(container,location,(0,1,0)) if(test): allIn.append(vtx) inner_faces = cmds.polyListComponentConversion(allIn,fv=True,tf=True) # select faces that facing the camera cmds.select(obj,r=True) cmds.selectMode(co=True) cmds.selectType(pf=True) cmds.setAttr('{0}.backfaceCulling'.format(obj),2) view = OMU.M3dView.active3dView() OM.MGlobal.selectFromScreen(0, 0, view.portWidth(), view.portHeight(), OM.MGlobal.kReplaceList) facing_cam_faces = cmds.ls(sl=True,fl=True) # combine both selection all_faces = [x for x in cmds.ls(inner_faces,fl=True) if x in cmds.ls(facing_cam_faces,fl=True)] return all_faces
def testGeoSampler(): sel = cmd.ls(sl=True) if len(sel) == 0: raise Exception("Selezionare il piano!") print '--------- Selection is: ' + sel[0] + ' ---------' cmd.selectMode(component=True) cmd.select(sel[0] + '.vtx[:]') cmd.polyGeoSampler(cs=False, cdo=False, dg=False, ac=True, bf=False) vtxNumber = len(cmd.getAttr(sel[0] + '.vtx[:]')) # cmd.softSelect(sse=1, ssd=1) for i in range(0, vtxNumber): v = sel[0] + '.vtx[%d]' % i cmd.select(v, r=True) vColor = cmd.polyColorPerVertex(query=True, r=True, g=True, b=True) r = vColor[0] g = vColor[1] b = vColor[2] h = colorToElevation(r, g, b) cmd.move(h, y=True, r=True) cmd.softSelect(sse=0) cmd.selectMode(object=True)
def set_select_mode(self, *types): """ replace the existing selection mode (object, component etc) with the types supplied. Cache the existing mode for later restore """ self.select_mode = {k: cmds.selectMode(**{'q': 1, k: 1}) for k in ALL_SELECT_MODES} options = {k: k in types for k in ALL_SELECT_MODES} cmds.selectMode(**options)
def bufMoveRelease(): """release the Buf move vertex mode""" activePanel = cmds.getPanel(withFocus=True) cmds.modelEditor(activePanel, e=True, manipulators=True) cmds.setToolTo('moveSuperContext') cmds.selectPref(clickDrag=False) cmds.selectMode(component=True) cmds.selectMode(object=True)
def face_extraction(faces=None, deleteOrg=True, selectDuplicated=True, transferWeight=True): ''' メッシュを選択したフェイスで切り分ける deleteOrg 切り分け元のフェイスを削除するかどうかを指定デフォルトTrue faces → 外部ツールからフェイスのリストを渡して実行したい場合の引数 ''' if faces is None: selection = cmds.ls(sl=True) else: selection = faces selObjects = [] for sel in selection: objNameTemp = sel.split('.') if not objNameTemp[0] in selObjects: selObjects.append(objNameTemp[0]) cmds.select(cl=True) duplicated = [] # 最後の選択格納用 # ハイライトされているオブジェクト毎に処理 for selObj in selObjects: compTemp = [] # バラバラのコンポーネントをオブジェクト毎に格納するリスト # 選択されているコンポーネントを整理 for sel in selection: objNameTemp = sel.split('.') objName = objNameTemp[0] # コンポーネントのオブジェクト名 # オブジェクト名が一致且つフェイス選択ならリスト入り if selObj == objName and '.f[' in sel: compTemp.append(sel) # print('compTemp ALL : '+str(compTemp)) if len(compTemp) != 0: dupObj = cmds.duplicate(selObj, rr=True) # 子供のオブジェクト取得関数呼び出し children = cmds.listRelatives(dupObj[0], type='transform', ad=True) # 子供のオブジェクトがある場合は重複を避けるため削除 if children: cmds.delete(children) duplicated.append(dupObj[0]) if transferWeight: # ウェイト転送フラグが有効だったら weight.transfer_weight(selObj, dupObj, logTransfer=False) # ウェイトを転送 faces = ",".join(compTemp) # リストを括弧のない文字列に faces = faces.replace(selObj, dupObj[0]) # 名前置き換え delface = faces.split(',') cmds.selectMode(co=True) cmds.hilite(dupObj) cmds.select(delface, r=True) #print('del face :',delface) for obj in dupObj: face_count = str(len(common.conv_comp(obj, mode='face'))) cmds.select(obj+'.f[0:'+face_count+']', tgl=True) #mel.eval('InvertSelection;') # 選択の反転 deleter = cmds.ls(sl=True) cmds.delete(deleter) # 最初に選択されていなかったフェース部分のみ削除 # 削除フラグが立っていたら古いフェイス削除 if deleteOrg is True: cmds.delete(compTemp) if selectDuplicated: cmds.select(duplicated) return duplicated
def create_job(self): cmds.selectMode(co=True) #cmds.select(cl=True) self.reset_var() self.script_job = cmds.scriptJob(cu=True, e=("SelectionChanged", qt.Callback(self.append_polygon))) self.undo_flag = False print 'create append job :', self.script_job
def Hardedge_Check(*args): obj = cmds.ls(selection=True) # 存储当前选择物体 cmds.polySelectConstraint(m=3, t=0x8000, sm=1) # 只选择硬边 sel = cmds.ls(selection=True) # 存储选择边 cmds.polySelectConstraint(sm=0) # 还原选zhi择约束 cmds.select(obj) # 还原之前选择的物体 cmds.selectMode(component=True) # 更改选择模式 cmds.selectType(edge=True) # 更改选择项为到边模式 cmds.select(sel) # 选择存储的边
def object_selection(selection_set): try: curr_object = current_object() mel.eval(command) except: pass select_set(selection_set) cmds.selectMode(object=True)
def main(mesh=None, pop_zero_poly=False): cmds.selectMode(o=True) # pop_zero_poly→ゼロポリゴンメッシュを発見した場合に警告メッセージを出すかどうか msg01 = lang.Lang(en="There is a zero polygon object : ", ja="ゼロポリゴンのメッシュが存在します : ") msg02 = lang.Lang( en= "As it is in selected state, please process accordingly\n(Recommended to delete)", ja="選択状態になっているので適宜処理してください \n(削除推奨)", ) if mesh is None: selection = cmds.ls(sl=True) selection_l = cmds.ls(sl=True, l=True) else: selection = mesh selection_l = cmds.ls(mesh, l=True) zero_mesh = modeling.cehck_zero_poly_object(mesh=selection, pop_msg=False) # リストタイプじゃなかったらリストに変換する if not isinstance(selection, list): temp = selection selection = [] selection.append(temp) clusterCopy = modeling.ClusterCopy() engine = "maya" for node, node_l in zip(selection, selection_l): if node in zero_mesh: print("Skip Zero Triangle Mesh :", node) continue # メッシュノードを含むオブジェクトのみ処理する。 meshnode = cmds.listRelatives(node_l, s=True, pa=True, type="mesh", fullPath=True) if meshnode: defCls = clusterCopy.copy(node) bs_dict = store_blend_shape(node) # ブレンドシェイプを保存 copyWeight(node_l, engine=engine) freezeModeling(node_l, engine=engine) if defCls: clusterCopy.paste(node) set_blend_shape(node, bs_dict) cmds.select(cl=True) for s in selection: try: cmds.select(s, add=True) except Exception as e: print(e.message) if zero_mesh and pop_zero_poly: msg = msg01.output() + str(len(zero_mesh)) msg += "\n" + msg02.output() for p in zero_mesh: msg += "\n[ " + p + " ]" cmds.confirmDialog(title="Warning", message=msg) cmds.select(zero_mesh, r=True)
def reset_select_mask(self): """ resets any selection modes set by this tool """ if self.select_mode: cmds.selectMode(**self.select_mode) self.select_mode = None if self.select_type: cmds.selectType(**self.select_type) self.select_type = None
def ngons(tris=False): typegon = 'ngons' if tris == True: tris = 1 typegon = 'triangles' else: tris = 3 sel = mc.select(ado=True) sel = mc.ls(sl=True) full_sel = [] for each in sel: mc.listRelatives(each, c=True) mc.selectMode(component=True) #Change to Face Component Mode mc.selectType(smp=False, sme=True, smf=False, smu=False, pv=False, pe=False, pf=True, puv=False) #Select Object/s and Run Script to highlight Triangles mc.polySelectConstraint(mode=3, type=0x0008, size=tris) mc.polySelectConstraint(disable=False) ngons = mc.polyEvaluate(faceComponent=True) mc.polySelectConstraint(disable=True) mc.select(cl=True) mc.selectMode(object=True) mc.select(cl=True) if ngons == 0: print('No ' + str.capitalize(typegon) + ' found !') print('There are ' + str(ngons) + ' ' + str.capitalize(typegon) + ' found on this asset.') return ngons
def ngons_on_selected(tris=False): typegon = 'ngons' if tris == True: tris = 1 typegon = 'triangles' else: tris = 3 sel = mc.ls(sl=True) if not sel: sys.exit('Nothing selected !') mc.selectMode(component=True) #Change to Face Component Mode mc.selectType(smp=False, sme=True, smf=False, smu=False, pv=False, pe=False, pf=True, puv=False) #Select Object/s and Run Script to highlight Triangles mc.polySelectConstraint(mode=3, type=0x0008, size=tris) mc.polySelectConstraint(disable=False) ngons = mc.polyEvaluate(faceComponent=True) mc.polySelectConstraint(disable=True) if ngons == 0: print('No ' + str.capitalize(typegon) + ' found !') print('There are ' + str(ngons) + ' ' + str.capitalize(typegon) + ' found on this piece of asset.') if ngons == 1: typegon = typegon[:-1] mc.warning(str(ngons) + ' ' + str(typegon) + ' found.') return ngons
def toggle_mute_skinning(): msg01 = lang.Lang( en= "No mesh selection.\nWould you like to process all of mesh in this scene?.", ja="選択メッシュがありません。\nシーン内のすべてのメッシュを処理しますか?", ).output() msg02 = lang.Lang(en="Yes", ja="はい").output() msg03 = lang.Lang(en="No", ja="いいえ").output() msg04 = lang.Lang(en="Skinning is disabled", ja="スキニングは無効になりました").output() msg05 = lang.Lang(en="Skinning is enabled", ja="スキニングが有効になりました").output() cmds.selectMode(o=True) objects = cmds.ls(sl=True, l=True) ad_node = [] for node in objects: children = cmds.ls(cmds.listRelatives(node, ad=True, f=True), type="transform") ad_node += [node] + children # print(len(ad_node)) objects = set(ad_node) # print(len(objects)) if not objects: all_mesh = cmds.confirmDialog( m=msg01, t="", b=[msg02, msg03], db=msg02, cb=msg03, icn="question", ds=msg03, ) if all_mesh == msg02: objects = cmds.ls(type="transform") if not objects: return mute_flag = 1 skin_list = [] for node in objects: skin = cmds.ls(cmds.listHistory(node), type="skinCluster") if not skin: continue skin_list.append(skin) if cmds.getAttr(skin[0] + ".envelope") > 0: mute_flag = 0 for skin in skin_list: cmds.setAttr(skin[0] + ".envelope", mute_flag) if mute_flag == 0: cmds.confirmDialog(m=msg04) if mute_flag == 1: cmds.confirmDialog(m=msg05)
def crack_obj( self, dag_node, crack_value, *args ): cmds.duplicate( dag_node.name() )[0] mesh_copy = oopmaya.DAG_Node() cmds.delete( mesh_copy.name(), ch = True ) cmds.makeIdentity( mesh_copy.name(), a = True, t = True, r = True, s = True ) dag_node.hide() dag_node.short_name() cmds.select( mesh_copy.name() ) mel.eval( 'solidShatter( "{0}_shatter_grp", {1}, 0, 1, 0, 0, 0, 0, 3, "shapes", 0, 0);'.format( dag_node.short_name(), crack_value ) ) cmds.selectMode( object = True )
def Upgrade(): mc.selectMode(co=True) Hard = mc.ls(sl=True) #gets selection mc.polySelectConstraint(m=3, t=0x8000, sm=1) #constraints hard edges and selects them mc.polyBevel3(fraction=0.5, offsetAsFraction=1, depth=1, chamfer=0, segments=1, subdivideNgons=1, mergeVertices=1) mc.polySelectConstraint(sm=0) # turn off edge smoothness constraint
def resetVertices(): """ Reset vertices of selected plane at y=0 (local space) :return: None """ sel = cmd.ls(sl=True) if len(sel) == 0: raise Exception("Selezionare il piano!") cmd.selectMode(component=True) cmd.select(sel[0]+'.vtx[:]') cmd.move(0, y=True, ls=True) cmd.selectMode(o=True)
def poles(self, arg=None): listOne=list() listTwo=list() selObj=self.selection_grab() if selObj: pass else: print "select polygon vertices" return if ".vtx[" in selObj[0]: pass else: print "You need to make a selection of vertices for this tool to interrogate." return cmds.selectMode(object=True) jim=cmds.ls (sl=True) cmds.select(cl=True) if cmds.objExists("Npoles")==True: cmds.delete("Npoles") cmds.sets(n="Npoles", co=1) if cmds.objExists("Epoles")==True: cmds.delete("Epoles") cmds.sets(n="Epoles", co=4) if cmds.objExists("starpoles")==True: cmds.delete("starpoles") cmds.sets(n="starpoles", co=7) for each in selObj: getComponent = cmds.polyInfo(each, ve=True) getVerts=getComponent[0].split(':')[1] edgeCount=re.findall(r'\d+', getVerts) if (len(edgeCount))==3: cmds.sets(each, fe='Npoles') elif (len(edgeCount))==5: cmds.sets(each, fe='Epoles') elif (len(edgeCount))>5: cmds.sets(each, fe='starpoles') cmds.select('starpoles', r=True, ne=True) cmds.pickWalk(d='Up') errorFound=cmds.ls(sl=True) if (len(errorFound))==0: cmds.delete("starpoles") cmds.select('Npoles', r=True, ne=True) cmds.pickWalk(d='Up') errorFound=cmds.ls(sl=True) if (len(errorFound))==0: cmds.delete("Npoles") cmds.select('Epoles', r=True, ne=True) cmds.pickWalk(d='Up') errorFound=cmds.ls(sl=True) if (len(errorFound))==0: cmds.delete("Epoles")
def toggle_mute_skinning(): msg01 = lang.Lang( en= 'No mesh selection.\nWould you like to process all of mesh in this scene?.', ja=u'選択メッシュがありません。\nシーン内のすべてのメッシュを処理しますか?').output() msg02 = lang.Lang(en='Yes', ja=u'はい').output() msg03 = lang.Lang(en='No', ja=u'いいえ').output() msg04 = lang.Lang(en='Skinning is disabled', ja=u'スキニングは無効になりました').output() msg05 = lang.Lang(en='Skinning is enabled', ja=u'スキニングが有効になりました').output() cmds.selectMode(o=True) objects = cmds.ls(sl=True, l=True) ad_node = [] for node in objects: children = cmds.ls(cmds.listRelatives(node, ad=True, f=True), type='transform') ad_node += [node] + children #print len(ad_node) objects = set(ad_node) #print len(objects) if not objects: all_mesh = cmds.confirmDialog(m=msg01, t='', b=[msg02, msg03], db=msg02, cb=msg03, icn='question', ds=msg03) if all_mesh == msg02: objects = cmds.ls(type='transform') if not objects: return mute_flag = 1 skin_list = [] for node in objects: skin = cmds.ls(cmds.listHistory(node), type='skinCluster') if not skin: continue skin_list.append(skin) if cmds.getAttr(skin[0] + '.envelope') > 0: mute_flag = 0 for skin in skin_list: cmds.setAttr(skin[0] + '.envelope', mute_flag) if mute_flag == 0: cmds.confirmDialog(m=msg04) if mute_flag == 1: cmds.confirmDialog(m=msg05)
def three(self): if cmds.selectMode(query=1, object=1): cmds.selectMode(component=1) self.selectionMask('face') else: # select mode is set to component if self.getType(0) == 'vertex' or self.getType(0) == 'edge': cmds.select(self.convertSelection('face')) self.selectionMask('face') else: if cmds.selectType(query=1, polymeshFace=True): cmds.selectMode(object=1) cmds.selectType(allComponents=False) else: self.selectionMask('face')
def three(self): if cmds.selectMode ( query = 1, object = 1): cmds.selectMode ( component = 1) self.selectionMask( 'face' ) else: # select mode is set to component if self.getType(0) == 'vertex' or self.getType(0) == 'edge': cmds.select(self.convertSelection('face')) self.selectionMask( 'face' ) else: if cmds.selectType( query = 1, polymeshFace = True): cmds.selectMode ( object = 1) cmds.selectType( allComponents = False ) else: self.selectionMask( 'face' )
def checkTriangle (self, *args): cmds.select(cmds.ls(type="mesh")) # to get triangles cmds.selectMode( co=True ) cmds.selectType( pf=True ) cmds.polySelectConstraint( m=3, t=8, sz=1 ) components = cmds.ls(sl=True) self.updateButton(components, self.widgets['checkTriangle_button'], self.widgets['selectTriangle_button']) cmds.polySelectConstraint( sz=0 ) # turn off face size constraint cmds.selectMode( o=True ) return components
def checkNonTriangulatable (self, *args): cmds.select(cmds.ls(type="mesh")) # to get triangles cmds.selectMode( co=True ) cmds.selectType( pf=True) cmds.polySelectConstraint( m=3, t=8, tp=1 ) components = cmds.ls(sl=True) self.updateButton(components, self.widgets['checkNonTriangulatable_button'], self.widgets['selectNonTriangulatable_button']) cmds.polySelectConstraint( tp=0 ) # turn off the face topology constraint cmds.selectMode( o=True ) return components
def badNGons(self): sel = cmds.ls(sl=1) cmds.selectMode(q=1, co=1) cmds.polySelectConstraint(m=3, t=0x0008, sz=3) cmds.polySelectConstraint(dis=1) numPolys = cmds.polyEvaluate(fc=1) try: self.polyCountLabel.setText('Poly Counts: %s N-Gon(s)' % str(int(numPolys))) except: self.polyCountLabel.setText('Please Select a Mesh!')
def crack_obj(self, dag_node, crack_value, *args): cmds.duplicate(dag_node.name())[0] mesh_copy = oopmaya.DAG_Node() cmds.delete(mesh_copy.name(), ch=True) cmds.makeIdentity(mesh_copy.name(), a=True, t=True, r=True, s=True) dag_node.hide() dag_node.short_name() cmds.select(mesh_copy.name()) mel.eval( 'solidShatter( "{0}_shatter_grp", {1}, 0, 1, 0, 0, 0, 0, 3, "shapes", 0, 0);'.format( dag_node.short_name(), crack_value ) ) cmds.selectMode(object=True)
def paste_uv(self, mode="component"): if os.path.exists(self.saveFile): with open(self.saveFile, "r") as f: save_uv_data = json.load(f) self.copy_uvs = save_uv_data["copy_uv"] else: return sel = cmds.ls(sl=True, l=True) self.paste_uvs = cmds.polyListComponentConversion(sel, tuv=True) self.paste_uvs = cmds.filterExpand(self.paste_uvs, sm=35) cmds.select(self.paste_uvs, r=True) cmds.selectMode(o=True) target_obj = [obj.split(".")[0] for obj in cmds.ls(sl=True, l=True)] # print('get target :', target_obj) freeze_m.main(mesh=target_obj) if not self.paste_uvs: return paste_objects = list(set([uv.split(".")[0] for uv in self.paste_uvs])) # cmds.bakePartialHistory(paste_objects, pre=True) # print(paste_objects) paste_uvs_dict = {obj: [] for obj in paste_objects} # print(paste_uvs_dict) for uv in map(lambda uv: uv.split("."), self.paste_uvs): paste_uvs_dict[uv[0]] += [".".join(uv)] # print(paste_uvs_dict) for paste_uvs in paste_uvs_dict.values(): # print(paste_uvs) cmds.select(cl=True) cmds.select(self.copy_uvs, r=True) cmds.select(paste_uvs, add=True) if mode == "component": sample_space = 4 if mode == "world": sample_space = 0 # print(mode) cmds.transferAttributes( flipUVs=0, transferPositions=0, transferUVs=2, searchMethod=3, transferNormals=0, transferColors=0, colorBorders=1, sampleSpace=sample_space, ) freeze_m.main(mesh=target_obj) cmds.select(target_obj, r=True)
def advanceMove(): """ enter a custom click and drag selection mode this is to be used with 'advanceMoveRelease' """ cmds.selectMode(component=True) cmds.selectMode(object=True) sel = cmds.ls(sl=True) # enter the move mode and set on vertex if sel: shape = cmds.listRelatives(sel[0]) if cmds.nodeType(shape) == 'nurbsCurve': try: cmds.delete(sel, ch=True) cmds.selectMode(component=True) activePanel = cmds.getPanel(withFocus=True) cmds.modelEditor(activePanel, e=True, manipulators=False) cmds.setToolTo('moveSuperContext') cmds.selectType(alc=0) cmds.selectType(controlVertex=1) cmds.selectPref(clickDrag=True) except: pass if cmds.nodeType(shape) == 'mesh': try: cmds.delete(sel, ch=True) cmds.selectMode(component=True) activePanel = cmds.getPanel(withFocus=True) cmds.modelEditor(activePanel, e=True, manipulators=False) cmds.setToolTo('moveSuperContext') cmds.selectType(alc=0) cmds.selectType(vertex=1) cmds.selectPref(clickDrag=True) except: pass else: try: cmds.delete(sel, ch=True) cmds.selectMode(component=True) activePanel = cmds.getPanel(withFocus=True) cmds.modelEditor(activePanel, e=True, manipulators=False) cmds.setToolTo('moveSuperContext') cmds.selectType(alc=0) cmds.selectType(vertex=1) cmds.selectPref(clickDrag=True) except: pass
def change_selection(): #print '*+*+*+*+*+*+*+selection changed+*+*+*+*+*+*+* :', cmds.ls(sl=True) global bake_mode if bake_mode: return #return if group_mode: group_selection() #コンポーネント選択の時はアンドゥできなくなるのでヒストリ取得を無効にしてからマトリックス取得実行 cmds.undoInfo(swf=False) get_matrix() cmds.undoInfo(swf=True) #コンテキストを切り替えてリアルタイム検出を有効にする。 #restore_context_and_axis() #コンテキストのpodモードを選択タイプによって切り替える sb.chenge_manip_type() sb.change_selection_display() #オブジェクト変更があった場合はセンターをベイクして再度センターモードに入りなおす #print 'check center mode in culc :', center_mode if cmds.selectMode(q=True, o=True): if center_mode: #cmds.undoInfo(cn='cng_center', ock=True) sb.toggle_center_mode(mode=False, change=True) sb.toggle_center_mode(mode=True, change=True) #qt.Callback(sb.transform_center() sb.transform_center() #cmds.undoInfo(cn='cng_center', cck=True) return #COGモードチェックしておく sb.window.setup_object_center() #UIの変更を反映する sb.check_option_parm()
def doneCmd(self): """""" if cmds.ls(sl=1): softSelectData = scData.SoftSelectionData(None, setup.getSupportTypes().keys()) weightData = softSelectData.getWeightData() append = cmds.checkBox(self.appendCheck, q=1, v=1) if self._type == 'joint': scData.JointFn.redefineWeight(self.influence, weightData, append) elif self._type == 'cluster': scData.ClusterFn.redefineWeight(self.influence, weightData, append) # Recover select mode cmds.selectMode( object=True ) cmds.select( self.influence ) self.toggleButton()
def one(self): if cmds.selectMode ( query = 1, object = 1): cmds.selectMode ( component = 1) self.selectionMask( 'vertex' ) else: # select mode is set to component if self.getType(0) == 'face' or self.getType(0) == 'edge': # Check to see if another component is alread selected # This will switch the selection over cmds.select(self.convertSelection('vertex')) self.selectionMask( 'vertex' ) else: if cmds.selectType( query = 1, polymeshVertex = True): cmds.selectMode ( object = 1) cmds.selectType( allComponents = False ) else: self.selectionMask( 'vertex' )
def object_mode(): """ Perform a task in object mode then restores mode to previous. """ try: object_mode = cmds.selectMode(q=True, object=True) if not object_mode: current_mode = get_active_select_mode() cmds.selectMode(object=True) object_flags = get_active_flags_in_mask(object=True) cmds.selectType(allObjects=True) yield finally: cmds.selectType(**{k: True for k in object_flags}) if not object_mode: cmds.selectMode(**{current_mode: True})
def bufMove(): """enter the Buf move vertex mode""" cmds.selectMode(component=True) cmds.selectMode(object=True) sel = cmds.ls(sl=True) # enter the move mode and set on vertex sel = cmds.ls(sl=True) shape = cmds.listRelatives(sel[0]) print cmds.nodeType(shape) if cmds.nodeType(shape) == 'nurbsCurve': try: cmds.delete(sel, ch=True) cmds.selectMode(component=True) activePanel = cmds.getPanel(withFocus=True) cmds.modelEditor(activePanel, e=True, manipulators=False) cmds.setToolTo('moveSuperContext') cmds.selectType(alc=0) cmds.selectType(controlVertex=1) cmds.selectPref(clickDrag=True) except: pass if cmds.nodeType(shape) == 'mesh': try: cmds.delete(sel, ch=True) cmds.selectMode(component=True) activePanel = cmds.getPanel(withFocus=True) cmds.modelEditor(activePanel, e=True, manipulators=False) cmds.setToolTo('moveSuperContext') cmds.selectType(alc=0) cmds.selectType(vertex=1) cmds.selectPref(clickDrag=True) except: pass else: try: cmds.delete(sel, ch=True) cmds.selectMode(component=True) activePanel = cmds.getPanel(withFocus=True) cmds.modelEditor(activePanel, e=True, manipulators=False) cmds.setToolTo('moveSuperContext') cmds.selectType(alc=0) cmds.selectType(vertex=1) cmds.selectPref(clickDrag=True) except: pass
def component_mode(): """ Perform a task in component mode then restore to previous mode. """ try: component_mode = cmds.selectMode(q=True, component=True) if not component_mode: current_mode = get_active_select_mode() cmds.selectMode(component=True) component_flags = get_active_flags_in_mask() cmds.selectType(allCoponents=True) yield finally: cmds.selectType(**{k: True for k in component_flags}) if not component_mode: cmds.selectMode(**{current_mode: True})
def build(self,*a,**kw ): if mc.draggerContext(self.name,query=True,exists=True): # if it exists, delete it mc.setToolTo('selectSuperContext') mc.selectMode(object=True) mc.deleteUI(self.name) imageFilePath = ('cgmDefault.png') mc.draggerContext( self.name, image1 = imageFilePath, undoMode = self.undoMode, projection = self.projection, space = self.space, initialize = self.initialPress, pressCommand = self.press, releaseCommand = self.release, finalize = self.finalize, *a,**kw ) if self.projection == 'plane': mc.draggerContext(self.name,e=True, plane = self.plane)# if our projection is 'plane', set the plane if self.dragOption:mc.draggerContext(self.name,e=True, dragCommand = self.drag)# If drag mode, turn it on
def storeSelectionData (): if RitalinRememberSelections == True: if cmds.undoInfo(q = true, redoName = True) == "": ComponentSelectMode = cmds.selectMode (query = True, component = True) if ComponentSelectMode == True: #print("Storing current component selection...") Sel = cmds.ls(sl = True) hiliteObjs = cmds.ls (hilite = True) if (cmds.selectType (query = True, polymeshVertex = True) == True): if findStoredVertexSelectionTemplate () != None: #print ("Clearing stored vertex selections first...") for obj in hiliteObjs: allVerts = getAllObjVertices(obj) if len(allVerts) > 0: cmds.polyBlindData(allVerts, typeId = 99410, associationType = "vertex", booleanData = False, longDataName = "StoredVertexSelectionData", shortDataName = "SVSD") vertList = list() for cmp in Sel: if cmp.find (obj + ".vtx[") > -1: vertList.append(cmp) #print ("Storing data for currently selected vertices: " + str(vertList)) if len(vertList) > 0: StoredVertexSelectionData = cmds.polyBlindData(vertList, typeId = 99410, associationType = "vertex", booleanData = True, longDataName = "StoredVertexSelectionData", shortDataName = "SVSD") result = cmds.rename ( StoredVertexSelectionData , obj + "_StoredVertexSelectionData") elif (cmds.selectType (query = True, polymeshFace = True) == True): if findStoredFaceSelectionTemplate () != None: #print ("Clearing stored face selections first...") for obj in hiliteObjs: allFaces = getAllObjFaces(obj) if len(allFaces) > 0: cmds.polyBlindData(allFaces, typeId = 99411, associationType = "face", booleanData = False, longDataName = "StoredFaceSelectionData", shortDataName = "SFSD") faceList = list() for cmp in Sel: if cmp.find (obj + ".f[") > -1: faceList.append(cmp) #print ("Storing data for currently selected faces: " + str(faceList) ) if len(faceList) > 0: StoredFaceSelectionData = cmds.polyBlindData(faceList, typeId = 99411, associationType = "face", booleanData = True, longDataName = "StoredFaceSelectionData", shortDataName = "SFSD") result = cmds.rename ( StoredFaceSelectionData , obj + "_StoredFaceSelectionData") elif (cmds.selectType (query = True, polymeshEdge = True) == True): if findStoredEdgeSelectionTemplate () != None: #print ("Clearing stored edge selections first...") for obj in hiliteObjs: allEdges = getAllObjEdges(obj) if len(allEdges) > 0: cmds.polyBlindData(allEdges, typeId = 99412, associationType = "edge", booleanData = False, longDataName = "StoredEdgeSelectionData", shortDataName = "SESD") edgeList = list() for cmp in Sel: if cmp.find (obj + ".e[") > -1: edgeList.append(cmp) #print ("Storing data for currently selected edges: " + str(edgeList) ) if len(edgeList) > 0: StoredEdgeSelectionData = cmds.polyBlindData(edgeList, typeId = 99412, associationType = "edge", booleanData = True, longDataName = "StoredEdgeSelectionData", shortDataName = "SESD") result = cmds.rename( StoredEdgeSelectionData , obj + "_StoredEdgeSelectionData")
def get_active_select_mode(): """ Return the current selection mode. """ for i in [ 'component', 'hierarchical', 'leaf', 'object', 'preset', 'root', 'template' ]: if cmds.selectMode(q=True, **{i: True}): return i
def getNgons(q=False): '''Selects Ngons in Selection Args: q(boolean): if true fucntion returns the selection. Return: result(list): the NGons in selection ''' cmds.selectMode(co=True) cmds.selectType(smp=False, sme=True, smf=False, smu=False, pv=False, pe=True, pf=False, puv=False) cmds.polySelectConstraint(mode=3, t=0x0008, size=3) cmds.polySelectConstraint(disable=True) nPolys = cmds.polyEvaluate(faceComponent=True) print >> sys.stderr, str(nPolys) + ' N-Gon(s) Selected.', if q: result = cmds.ls(sl=True, fl=True) return result
def sclCtrlShape (_sel, _factor,_sclX = True, _sclY = True, _sclZ = True): #set default scale factors factorX = 1 factorY = 1 factorZ = 1 #set the user defined values if (_sclX == True): factorX = _factor if (_sclY == True): factorY = _factor if (_sclZ == True): factorZ = _factor #clear the selection cmds.select(clear = True) for controlName in _sel: #error catching, in case something other than a #curve or circle is selected cmds.selectMode(component = True) try: #selects the cvs in a nurbs curve or circle cmds.select(controlName+".cv[0:"+ str(getCVs(controlName)-1) + "]") except: #prints the reason for the failure print "Button not Activated: Control to Scale Must be a Curve or Circle" cmds.scale(factorX,factorY,factorZ, os = True, r = True) #select all of the controls that were originally selected cmds.selectMode(object = True) cmds.select(_sel)
def nonquads(ngons=True, query=False): """ Select all nonquads from an object. """ type_ = 3 if ngons else 1 if query: selected = mampy.daglist() cmds.selectMode(component=True) cmds.selectType(facet=True) cmds.polySelectConstraint(mode=3, t=0x0008, size=type_) cmds.polySelectConstraint(disable=True) ngons = mampy.daglist() if query: cmds.select(selected.cmdslist()) return ngons sys.stdout.write(str(len(ngons)) + ' N-Gon(s) Selected.\n')
def smoothEdgeLineFromUI(): """ Smooth Edge Line From UI """ # Get Edge Selection sel = cmds.ls(sl=True, fl=True) edges = cmds.filterExpand(sel, ex=True, sm=32) verts = cmds.filterExpand(sel, ex=True, sm=31) if not edges and verts: cmds.select(verts) mel.eval('ConvertSelectionToContainedEdges') edges = cmds.filterExpand(ex=True, sm=32) if not edges: print('Select a list of connected vertices or edges and run again...') return # Get Mesh from vertices mesh = cmds.ls(edges, o=True) # Get UI Parameters smooth = cmds.intSliderGrp('smoothEdges_smoothISG', q=True, v=True) falloff = cmds.floatSliderGrp('smoothEdges_falloffFSG', q=True, v=True) edgeSpacing = cmds.checkBoxGrp('smoothEdges_edgeSpacingCBG', q=True, v1=True) snapToOrig = cmds.checkBoxGrp('smoothEdges_snapToOrigCBG', q=True, v1=True) delHistory = cmds.checkBoxGrp('smoothEdges_deleteHistoryCBG', q=True, v1=True) # Smooth Edges smoothEdgeLine(edges, smooth=smooth, falloff=falloff, snapToOrig=snapToOrig, keepEdgeSpacing=edgeSpacing, deleteHistory=delHistory) # Restore Selection if sel: cmds.selectMode(component=True) cmds.selectType(edge=True) cmds.hilite(mesh) cmds.select(edges)
def _decapitate(targets, edges, orig_mesh, index_target=1): """ Takes a lsit of target meshes and deparates them from their bodies so we have isolated head meshes Args: targets [str]: list of target meshes to separate edges [str]: list of edges orig_mesh (str): the original mesh we are replacing from the blends file name index_target (int): used just in case the separate is targetting the wrong index of shell Returns [str]: list of face template meshes created from the targets """ blend_table = {} for edge in [edge for edge in edges if '.' in edge]: transform = edge.split('.')[0] try: blend_table[transform].append(edge) except KeyError: blend_table[transform] = [edge] heads = [] for target in targets: for transform, edges in blend_table.iteritems(): target_shape = mc.listRelatives(target, s=True)[0] edges = [edge.replace(transform, target) for edge in edges] if mc.ls(edges) and len(list(set(mc.ls(edges))))==len(edges): mc.selectMode(co=True) mc.selectType(alc=0, pe=1) mc.select(mc.ls(edges), r=True) mc.polySplitEdge(operation=1, ch=1) shells = mc.polySeparate(target_shape, ch=False) for index, shell in enumerate(shells): if index != index_target: mc.delete(shell) else: shell=shell mc.ungroup(target, w=True) heads.append(shell) mc.selectMode(o=True) return heads
def selectionMask(self, toType): if cmds.selectMode( query = 1, component = True): cmds.selectType( allComponents = False ) if toType == 'face': cmds.selectType(polymeshFace = True) elif toType == 'edge': cmds.selectType(polymeshEdge = True) elif toType == 'vertex': cmds.selectType(polymeshVertex = True) else: cmds.selectType(polymeshFace = True) # default in case no type matches else: cmds.selectType( allComponents = False, allObjects = True )
def evenEdgeSpacingFromUI(): ''' Even Edge Spacing From UI ''' # Get Edge Selection sel = mc.ls(sl=True,fl=True) edges = mc.filterExpand(sel,ex=True,sm=32) verts = mc.filterExpand(sel,ex=True,sm=31) if not edges and verts: mc.select(verts) mm.eval('ConvertSelectionToContainedEdges') edges = mc.filterExpand(ex=True,sm=32) if not edges: print('Select a list of connected vertices or edges and run again...') return # Get Mesh from vertices mesh = mc.ls(edges,o=True) # Get UI Parameters smooth = mc.intSliderGrp('evenEdgeSpacing_smoothISG',q=True,v=True) influence = mc.floatSliderGrp('evenEdgeSpacing_influenceFSG',q=True,v=True) snapToOrig = mc.checkBoxGrp('evenEdgeSpacing_snapToOrigCBG',q=True,v1=True) delHistory = mc.checkBoxGrp('evenEdgeSpacing_deleteHistoryCBG',q=True,v1=True) # Even Edge Spacing evenEdgeSpacing( edgeList = edges, smooth = smooth, influence = influence, snapToOrig = snapToOrig, deleteHistory = delHistory ) # Restore Selection if sel: mc.selectMode(component=True) mc.selectType(edge=True) mc.hilite(mesh) mc.select(edges)