Python maya.cmds.ls() Examples
The following are 30
code examples of maya.cmds.ls().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
maya.cmds
, or try the search function
.
Example #1
Source File: dpFacialControl.py From dpAutoRigSystem with GNU General Public License v2.0 | 7 votes |
def dpLoadBSNode(self, *args): """ Load selected object as blendShapeNode """ selectedList = cmds.ls(selection=True) if selectedList: if cmds.objectType(selectedList[0]) == "blendShape": cmds.textField(self.bsNodeTextField, edit=True, text=selectedList[0]) self.dpLoadBSTgtList(selectedList[0]) self.bsNode = selectedList[0] elif cmds.objectType(selectedList[0]) == "transform": meshList = cmds.listRelatives(selectedList[0], children=True, shapes=True, noIntermediate=True, type="mesh") if meshList: bsNodeList = cmds.listConnections(meshList[0], type="blendShape") if bsNodeList: self.dpLoadBSTgtList(bsNodeList[0]) self.bsNode = bsNodeList[0] else: mel.eval("warning \""+self.langDic[self.langName]["e018_selectBlendShape"]+"\";") else: mel.eval("warning \""+self.langDic[self.langName]["e018_selectBlendShape"]+"\";") else: mel.eval("warning \""+self.langDic[self.langName]["e018_selectBlendShape"]+"\";") else: mel.eval("warning \""+self.langDic[self.langName]["e018_selectBlendShape"]+"\";")
Example #2
Source File: sets.py From SISideBar with MIT License | 6 votes |
def add_to_set_members(): selection = cmds.ls(sl=True) if selection: setCount = 0 for node in selection: if cmds.nodeType(node) != 'objectSet': continue for sel in selection: if sel == node: continue try: cmds.sets(sel, add=node) except Exception as e: print e.message setCount += 1 if setCount == 0: cmds.confirmDialog( title='Error',message='Please select set_node') #選択セットのノード、コンポーネントを削除
Example #3
Source File: lib.py From core with MIT License | 6 votes |
def lsattr(attr, value=None): """Return nodes matching `key` and `value` Arguments: attr (str): Name of Maya attribute value (object, optional): Value of attribute. If none is provided, return all nodes with this attribute. Example: >> lsattr("id", "myId") ["myNode"] >> lsattr("id") ["myNode", "myOtherNode"] """ if value is None: return cmds.ls("*.%s" % attr, recursive=True, objectsOnly=True, long=True) return lsattrs({attr: value})
Example #4
Source File: lib.py From core with MIT License | 6 votes |
def maintained_selection(): """Maintain selection during context Example: >>> scene = cmds.file(new=True, force=True) >>> node = cmds.createNode("transform", name="Test") >>> cmds.select("persp") >>> with maintained_selection(): ... cmds.select("Test", replace=True) >>> "Test" in cmds.ls(selection=True) False """ previous_selection = cmds.ls(selection=True) try: yield finally: if previous_selection: cmds.select(previous_selection, replace=True, noExpand=True) else: cmds.select(clear=True)
Example #5
Source File: AEsporeNodeTemplate.py From spore with MIT License | 6 votes |
def add_instance(self): """ add a source to the instancer and the sporeNode """ selection = cmds.ls(sl=True, l=True) spore_node = selection.pop(-1) num_items = cmds.textScrollList('instanceList', numberOfItems=True, q=True) items = cmds.textScrollList('instanceList', q=True, ai=True) instances = node_utils.get_instanced_geo(self._node) for i, obj in enumerate(selection): # TODO - check if object type is valid if obj not in instances: obj_name = '[{}]: {}'.format(i + num_items, obj) cmds.textScrollList('instanceList', e=1, append=obj_name) node_utils.connect_to_instancer(obj, self._node)
Example #6
Source File: dpRivet.py From dpAutoRigSystem with GNU General Public License v2.0 | 6 votes |
def dpLoadGeoToAttach(self, geoName=None, geoFromUI=None, *args): """ Load selected object a geometry to attach rivet. """ if geoName: selectedList = [geoName] elif geoFromUI: selectedList = [cmds.textField(self.geoToAttachTF, query=True, text=True)] else: selectedList = cmds.ls(selection=True) if selectedList: if self.dpCheckGeometry(selectedList[0]): self.geoToAttach = selectedList[0] cmds.textField(self.geoToAttachTF, edit=True, text=self.geoToAttach) self.dpLoadUVSet(self.geoToAttach) else: mel.eval("warning \"Select a geometry in order use it to attach rivets, please.\";")
Example #7
Source File: dpControls.py From dpAutoRigSystem with GNU General Public License v2.0 | 6 votes |
def pasteAttr(self, destinationList=False, verbose=False, *args): """ Get to destination list and set the dictionary values on them. """ # getting destinationList: if not destinationList: destinationList = cmds.ls(selection=True, long=True) if destinationList and self.attrValueDic: # set dic values to destinationList: for destItem in destinationList: for attr in self.attrValueDic: try: cmds.setAttr(destItem+'.'+attr, self.attrValueDic[attr]) except: try: cmds.setAttr(destItem+'.'+attr, self.attrValueDic[attr], type='string') except: pass if verbose: print self.dpUIinst.langDic[self.dpUIinst.langName]["e016_notPastedAttr"], attr if verbose: print self.dpUIinst.langDic[self.dpUIinst.langName]["i126_pastedAttr"]
Example #8
Source File: dpUtils.py From dpAutoRigSystem with GNU General Public License v2.0 | 6 votes |
def findModuleLastNumber(className, typeName): """ Find the last used number of this type of module. Return its highest number. """ # work with rigged modules in the scene: numberList = [] guideTypeCount = 0 # list all transforms and find the existing value in them names: transformList = cmds.ls(selection=False, transforms=True) for transform in transformList: if cmds.objExists(transform+"."+typeName): if cmds.getAttr(transform+"."+typeName) == className: numberList.append(className) # try check if there is a masterGrp and get its counter: if cmds.objExists(transform+".masterGrp") and cmds.getAttr(transform+".masterGrp") == 1: guideTypeCount = cmds.getAttr(transform+'.dp'+className+'Count') if(guideTypeCount > len(numberList)): return guideTypeCount else: return len(numberList)
Example #9
Source File: dpUtils.py From dpAutoRigSystem with GNU General Public License v2.0 | 6 votes |
def getOriginedFromDic(): """ List all transforms in the scene, verify if there is an originedFrom string attribute and store it value in a dictionary. Return a dictionary with originedFrom string as keys and transform nodes as values of these keys. """ originedFromDic = {} allTransformList = cmds.ls(selection=False, type="transform") if allTransformList: for transform in allTransformList: if cmds.objExists(transform+".originedFrom"): tempOriginedFrom = cmds.getAttr(transform+".originedFrom") if tempOriginedFrom: if not ";" in tempOriginedFrom: originedFromDic[tempOriginedFrom] = transform else: tempOriginedFromList = tempOriginedFrom.split(";") for orignedFromString in tempOriginedFromList: originedFromDic[orignedFromString] = transform return originedFromDic
Example #10
Source File: manager.py From spore with MIT License | 6 votes |
def context_request(self, widget, action): if action.text() == 'Delete': selection = cmds.ls(sl=1, typ='sporeNode') for geo_wdg, spore_wdgs in self.wdg_tree.iteritems(): for spore_wdg in spore_wdgs: spore_node = spore_wdg.name print spore_node if spore_wdg.is_selected and cmds.objExists(spore_node): instancer = node_utils.get_instancer(spore_node) transform = cmds.listRelatives(spore_node, p=True, f=True) if len(cmds.listRelatives(transform, c=1)) == 1: cmds.delete((spore_node, transform[0], instancer)) else: cmds.delete((spore_node, instancer)) selection.remove(spore_node) cmds.select(selection) self.refresh_spore()
Example #11
Source File: transform.py From SISideBar with MIT License | 6 votes |
def move_center_each_object(): object_mode = cmds.selectMode( q=True, o=True ) cmds.selectMode(o=True) selection = cmds.ls(sl=True, l=True) meshes = common.search_polygon_mesh(selection, fullPath=True, nurbs=True) if not meshes: return dummy = common.TemporaryReparent().main(mode='create') for m in meshes: cmds.selectMode(o=True) common.TemporaryReparent().main(m, dummyParent=dummy, mode='cut') cmds.select(m, r=True) if not object_mode: cmds.selectMode(co=True) move_center2selection() common.TemporaryReparent().main(m, dummyParent=dummy, mode='parent') common.TemporaryReparent().main(dummyParent=dummy, mode='delete') freeze.main(mesh=selection) cmds.select(selection, r=True)
Example #12
Source File: transform.py From SISideBar with MIT License | 6 votes |
def reset_actor(): from . import sisidebar_sub sel = cmds.ls(sl=True, l=True) joints = cmds.ls(sl=True, l=True, type='joint') if not joints: joints = [] for s in sel: if cmds.nodeType(s) == 'KTG_ModelRoot': child_joints = cmds.ls(cmds.listRelatives(s, ad=True, f=True), l=True, type='joint') if child_joints: joints += child_joints if not sel: joints = cmds.ls(l=True, type='joint') for j in joints: con_info = cmds.connectionInfo(j+'.bindPose', dfs=True) if not con_info: continue con_info = con_info[0] bind_info = con_info.replace('world', 'xform') pose = cmds.getAttr(bind_info) cmds.xform(j, m=pose) sisidebar_sub.get_matrix()
Example #13
Source File: uv.py From SISideBar with MIT License | 6 votes |
def ajustSelection(self): #選択したものからメッシュノードがあるものを取り出し。 #何も選択されていなかったらシーン内のメッシュ全取得 selection = cmds.ls(sl=True) #print len(selection) #print selection if self.popUpMsg: if len(selection) == 0: allMeshSel = cmds.confirmDialog(m=self.msg01, t='', b= [self.msg02, self.msg03], db=self.msg02, cb=self.msg03, icn='question',ds=self.msg03) #print allMeshSel if allMeshSel == self.msg02: selection = cmds.ls(type='transform') else: if len(selection) == 0: #print 'process all of mesh' selection = cmds.ls(type='transform') #メッシュノードが存在したらリストに加える return [sel for sel in selection if common.search_polygon_mesh(sel)]
Example #14
Source File: go.py From SISideBar with MIT License | 6 votes |
def maya_import(): temp = __name__.split('.')#nameは自分自身のモジュール名。splitでピリオドごとに3分割。 folderPath = os.path.join(os.getenv('MAYA_APP_DIR'),'Scripting_Files','go') if not os.path.exists(folderPath): os.makedirs(os.path.dirname(folderPath+'\\')) # 末尾\\が必要なので注意 #print folderPath files = os.listdir(folderPath) if files is not None: for file in files: print file nameSpace = file.replace('.ma', '') cmds.file(folderPath+'\\'+file, i=True, typ="mayaAscii", iv=True, mnc=False, options="v=0;", pr=True) #重複マテリアルにファイル名が頭に付与されてしまうのを修正 allMat = cmds.ls(mat=True) fileName = file.split('.')[0] for mat in allMat: if mat.startswith(fileName+'_'): cmds.rename(mat, mat.replace(fileName+'_', '')) cmds.inViewMessage( amg='<hl>Go Maya</hl> : Imoprt objects', pos='midCenterTop', fade=True, ta=0.75, a=0.5) else: cmds.inViewMessage( amg='<hl>Go Maya</hl> : There is no exported object', pos='midCenterTop', fade=True, ta=0.75, a=0.5)
Example #15
Source File: freeze.py From SISideBar with MIT License | 6 votes |
def freeze(): cmds.selectMode(o=True) selection = cmds.ls(sl=True, type = 'transform') dummy = common.TemporaryReparent().main(mode='create')#モジュールでダミーの親作成 clusterCopy = modeling.ClusterCopy() for sel in selection: allChildren = [sel] + cmds.listRelatives(sel, ad=True)#子供を取得して1つのリストにする polyMesh = common.search_polygon_mesh(allChildren) if polyMesh: for mesh in polyMesh: common.TemporaryReparent().main(mesh, dummyParent=dummy, mode='cut') defCls = clusterCopy.copy(mesh) cmds.bakePartialHistory(mesh,pc=True) if defCls: clusterCopy.paste(mesh) common.TemporaryReparent().main(mesh, dummyParent=dummy, mode='parent')#コピーのおわったメッシュの子供を元に戻す common.TemporaryReparent().main(dummyParent=dummy, mode='delete')#ダミー親削除 cmds.select(selection, r=True)
Example #16
Source File: sisidebar_sub.py From SISideBar with MIT License | 6 votes |
def pre_pro_reference(sel=None): global pre_ref_mode, pre_sel, ctx_mode, pre_obj_list if cmds.selectMode(q=True, o=True): pre_ref_mode = 'object' else: prej_ref_mode = 'component' if cmds.selectType(q=True, pv=True): pre_ref_mode = 'vertex' if cmds.selectType(q=True, pe=True): pre_ref_mode = 'edge' if cmds.selectType(q=True, pf=True): pre_ref_mode = 'face' pre_sel = sel if cmds.selectMode(q=True, co=True): cmds.selectMode(o=True) pre_obj_list = cmds.ls(sl=True, l=True) cmds.selectMode(co=True) return pre_ref_mode
Example #17
Source File: lib.py From core with MIT License | 5 votes |
def apply_shaders(relationships, namespace=None): """Given a dictionary of `relationships`, apply shaders to meshes Arguments: relationships (avalon-core:shaders-1.0): A dictionary of shaders and how they relate to meshes. """ if namespace is not None: # Append namespace to shader group identifier. # E.g. `blinn1SG` -> `Bruce_:blinn1SG` relationships = { "%s:%s" % (namespace, shader): relationships[shader] for shader in relationships } for shader, ids in relationships.items(): print("Looking for '%s'.." % shader) shader = next(iter(cmds.ls(shader)), None) assert shader, "Associated shader not part of asset, this is a bug" for id_ in ids: mesh, faces = (id_.rsplit(".", 1) + [""])[:2] # Find all meshes matching this particular ID # Convert IDs to mesh + id, e.g. "nameOfNode.f[1:100]" meshes = list(".".join([mesh, faces]) for mesh in lsattr("mbID", value=mesh)) if not meshes: continue print("Assigning '%s' to '%s'" % (shader, ", ".join(meshes))) cmds.sets(meshes, forceElement=shader)
Example #18
Source File: uv.py From SISideBar with MIT License | 5 votes |
def copy_uv(self): sel = cmds.ls(sl=True, l=True) self.copy_uvs = cmds.polyListComponentConversion(sel, tuv=True) self.copy_uvs = cmds.filterExpand(self.copy_uvs, sm=35) if self.copy_uvs: save_uv_data = {'copy_uv':self.copy_uvs } with open(self.saveFile, 'w') as f: json.dump(save_uv_data, f)
Example #19
Source File: utils.py From maya-retarget-blendshape with GNU General Public License v3.0 | 5 votes |
def getSelectedMeshes(): """ Get all selected meshes, the current selection will be looped and checked if any of the selected transforms contain a mesh node. If this is the case the transform will be added to the selection list. :return: Parents nodes of all selected meshes :rtype: list """ # get selection selection = cmds.ls(sl=True, l=True) extendedSelection = [] # extend selection for sel in selection: extendedSelection.extend( cmds.listRelatives(sel, s=True, ni=True, f=True) ) # return parent of meshes return list(set([ cmds.listRelatives(m, p=True, f=True)[0] for m in extendedSelection if cmds.nodeType(m) == "mesh" ])) # ----------------------------------------------------------------------------
Example #20
Source File: transform.py From SISideBar with MIT License | 5 votes |
def set_joint_orient(reset=True): from . import sisidebar_sub joints = cmds.ls(sl=True, type='joint') if len(joints) == 0: confirm_mes = lang.Lang( en='Joint is not selected\nDo you want to process all the joints in the scene? ', ja=u'ジョイントが選択されていません\nシーン内のすべてのジョイントを処理しますか?' ) rtn = pm.cmds.confirmDialog(title='Confirm', message=confirm_mes.output(), button=['Yes', 'No'], defaultButton='Yes', cancelButton='No', dismissString='No') if rtn != 'Yes': return False joints = cmds.ls('*', type='joint') if len(joints) == 0: pm.confirmDialog(title='Warning', message='Joint Object Nothing.', button='OK', icon='Warning') return False for j in joints: # マトリックス取得 mat = cmds.xform(j, q=True, m=True) # 回転とジョイントの方向をいったん0に cmds.rotate(0, 0, 0, j, objectSpace=True) cmds.joint(j, e=True, orientation=[0, 0, 0]) # マトリックス再設定、回転のみに数値が入る。 cmds.xform(j, m=mat) if reset: # 回転取得 rot = cmds.xform(j, q=True, ro=True) # 回転を0にしてジョイントの方向に同じ値を移す cmds.rotate(0, 0, 0, j, objectSpace=True) cmds.joint(j, e=True, orientation=rot) sisidebar_sub.get_matrix()
Example #21
Source File: manager_ui.py From spore with MIT License | 5 votes |
def __init__(self, name, parent=None): super(SporeItem, self).__init__(name, parent) self.node_name = name self.build_spore_ui() self.connect_signals() if name in cmds.ls(sl=1, typ='sporeNode'): self.select()
Example #22
Source File: dpBaseControlClass.py From dpAutoRigSystem with GNU General Public License v2.0 | 5 votes |
def cvCreate(self, useUI, cvID, cvName='Control_Ctrl', cvSize=1.0, cvDegree=1, cvDirection='+Y', cvRot=(0, 0, 0), cvAction=1, dpGuide=False, combine=False, *args): """ Check if we need to get parameters from UI. Create a respective curve shape. Return the transform curve or a list of selected destination items. """ # getting current selection: destinationList = cmds.ls(selection=True, type="transform") # check if the given name is good or add a sequencial number on it: self.cvName = utils.validateName(cvName, self.suffix) self.cvID = cvID self.cvSize = cvSize self.cvDegree = cvDegree self.cvDirection = cvDirection self.cvRot = cvRot self.cvAction = cvAction # getting UI info: if useUI: self.getControlUIValues(self.cvName) # combine or create curve using the parameters: if combine: self.cvCurve = self.generateCombineCurves(useUI, self.cvID, self.cvName, self.cvSize, self.cvDegree, self.cvDirection) else: # getting curve info to be created based on choose degree: if self.cvDegree == 1: #linear self.getLinearPoints() else: #cubic self.getCubicPoints() self.cvCurve = self.createCurve(self.cvName, self.cvDegree, self.cvPointList, self.cvKnotList, self.cvPeriodic, dpGuide) # set control direction for the control curve: self.setControlDirection(self.cvCurve, self.cvDirection) # working about action to do, like new control, add shape or replace shapes: self.doControlAction(destinationList) # select the result node and return it if self.cvAction == 1: #new control cmds.select(self.cvCurve) return self.cvCurve elif destinationList: cmds.select(destinationList) return destinationList
Example #23
Source File: dpSelectAllControls.py From dpAutoRigSystem with GNU General Public License v2.0 | 5 votes |
def dpFindAllGrp(self, *args): """ Try to find All_Grp without selection searching for all nodes in the scene. Returns the first one found. """ allNodeList = cmds.ls(selection=False) if allNodeList: for item in allNodeList: if self.dpCheckAllGrp(item): return item return False
Example #24
Source File: transform.py From SISideBar with MIT License | 5 votes |
def match_transform(mode='', child_comp=False): from . import sisidebar_sub pre_sel = cmds.ls(sl=True, l=True) selection = cmds.ls(sl=True, l=True, type='transform') if not selection: return cmds.undoInfo(openChunk=True) set_maching(nodes=selection, mode=mode ,pre_sel=pre_sel, child_comp=child_comp) msg = lang.Lang(en=u"<hl>Select Matching Object</hl>", ja=u"<hl>一致対象オブジェクトを選択してください</hl>") cmds.inViewMessage( amg=msg.output(), pos='midCenterTop', fade=True ) #cmds.select(cl=True) maching_tool = cmds.scriptCtx( title='Much Transform', totalSelectionSets=3, cumulativeLists=True, expandSelectionList=True, toolCursorType="edit", setNoSelectionPrompt='Select the object you want to matching transform.' ) #カスタムカーソルを設定 image_path = os.path.join(os.path.dirname(__file__), 'icon/') my_cursor = QCursor(QPixmap(image_path+'picker.png')) QApplication.setOverrideCursor(my_cursor) #cmds.hudButton('HUDHelloButton', e=True, s=7, b=5, vis=1, l='Button', bw=80, bsh='roundRectangle', rc=match_cancel ) global hud_but if maya_ver != 2017: try: hud_but = cmds.hudButton('HUD_match_cancel', s=7, b=5, vis=1, l='Cancel', bw=80, bsh='roundRectangle', rc=finish_matching) #print 'create' except: #print 'change' hud_but = cmds.hudButton('HUD_match_cancel',e=True, s=7, b=5, vis=1, l='Cancel', bw=80, bsh='roundRectangle', rc=finish_matching) jobNum = cmds.scriptJob(ro=True, e=('SelectionChanged', qt.Callback(trs_matching)), protected=True) sisidebar_sub.get_matrix()
Example #25
Source File: transform.py From SISideBar with MIT License | 5 votes |
def trs_matching(node=None, sel_org=True): global matching_obj global matching_mode global child_comp_flag #print matching_mode, matching_obj mode = matching_mode if node is None: mached_obj = cmds.ls(sl=True, l=True, type='transform') else: #print 'muched obj', node mached_obj = node if not mached_obj: if sel_org: finish_matching() return else: if isinstance(mached_obj, list): mached_obj = mached_obj[0] #print 'trs matching :', mached_obj scl = cmds.xform(mached_obj, q=True, s=True, ws=True) rot = cmds.xform(mached_obj, q=True, ro=True, ws=True) pos = cmds.xform(mached_obj, q=True, t=True, ws=True) for obj in matching_obj: if mode == 'scale' or mode == 'all': cmds.scale(1.0, 1.0, 1.0, obj, pcp=True) ws_scl = cmds.xform(obj, q=True, s=True, ws=True) cmds.scale(scl[0]/ws_scl[0], scl[1]/ws_scl[1], scl[2]/ws_scl[2], obj, pcp=child_comp_flag) if mode == 'rotate' or mode == 'all': cmds.rotate(rot[0], rot[1], rot[2], obj, ws=True, pcp=child_comp_flag) if mode == 'translate' or mode == 'all': cmds.move(pos[0], pos[1], pos[2], obj, ws=True, pcp=child_comp_flag) if sel_org: finish_matching() #アトリビュートの桁数を丸める
Example #26
Source File: transform.py From SISideBar with MIT License | 5 votes |
def round_transform(mode='', digit=3): from . import sisidebar_sub sel = cmds.ls(sl=True, l=True) axis = ['X', 'Y', 'Z'] if mode == 'all': mode_list = ['.translate', '.rotate', '.scale', '.jointOrient'] else: mode_list = ['.' + mode] for s in sel: for a, m in itertools.product(axis, mode_list): #print cmds.nodeType(s) , m #print cmds.nodeType(s) != 'joint' if cmds.nodeType(s) != 'joint' and m == '.jointOrient': #print m == '.jointOrient' #print 'Node Type Error' continue try: v = cmds.getAttr(s+m+a) #print v v = round(v, digit) cmds.setAttr(s+m+a, v) #print v except Exception as e: print e.message sisidebar_sub.get_matrix()
Example #27
Source File: texture.py From SISideBar with MIT License | 5 votes |
def rename_textures(delUnuseTex=True): attrPort = [ '.outColor', '.outAlpha', '.outTransparency' ] textures = cmds.ls(tex=True) #テクスチャを一括リネーム、未使用のものは削除 for tex in textures: deleteFlag = True#削除フラグ for portName in attrPort: #接続されたノードを返す。pフラグでアトリビュート名を合わせて取得。 try: connectItems = cmds.listConnections(tex+portName, p=True) except: print 'Get Attribute Error : '+texA+'.'+portName continue #接続を取得した変数がnoneTypeでなければ(接続があれば) if connectItems is not None: #if not isinstance(connectItems,type(None)): deleteFlag = False#削除フラグをFalseに if deleteFlag and delUnuseTex:#削除フラグがTrueなら cmds.delete(tex)#テクスチャ削除 continue#以降のリネーム処理を行わずfor文の最初に戻る try: sourceName = cmds.getAttr(tex+'.fileTextureName') fileExpName = sourceName.split('/')[-1] fileExpName = fileExpName.split('\\')[-1] fileName = fileExpName.split('.')[0] cmds.rename(tex,fileName) except: print 'Rename Error : '+tex continue
Example #28
Source File: texture.py From SISideBar with MIT License | 5 votes |
def __init__(self): materials = cmds.ls(mat=True) for mat in materials: self.__nodeName = []#サイクル接続されたノードどうしでの無限ループ回避 self.place2dItems = [] self.searchPlace2d(mat) if len(self.place2dItems) != 0: self.reconnectAttr() #place2dをつなぎ直すメソッド
Example #29
Source File: texture.py From SISideBar with MIT License | 5 votes |
def textrue_path_2_local(): selection = cmds.ls(type='file') for texture in selection: texName = cmds.getAttr(texture + '.fileTextureName') splitText = '/' #区切り文字が\\の場合の対応 if not splitText in texName: splitText = '\\' tempName = texName.split(splitText) newName = 'sourceimages'+splitText+tempName[-1] cmds.setAttr (texture + '.fileTextureName', newName, type = 'string')
Example #30
Source File: transform.py From SISideBar with MIT License | 5 votes |
def reset_transform(mode='', c_comp=False, reset_pivot=True): #print 'comp mode :', c_comp from . import sisidebar_sub if cmds.selectMode(q=True, co=True): return selections = cmds.ls(sl=True, l=True) #子供のノード退避用ダミーペアレントを用意 dummy = common.TemporaryReparent().main(mode='create') for sel in selections: if c_comp: common.TemporaryReparent().main(sel, dummyParent=dummy, mode='cut') if mode == 'all': cmds.xform(sel, t=[0, 0, 0]) cmds.xform(sel, ro=[0, 0, 0]) cmds.xform(sel, s=[1, 1, 1]) if mode == 'trans': cmds.xform(sel, t=[0, 0, 0]) if mode == 'rot': cmds.xform(sel, ro=[0, 0, 0]) if mode == 'scale': cmds.xform(sel, s=[1, 1, 1]) if mode == 'trans' or mode =='all': if reset_pivot: cmds.xform(sel+'.scalePivot', t=[0, 0, 0], os=True) cmds.xform(sel+'.rotatePivot', t=[0, 0, 0], os=True) if c_comp: common.TemporaryReparent().main(sel, dummyParent=dummy, mode='parent') common.TemporaryReparent().main(dummyParent=dummy, mode='delete')#ダミー親削除 cmds.select(selections, r=True) sisidebar_sub.get_matrix() #フリーズスケーリングをまとめて