我需要获取所有选定的顶点并将它们存储在一个数组中,这样我就可以遍历并找出有关每个顶点的信息.
虽然我无法弄清楚这一点.
sel = cmds.ls(sl=1)
print sel
Run Code Online (Sandbox Code Playgroud)
返回:
//[u'pCube1.vtx[50:53]', u'pCube1.vtx[74:77]']
Run Code Online (Sandbox Code Playgroud)
或多或少我需要我的'sel'变量来打印出这个:
pCube1.vtx[50]
pCube1.vtx[51]
pCube1.vtx[52]
pCube1.vtx[53]
pCube1.vtx[74]
pCube1.vtx[75]
pCube1.vtx[76]
pCube1.vtx[77]
Run Code Online (Sandbox Code Playgroud)
有没有人知道如何做到这一点,而不是字面上剥离字符串?我认为这是一个非常混乱的方式,并想知道是否有另一种可能性!也许使用OpenMaya的Maya API?
我正在使用 C++ 为 Autodesk Maya 编写一个插件,但出现链接器错误。
我的主类是 Maya_Search_Plugin.cpp
#include <Utilities.h>
DeclareSimpleCommand( search_face, PLUGIN_COMPANY, "4.5");
//doIt method is entry point for plugin
MStatus search_face::doIt( const MArgList& )
{
//calls to Maya types/functions and Utilities functions
}
Run Code Online (Sandbox Code Playgroud)
然后我有一个实用程序类,其中包含一些静态方法,其标头如下所示
#ifndef __Maya_CPP_Plugin__Utilities__
#define __Maya_CPP_Plugin__Utilities__
//#pragma once
//standard libs
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <iostream>
#include <math.h>
//maya libs
#include <maya/MDagPath.h>
#include <maya/MFn.h>
#include <maya/MFileIO.h>
#include <maya/MIOStream.h>
#include <maya/MFnMesh.h>
#include <maya/MFnTransform.h>
#include <maya/MGlobal.h>
#include <maya/MSelectionList.h>
#include <maya/MSimple.h>
#include <maya/MTypes.h>
#include <maya/MPointArray.h>
#include <maya/MObjectArray.h> …Run Code Online (Sandbox Code Playgroud) 我一直在这里阅读,但我无法在网上找到解决我问题的任何解决方案.我想我的缩进是正确的,但我仍然得到名称错误.有人可以帮助我.这个脚本应该在maya中运行一个新的面板,它的工作类型,但错误真的很烦人.
class PanelWindow( object ):
def __init__( self, name, title, namespace=__name__ ):
self.__name__ = name
self._title = title
self.instance = str(namespace) + '.' + self.__name__
if not pm.scriptedPanelType(self.__name__, q = True, ex = True):
pm.scriptedPanelType(self.__name__, u = True)
jobCmd = 'python(\\\"%s._setup()\\\")' % self.instance
job = "scriptJob -replacePrevious -parent \"%s\" -event \"SceneOpened\" \"%s\";" % ( self.__name__, jobCmd )
mel.eval(job)
pm.scriptedPanelType( self.__name__, e = True,
unique=True,
createCallback = 'python("%s._createCallback()")' % self.instance,
initCallback = 'python("%s._initCallback()" )' % self.instance,
addCallback = 'python("%s._addCallback()" )' % …Run Code Online (Sandbox Code Playgroud) 是否可以从Windows中的命令提示符(或linux中的bash)调用脚本来打开Maya,然后在Maya中运行自定义脚本(可能每次运行时更改它)?我正在寻找比更改userSetup文件然后运行Maya更优雅的东西.
这里的目标是能够打开.mb文件,运行脚本将场景定位在内部,设置一组通用灯光,然后将场景渲染到特定的位置和文件类型.我希望能够将其设置为计划任务,以检查目录中的任何新场景文件,然后打开maya并继续.
谢谢您的帮助!
问题:有没有办法使用 Python 访问正在运行的进程的标准输出?这个过程没有被 Python 启动。
上下文:有一个名为mayabatch的程序,它可以从 3D Maya 场景文件中渲染出图像。如果我从命令行运行程序,我会看到来自mayabatch 的进度消息。有时,艺术家会关闭这些窗口,直到程序完成后才能追踪进度。这导致我沿着这条路线尝试在它由外部进程产生后读取它的标准输出。
背景:
到目前为止,我的研究:如果它是一个子流程,我只找到了有关如何使用该subprocess模块执行此操作的问题和答案。我还简要地研究了psutil,但我找不到任何方法来读取进程的标准输出。
任何帮助将非常感激。谢谢你。
这是一个命名脚本,用于命名Autodesk Maya中的节点.然而,这个特定的脚本并没有使用特定的任何东西.
我刚才问过我会怎么做这样的事情,可以使用变量约定,然后出现模板.
所以如果我有这样的约定:
'${prefix}_${name}_${side}_${type}'
Run Code Online (Sandbox Code Playgroud)
我可以传递这些论点:
bind_thigh_left_joint
Run Code Online (Sandbox Code Playgroud)
然后通过缩写词典(以及用户缩写词典)运行它们,使用场景文件中的相关节点进行检查以确保没有重复项,最后得到: bn_thigh_L_jnt
但是我想要它,以便如果其中一个键具有第一个大写字母,它将使替换大写.
例如,如果{$prefix}是代替{$Prefix}大腿会成为大腿,或者如果{$prefix}是{$PREFIX}大腿会成为大腿上.但是,如果它是{$PREfix}大腿仍然只是大腿.
我可以很容易地做到这一点,除了我无法检测钥匙的个别情况.例如,如果字符串是'${Prefix}_${name}_${SIDE}_${type}'我如何找到什么案例前缀,如果我知道,我将如何使用此模板?
请注意,这段代码不是我所拥有的确切代码,我已经省略了许多其他更具特色的东西,这只是处理替换本身.
from string import Template
import collections
def convert(prefix, name, side, obj_type):
user_conv = '${Prefix}_${name}_${SIDE}_${type}'
# Assigns keys to strings to be used by the user dictionary.
subs = {'prefix': prefix, 'name': name, 'side': side, 'type': obj_type}
# Converts all of user convention to lowercase, and substitutes the names from subs.
new_name = Template(user_conv.lower())
new_name = …Run Code Online (Sandbox Code Playgroud) .ma我正在尝试在 Python 脚本末尾打开一个 Maya 场景,
路径看起来像这样:G:\ProjectPath\Scene.ma。
但我知道的唯一命令是 MEL 命令:
file -f -options "v=0; p=17; f=0" -ignoreVersion -typ "mayaAscii" -o
"G:/ProjectPath/Scene.ma";
addRecentFile("G:/ProjectPath/Scene.ma", "mayaAscii");
Run Code Online (Sandbox Code Playgroud)
有人知道如何用 Python 实现这一点吗?
我有从Maya用MEL导出Alembic的脚本:
AbcExport(-frameRange 31 41 -writeVisibility -dataFormat ogawa -root |myChar:char|myChar:GEOchar -file E:/test.abc)
Run Code Online (Sandbox Code Playgroud)
我想用Python做同样的事情.就像是 :
cmds.AbcExport(...)
Run Code Online (Sandbox Code Playgroud)
我找不到任何关于它的文件......有什么想法吗?
非常感谢!
因此,我有数百个必须使用一个脚本运行的maya文件。所以我在想为什么我什至要打扰maya,我应该能够从python shell(而不是maya的python shell,windows的python shell)进行操作
因此,想法是:
fileList = ["....my huge list of files...."]
for f in fileList:
openMaya
runMyAwesomeScript
Run Code Online (Sandbox Code Playgroud)
我找到了这个:
C:\Program Files\Autodesk\Maya201x\bin\mayapy.exe
maya.standalone.initialize()
Run Code Online (Sandbox Code Playgroud)
看起来好像加载了某物,因为我可以看到我的脚本是从自定义路径加载的。但是,它不会使maya.exe运行。
欢迎提供任何帮助,因为我从未进行过此类Maya python外部操作。
PS使用Maya 2015和python 2.7.3
我正在尝试采用我之前在代码中添加的文件纹理,并将其添加到maya中的选定网格中.我对python和脚本编写起来很陌生,现在我已经苦苦挣扎了几天,所以我的代码可能很乱.
import maya.cmds as cmds
from os import listdir
class TextureImport():
def __init__(self):
if cmds.window(TextureImport, q=True, exists=True):
cmds.deleteUI(TextureImport)
GUI=cmds.window(title="Texture Import Tool", widthHeight=(250,160), s=True, tlb=True)
cmds.rowColumnLayout(numberOfColumns=1, columnAlign=(1, 'center'), columnAttach=(1, 'both', 0), cw=(1,250))
cmds.button(label="Select Directory", command=self.select_dir)
cmds.separator(style='in', h=20)
cmds.optionMenu('optionMenu', label="File List")
cmds.button(label="Clear List", command=self.clear_list)
cmds.separator(style='in', h=20)
cmds.text('Select your object, then:', h=25)
cmds.button(label="Apply Texture", command=self.apply_texture)
cmds.setParent('..')
cmds.showWindow()
def select_dir(self, *args):
basicFilter = "Image Files (*.jpg *.jpeg *.tga *.png *.tiff *.bmp *.psd)"
self.myDir = cmds.fileDialog2 (fileFilter=basicFilter, dialogStyle=2, fm=3)
myFiles = listdir(self.myDir[0])
for items in …Run Code Online (Sandbox Code Playgroud)