2014-11-24 43 views
0

我想創建一個腳本來導入場景,運行nCloth模擬並將結果導出爲OBJ格式。Maya:在獨立模式和嵌入模式下的不同行爲

我使用的輸入是從Maya的「入門」部分下載的。該腳本使用Python編寫,以便在獨立模式下啓動:http://pastebin.com/3hptPYbB

在Maya中啓動時,該腳本正常工作。在獨立模式下,nCloth仿真不會觸發,因爲仿真前的場景會導致腳本非常快地終止。

有誰知道爲什麼兩種運行模式之間的結果不同,以及如何解決這個問題?也許應該事先加載一個nCloth插件?

感謝,

回答

2

在這種情況下,我認爲它實際上是在bakeResults標誌。我能得到這個在Maya中獨立工作:

import maya.mel 
import maya.cmds as cmds 
cmds.file(new=True, f=True) 
cmds.polyCube() 
cmds.polyPlane(sx = 21, sy = 22) 
cmds.xform(t= (.0005, .015, .0005)) # note units - my maya is working in meters... 
mel.eval("createNCloth 0;") 
maya.mel.eval("createNCloth 0;") 
cmds.select('pCube1') 
maya.mel.eval("makeCollideNCloth") 
cmds.playbackOptions(animationStartTime=0) 
cmds.playbackOptions(animationEndTime=100) 
cmds.play(f=True) 
cmds.bakeResults('pPlane1', simulation=True, t=(1,20), disableImplicitControl=True, sb = 1, shape=True, cp=True) 

# use openMaya to set the frame - cmds.currentTime does not 
# stick in standalone: 
import maya.OpenMaya as om 
om.MGlobal.viewFrame(20) 
# delete the cloth solution 
cmds.delete('nCloth1', 'nRigid1') 
# delete the orphaned shape 
cmds.delete('pPlaneShape1') 
cmds.file(rename = "C:/test/cloth.mb") 
cmds.file(save=True) 

我注意到了設置烘烤結果的形狀和控制點標誌,需要這兩個問題,而需要從分離出烤形狀刪除布料求解器後的原始幾何圖形。在這個例子中,刪除布和剛體,而不刪除pPlaneShape1留下原始飛機懸掛在空中的副本。您可能需要刪除刪除內容並查看結果以瞭解此場景中的功能。

+0

使用API​​繞過獨立的currentTime問題!棒極了。 – kartikg3 2014-11-24 19:06:35

+0

我想知道爲什麼我們需要這樣做。有關爲什麼我們需要這樣做@theodox的想法嗎? – kartikg3 2014-11-24 19:09:12

+1

我不確定。如果你運行cmds.currentTime,它會提前計時 - 用'cmds.currentTime(q = True)'檢查結果 - 但它似乎並沒有更新文件關於GUI不存在的時間的「永久性」的想法。瑪雅之謎 – theodox 2014-11-24 20:10:51

相關問題