maya_mel语言中多边形点的提取和遍历操作方法
生活随笔
收集整理的這篇文章主要介紹了
maya_mel语言中多边形点的提取和遍历操作方法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一、問題分析:
有老同事問我,向用maya mel語言為模型上的選擇單獨點,做沿著法向方向的移動。如下圖:
并使用了如下代碼操作單個定點,成功了,:
之后,又同時選擇多個點操作,出現了如下錯誤。
點不再沿著法線移動而是垂直向上了。
二、解決方法:
分析研究后法線,maya對元素點線面的選擇時,會以一種集合方式操作。必須使用 filterExpand 命令來轉化為獨立的單個元素,才能在for循環里調用:
用editplus文本編輯器,批量文件搜索工具在maya官方scripts腳本中查找filterExpand 用法:如下圖:
發現了各類元素的分解方法:
看看多邊形點的分解方式:
以上程序可以把選擇多邊形元素轉換為獨立點集合。之后在用for就可以操作了。秀給一下如上的代碼再測試一下:
string $pp[]; string $v; $pp =` getVerts `;for ($v in $pp) { select -cl;select $v;move -r -cs -ls -wd 1 0 0 ; }成功了!阿彌陀佛
三、官方的filterExpand 命令文檔如下:
命令 (MEL) 過濾器展開 在類別中: 建模, NURBS 無幀轉到:劇情簡介。返回值。相關。標志。MEL 示例。概要 filterExpand [-expand boolean] [-fullPath boolean] [-selectionMask int] [-symActive] [-symNegative] [-symPositive] [-symSeam]filterExpand 是不可操作、不可查詢且不可編輯的。根據選定的組件(或在命令行上指定的組件),命令將篩選和/或擴展給定選項的列表。返回包含所有匹配選擇項的字符串數組。選擇蒙版如下所示: 對象類型 面具 處理 0 努爾斯曲線 9 努爾布斯表面 10 努爾布斯曲面曲線 11 多邊形 12 定位器 XYZ 22 方向定位器 23 紫外線定位器 24 控制頂點 (CV) 28 編輯點 30 多邊形頂點 31 多邊形邊 32 多邊形面 34 多邊形 UV 35 細分網格點 36 細分網格邊 37 細分網格面 38 曲線參數點 39 曲線結 40 曲面參數點 41 表面結 42 表面范圍 43 修剪表面邊緣 44 表面等臂 45 晶格點 46 粒子 47 縮放透視表 49 旋轉樞軸 50 選擇手柄 51 細分曲面 68 多邊形頂點面 70 NURBS 表面面 72 細分網格 UV 73 返回值 字符串[] 命令結果 相關 選擇類型 標志 expand, fullPath, selectionMask, symActive, symNegative, symPositive, symSeam 長名稱(短名稱) 參數類型 性能 -expand(-ex) boolean 創造 如果這是真的,則每個項目都是一個實體。默認值為 true。 -fullPath(-fp) boolean 創造 如果為 true 并且選擇項是 DAG 對象,則僅當此值為 false 時,才返回其完整的選擇路徑,而不是對象的名稱。默認值為 false。 -selectionMask(-sm) int 創造多用途 指定選擇蒙版 -symActive(-sma) 創造 如果啟用了對稱性,則僅返回對象活動對稱側的組件。如果對稱性不處于活動狀態,則此標志不起作用。 -symNegative(-smn) 創造 如果啟用了對稱性,則僅返回對象負側相對于當前對稱平面的分量。如果對稱性不處于活動狀態,則此標志不起作用。 -symPositive(-smp) 創造 If symmetry is enabled only return the components on the positive side of the object relative to the current symmetry plane. This flag has no effect if symmetry is not active. -symSeam(-sms) create If symmetry is enabled only return the components that lie equally on both sides of the object relative to the current symmetry plane. This flag has no effect if symmetry is not active.Flag can appear in Create mode of command Flag can appear in Edit mode of commandFlag can appear in Query mode of command Flag can be used more than once in a command. MEL examples // Returns any selected isoparms (mask 45) as individual items // (because of "-ex true"). filterExpand -ex true -sm 45;// Returns any selected CVs (mask 28) as compact items. For example, // if curve.cv[0:3] is selected, then "curve.cv[0:3]" is returned. // If "-ex true", then four items are returned, one for each CV. filterExpand -ex false -sm 28;// Returns any selected CVs (mask 28) and edit points (mask 30). filterExpand -sm 28 -sm 30;// Returns any selected nurbs curves. filterExpand -sm 9;// Returns any selected nurbs curves-on-surface. filterExpand -sm 11;// return the poly faces (mask 34) from the specified arguments filterExpand -sm 34 "pCube1.f[1]" "pCube1.f[4]" "pCube1.vtx[0:3]";南無阿彌陀佛,哈哈哈。
總結
以上是生活随笔為你收集整理的maya_mel语言中多边形点的提取和遍历操作方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python天天向上和天天向下代码解析_
- 下一篇: 一口气Ping1000个IP地址,会发生