import pymel.core as pm import maya.cmds as cmds #指定ノード以下のシェイプノードのバウンディングボックスを取得 def get_boundingbox(root): if isinstance(root,str) == True: root = pm.PyNode(root) transforms = root.listRelatives(ad=True,type="transform") pm.select(transforms) bbox = cmds.polyEvaluate(b=True, ae=True) return bbox #バウンディングボックスの位置にロケータ作成 def make_bbox_locator(bbox ,root): for x in bbox[0]: for y in bbox[1]: for z in bbox[2]: l = pm.spaceLocator(p=(x, y, z)) pm.parent(l ,root) min = int(pm.Env().minTime) max = int(pm.Env().maxTime) step = 5 #フレームステップ数 obj = pm.selected()[0] root = pm.group(em=True, name='bbox_root') for fr in range(min ,max ,step): pm.currentTime(fr) bbox = get_boundingbox(obj) make_bbox_locator(bbox ,root)
import pymel.core as pm import pymel.core as pm import maya.cmds as cmds def get_boundingbox(root): if isinstance(root,str) == True: root = pm.PyNode(root) transforms = root.listRelatives(ad=True,type="transform") pm.select(transforms) bbox = cmds.polyEvaluate(b=True, ae=True) print bbox files = get_boundingbox(pm.selected()[0])
#!/usr/bin/env python
#!/usr/bin/env python # -*- coding: utf-8 -*- import pymel.core as pm import os import shutil #指定ノード以下に接続されている全テクスチャノードを取得 def get_all_texture_node(root_node): if isinstance(root_node, str) == True: root_node = pm.PyNode(root_node) shapes = root_node.listRelatives(ad=True, type="mesh") file_nodes = [] for i in shapes: shading_engines = i.connections(type="shadingEngine") for s in shading_engines: shader_list = s.surfaceShader.connections() for shader in shader_list: file_node = shader.connections(type="file") file_nodes += file_node return file_nodes #指定ノード以下に接続されているテクスチャパスのリスト def get_use_texture_list(root_node): file_nodes = get_all_texture_node(root_node) files = [] for tex in file_nodes: files.append(tex.fileTextureName.get()) files = list(set(files)) return files #指定ノード以下に接続されているテクスチャを指定のディレクトリに接続し直し def set_texture_to_specified_dir(root_node, dir): file_nodes = get_all_texture_node(root_node) for tex in file_nodes: def_path = tex.fileTextureName.get() base_name = os.path.basename(def_path) new_path = os.path.join(dir, base_name) if os.path.isfile(new_path): tex.fileTextureName.set(new_path) #ファイルリストを指定のディレクトリにコピーする def copy_filelist(list ,copy_dir): os.makedirs(copy_dir) for e in files: shutil.copy(e, copy_dir) dir = r"c:\temp\test\test2" node = pm.selected()[0] files = get_use_texture_list(node) copy_filelist(files ,dir) set_texture_to_specified_dir(node ,dir)
import pymel.core as pm select_node = pm.selected()[0] skinCluster_node = select_node.inMesh.inputs()[0] bind_node = skinCluster_node.matrix.inputs() for n in bind_node: print n
import pymel.core as pm import pymel.core as pm select_node = pm.selected()[0] skinCluster_node = select_node.inMesh.inputs()[0] bind_node = skinCluster_node.matrix.inputs() for i in range(len(bind_node)): print bind_node[i] print pm.getAttr(skinCluster_node.bindPreMatrix[i])