资讯详情

maya_mel语言中多边形点的提取和遍历操作方法

一、问题分析:

一位老同事问我,向用maya mel语言是模型上的单独点,沿法向移动。如下图所示: 在这里插入图片描述 并使用以下代码操作单个定点,成功:

string $pp[]; string $obj; $pp = `ls -sl`; for ($obj in $pp) {        select -cl;     select $obj;     move -r -cs -ls -wd  1 0 0 ; } 

之后,同时选择多点操作,出现以下错误。 点不再沿法线移动,而是垂直向上移动。

二、解决方案:

后法线分析研究,maya在选择元素点线表面时,将采用集合操作。必须使用 filterExpand 只有将命令转化为独立的单个元素,才能在for循环调用:

用editplus文本编辑器、批量文件搜索工具maya官方scripts脚本中查找filterExpand 用法如下: 发现了各种元素的分解方法: 看多边形点的分解方法:

// Copyright 2017 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. //  global proc string[] getVerts() {  select -r `polyListComponentConversion -tv`;  string $result[]=`filterExpand -ex true -sm 31`;  return $result; } 

以上程序可将选择的多边形元素转换为独立点集合。然后使用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。默认值为 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 command  Flag 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]";  

南无阿弥陀佛,哈哈哈。

标签: 韩国cas传感器型号smn

锐单商城拥有海量元器件数据手册IC替代型号,打造 电子元器件IC百科大全!

锐单商城 - 一站式电子元器件采购平台