将OBJ文件导入maya场景(MEL / Python) [英] Importing OBJ file to maya scene (MEL/Python)

查看:1011
本文介绍了将OBJ文件导入maya场景(MEL / Python)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个脚本,我需要在其中导入外部OBJ文件。我一直在阅读,我认为应该使用文件命令完成。我转到maya文档,找不到有关使用它的明确示例。为了做到这一点,我应该通过哪些参数?

I am working on a script in which I need to import an external OBJ file. I have been reading and I think that should be done using the file command. I go to the maya documentation and find no clear examples about using it. What arguments should I pass in order to do that?

我在MEL中看到了一个例子: http://forums.cgsociety.org/showthread.php?t=144296

I have seen an example in MEL which is in this thread: http://forums.cgsociety.org/showthread.php?t=144296

file -import -type "OBJ" -options "mo=1" -pr $sourceFiles[$x];

此外,maya应该有一条有用的路径去收集OBJ项目,它会在哪里?我应该写一个环境变量或什么来查询OBJ的位置,以便maya可以从那里选择并将它带到现场吗?

Furthermore there should be a useful path for maya to go and collect the OBJ item, where would it be? Should I write an environment variable or something in order to query the location of the OBJ so that maya can pick it from there and bring it to the scene?

谢谢大家。

推荐答案

我不确定你是否在这里找到了文件命令文件:文件命令,但有大量的信息!

I'm not sure if you found the file command docs here: File command, however there is loads of info on it!

根据我的理解,你想从源目录导入一系列obj,如果我错了,请原谅我,但这就是我如何解释你的问题。

To my understanding, you want to import a series of obj's from a source directory, forgive me if I'm wrong in but that's how I've interpreted your question.

import maya.cmds as cmds

pathOfFiles = "/path/to/folder/containing/objs/"
fileType = "obj"

files = cmds.getFileList(folder=pathOfFiles, filespec='*.%s' % fileType)
if len(files) == 0:
    cmds.warning("No files found")
else:
    for f in files:
        cmds.file(pathOfFiles + f, i=True)

我们在这里做的是指向一条路径,在那里搜索一个文件类型路径,而不是一旦找到它们就导入它们。

What we're doing here, is pointing to a path, searching for a file type in that path and than importing them once they're found.

希望这有助于

这篇关于将OBJ文件导入maya场景(MEL / Python)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆